[asterisk-commits] mmichelson: branch 1.4 r129158 - in /branches/1.4: apps/ doc/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jul 8 16:09:10 CDT 2008


Author: mmichelson
Date: Tue Jul  8 16:09:10 2008
New Revision: 129158

URL: http://svn.digium.com/view/asterisk?view=rev&rev=129158
Log:
Backport TCP-related timeouts to IMAP voicemail in 1.4
since it should solve bugs people are experiencing. Specifically,
there are times where communication with the IMAP server causes
system calls to block forever. If this should happen when querying
the mailbox so that chan_sip's do_monitor thread can send MWI to
a phone, it means that SIP calls cannot be processed any more.

The timeout options are outlined in doc/imapstorage.txt. Defaults
for the timeouts are sixty seconds.

(closes issue #12987)
Reported by: mthomasslo


Modified:
    branches/1.4/apps/app_voicemail.c
    branches/1.4/doc/imapstorage.txt

Modified: branches/1.4/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/apps/app_voicemail.c?view=diff&rev=129158&r1=129157&r2=129158
==============================================================================
--- branches/1.4/apps/app_voicemail.c (original)
+++ branches/1.4/apps/app_voicemail.c Tue Jul  8 16:09:10 2008
@@ -109,7 +109,6 @@
 #ifdef IMAP_STORAGE
 AST_MUTEX_DEFINE_STATIC(imaptemp_lock);
 static char imaptemp[1024];
-
 static char imapserver[48];
 static char imapport[8];
 static char imapflags[128];
@@ -119,6 +118,7 @@
 
 static int expungeonhangup = 1;
 static char delimiter = '\0';
+static const long DEFAULT_IMAP_TCP_TIMEOUT = 60L;
 
 struct vm_state;
 struct ast_vm_user;
@@ -7456,6 +7456,7 @@
 	const char *auth_user;
 	const char *auth_password;
 	const char *expunge_on_hangup;
+	const char *imap_timeout;
 #endif
 	const char *astcallop;
 	const char *astreview;
@@ -7603,6 +7604,36 @@
 		} else {
 			ast_copy_string(imapfolder,"INBOX", sizeof(imapfolder));
 		}
+
+		/* There is some very unorthodox casting done here. This is due
+		 * to the way c-client handles the argument passed in. It expects a 
+		 * void pointer and casts the pointer directly to a long without
+		 * first dereferencing it. */
+
+		if ((imap_timeout = ast_variable_retrieve(cfg, "general", "imapreadtimeout"))) {
+			mail_parameters(NIL, SET_READTIMEOUT, (void *) (atol(imap_timeout)));
+		} else {
+			mail_parameters(NIL, SET_READTIMEOUT, (void *) DEFAULT_IMAP_TCP_TIMEOUT);
+		}
+
+		if ((imap_timeout = ast_variable_retrieve(cfg, "general", "imapwritetimeout"))) {
+			mail_parameters(NIL, SET_WRITETIMEOUT, (void *) (atol(imap_timeout)));
+		} else {
+			mail_parameters(NIL, SET_WRITETIMEOUT, (void *) DEFAULT_IMAP_TCP_TIMEOUT);
+		}
+
+		if ((imap_timeout = ast_variable_retrieve(cfg, "general", "imapopentimeout"))) {
+			mail_parameters(NIL, SET_OPENTIMEOUT, (void *) (atol(imap_timeout)));
+		} else {
+			mail_parameters(NIL, SET_OPENTIMEOUT, (void *) DEFAULT_IMAP_TCP_TIMEOUT);
+		}
+
+		if ((imap_timeout = ast_variable_retrieve(cfg, "general", "imapclosetimeout"))) {
+			mail_parameters(NIL, SET_CLOSETIMEOUT, (void *) (atol(imap_timeout)));
+		} else {
+			mail_parameters(NIL, SET_CLOSETIMEOUT, (void *) DEFAULT_IMAP_TCP_TIMEOUT);
+		}
+
 #endif
 		/* External voicemail notify application */
 		

Modified: branches/1.4/doc/imapstorage.txt
URL: http://svn.digium.com/view/asterisk/branches/1.4/doc/imapstorage.txt?view=diff&rev=129158&r1=129157&r2=129158
==============================================================================
--- branches/1.4/doc/imapstorage.txt (original)
+++ branches/1.4/doc/imapstorage.txt Tue Jul  8 16:09:10 2008
@@ -105,6 +105,10 @@
 expungeonhangup=<yes or no>
 authuser=<username>
 authpassword=<password>
+opentimeout=<TCP open timeout in seconds>
+closetimeout=<TCP close timeout in seconds>
+readtimeout=<TCP read timeout in seconds>
+writetimeout=<TCP write timeout in seconds>
 
 The "expungeonhangup" flag is used to determine if the voicemail system should
 expunge all messages marked for deletion when the user hangs up the phone. 




More information about the asterisk-commits mailing list