[svn-commits] dvossel: trunk r187426 - /trunk/apps/app_dial.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Apr 9 12:39:13 CDT 2009


Author: dvossel
Date: Thu Apr  9 12:39:10 2009
New Revision: 187426

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=187426
Log:
Fixes deadlock caused by calling get_cid_name with chan locked.

get_cid_name should not be called with a channel lock.  get_cid_name calls ast_get_hint which eventually calls pbx_find_extension.  pbx_find_extension starts and stops autoservice which should not be done with a channel lock, so get_cid_name should not be called with one.


Modified:
    trunk/apps/app_dial.c

Modified: trunk/apps/app_dial.c
URL: http://svn.digium.com/svn-view/asterisk/trunk/apps/app_dial.c?view=diff&rev=187426&r1=187425&r2=187426
==============================================================================
--- trunk/apps/app_dial.c (original)
+++ trunk/apps/app_dial.c Thu Apr  9 12:39:10 2009
@@ -661,10 +661,11 @@
 	return 0;
 }
 
+/* do not call with chan lock held */
 static const char *get_cid_name(char *name, int namelen, struct ast_channel *chan)
 {
-	const char *context = S_OR(chan->macrocontext, chan->context);
-	const char *exten = S_OR(chan->macroexten, chan->exten);
+	const char *context = ast_strdupa(S_OR(chan->macrocontext, chan->context));
+	const char *exten = ast_strdupa(S_OR(chan->macroexten, chan->exten));
 
 	return ast_get_hint(NULL, 0, name, namelen, chan, context, exten) ? name : "";
 }
@@ -1915,12 +1916,13 @@
 			ast_free(tmp);
 			continue;
 		} else {
+			const char *tmpexten = ast_strdupa(S_OR(chan->macroexten, chan->exten));
 			senddialevent(chan, tc, numsubst);
 			ast_verb(3, "Called %s\n", numsubst);
+			ast_channel_unlock(chan); /* unlock chan here.  should not call get_cid_name with chan locked */
 			if (!ast_test_flag64(peerflags, OPT_ORIGINAL_CLID)) {
-				ast_set_callerid(tc, S_OR(chan->macroexten, chan->exten), get_cid_name(cidname, sizeof(cidname), chan), NULL);
-			}
-			ast_channel_unlock(chan);
+				ast_set_callerid(tc, tmpexten, get_cid_name(cidname, sizeof(cidname), chan), NULL);
+			}
 			ast_channel_unlock(tc);
 		}
 		/* Put them in the list of outgoing thingies...  We're ready now.




More information about the svn-commits mailing list