[asterisk-commits] [svn-commits] mmichelson: branch 1.6.0 r111072 - in /branches/1.6.0: ./ apps/app_voicemail.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Mar 26 14:27:11 CDT 2008


Author: mmichelson
Date: Wed Mar 26 14:27:10 2008
New Revision: 111072

URL: http://svn.digium.com/view/asterisk?view=rev&rev=111072
Log:
Merged revisions 111067 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
r111067 | mmichelson | 2008-03-26 14:26:23 -0500 (Wed, 26 Mar 2008) | 17 lines

Merged revisions 111049 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r111049 | mmichelson | 2008-03-26 14:22:16 -0500 (Wed, 26 Mar 2008) | 9 lines

Add a lock to the vm_state structure and use the lock around mail_open calls
to prevent concurrent access of the same mailstream. This, along with trunk's
ability to configure TCP timeouts for IMAP storage will help to prevent
crashes and hangs when using voicemail with IMAP storage.

(closes issue #10487)
Reported by: ewilhelmsen


........

................

Modified:
    branches/1.6.0/   (props changed)
    branches/1.6.0/apps/app_voicemail.c

Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.0/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/branches/1.6.0/apps/app_voicemail.c?view=diff&rev=111072&r1=111071&r2=111072
==============================================================================
--- branches/1.6.0/apps/app_voicemail.c (original)
+++ branches/1.6.0/apps/app_voicemail.c Wed Mar 26 14:27:10 2008
@@ -416,6 +416,7 @@
 	int starting;
 	int repeats;
 #ifdef IMAP_STORAGE
+	ast_mutex_t lock;
 	int updated;                         /*!< decremented on each mail check until 1 -allows delay */
 	long msgArray[256];
 	MAILSTREAM *mailstream;
@@ -5042,7 +5043,9 @@
 #endif
 		/* Connect to mailbox to get mailstream so we can get delimiter */ 
 		imap_mailbox_name(tmp, sizeof(tmp), vms, 0, 1);
+		ast_mutex_lock(&vms->lock);
 		stream = mail_open (stream, tmp, debug ? OP_DEBUG : NIL);
+		ast_mutex_unlock(&vms->lock);
 		if (stream == NIL) {
 			ast_log(LOG_ERROR, "Can't connect to imap server %s\n", tmp);
 			return -1;
@@ -5057,7 +5060,9 @@
 	/* Now connect to the target folder */
 	imap_mailbox_name(tmp, sizeof(tmp), vms, box, 1);
 	ast_debug(3, "Before mail_open, server: %s, box:%d\n", tmp, box);
-	vms->mailstream = mail_open(stream, tmp, debug ? OP_DEBUG : NIL);
+	ast_mutex_lock(&vms->lock);
+	vms->mailstream = mail_open (stream, tmp, debug ? OP_DEBUG : NIL);
+	ast_mutex_unlock(&vms->lock);
 	if (vms->mailstream == NIL) {
 		return -1;
 	} else {
@@ -9779,8 +9784,10 @@
 	AST_LIST_TRAVERSE_SAFE_END
 	AST_LIST_UNLOCK(&vmstates);
 	
-	if (vc)
+	if (vc) {
+		ast_mutex_destroy(&vms->lock);
 		ast_free(vc);
+	}
 	else
 		ast_log(LOG_ERROR, "No vmstate found for user:%s, mailbox %s\n", vms->imapuser, vms->username);
 }
@@ -9809,6 +9816,7 @@
 	for (x = 0; x < 256; x++) {
 		vms->msgArray[x] = 0;
 	}
+	ast_mutex_init(&vms->lock);
 }
 
 static void check_msgArray(struct vm_state *vms) 


_______________________________________________
--Bandwidth and Colocation Provided by http://www.api-digital.com--

svn-commits mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/svn-commits

-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.




More information about the asterisk-commits mailing list