[asterisk-commits] mnicholson: branch 1.8 r323040 - /branches/1.8/channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jun 10 14:20:45 CDT 2011


Author: mnicholson
Date: Fri Jun 10 14:20:41 2011
New Revision: 323040

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=323040
Log:
Unlock the sip channel during fax detection like chan_dahdi does to prevent a deadlock with ast_autoservice_stop.

(closes ASTERISK-17798)
tested by mnicholson

Modified:
    branches/1.8/channels/chan_sip.c

Modified: branches/1.8/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/channels/chan_sip.c?view=diff&rev=323040&r1=323039&r2=323040
==============================================================================
--- branches/1.8/channels/chan_sip.c (original)
+++ branches/1.8/channels/chan_sip.c Fri Jun 10 14:20:41 2011
@@ -7208,12 +7208,19 @@
 
 	/* If we detect a CNG tone and fax detection is enabled then send us off to the fax extension */
 	if (faxdetected && ast_test_flag(&p->flags[1], SIP_PAGE2_FAX_DETECT_CNG)) {
-		ast_channel_lock(ast);
 		if (strcmp(ast->exten, "fax")) {
 			const char *target_context = S_OR(ast->macrocontext, ast->context);
+			/* We need to unlock 'ast' here because
+			 * ast_exists_extension has the potential to start and
+			 * stop an autoservice on the channel. Such action is
+			 * prone to deadlock if the channel is locked.
+			 */
+			sip_pvt_unlock(p);
 			ast_channel_unlock(ast);
 			if (ast_exists_extension(ast, target_context, "fax", 1,
 				S_COR(ast->caller.id.number.valid, ast->caller.id.number.str, NULL))) {
+				ast_channel_lock(ast);
+				sip_pvt_lock(p);
 				ast_verbose(VERBOSE_PREFIX_2 "Redirecting '%s' to fax extension due to CNG detection\n", ast->name);
 				pbx_builtin_setvar_helper(ast, "FAXEXTEN", ast->exten);
 				if (ast_async_goto(ast, target_context, "fax", 1)) {
@@ -7221,10 +7228,10 @@
 				}
 				fr = &ast_null_frame;
 			} else {
+				ast_channel_lock(ast);
+				sip_pvt_lock(p);
 				ast_log(LOG_NOTICE, "FAX CNG detected but no fax extension\n");
 			}
-		} else {
-			ast_channel_unlock(ast);
 		}
 	}
 




More information about the asterisk-commits mailing list