[asterisk-commits] file: trunk r373456 - in /trunk: ./ channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Sep 24 14:23:36 CDT 2012


Author: file
Date: Mon Sep 24 14:23:32 2012
New Revision: 373456

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=373456
Log:
Fix a deadlock caused by a race condition between removing a hint and reloading the dialplan and subscribing to the removed hint.

If conditions were right it was possible for both the PBX core and chan_sip to deadlock by both having a lock that the other
wants. In the case of the PBX core it had the contexts lock and wanted a SIP dialog lock, while in the case of chan_sip it
had the SIP dialog lock and wanted the contexts lock.

This fix unlocks the SIP dialog before getting the extension state so that the other thread will not block on trying to lock
it. Once the extension state is retrieved the SIP dialog is locked again and life carries on.

As the SIP dialog is reference counted it is not possible for it to go away after unlocking.

(closes issue ASTERISK-20437)
Reported by: jhutchins
........

Merged revisions 373438 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 373440 from http://svn.asterisk.org/svn/asterisk/branches/10
........

Merged revisions 373454 from http://svn.asterisk.org/svn/asterisk/branches/11

Modified:
    trunk/   (props changed)
    trunk/channels/chan_sip.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=373456&r1=373455&r2=373456
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Mon Sep 24 14:23:32 2012
@@ -14183,6 +14183,11 @@
 	struct sip_request req;
 	const struct cfsubscription_types *subscriptiontype;
 
+	/* If the subscription has not yet been accepted do not send a NOTIFY */
+	if (!ast_test_flag(&p->flags[1], SIP_PAGE2_DIALOG_ESTABLISHED)) {
+		return 0;
+	}
+
 	memset(from, 0, sizeof(from));
 	memset(to, 0, sizeof(to));
 
@@ -27224,7 +27229,12 @@
 					dialog_unref(p, "copying dialog ptr into extension state struct failed");
 				}
 			}
-			if ((data.state = ast_extension_state_extended(NULL, p->context, p->exten, &device_state_info)) < 0) {
+
+			sip_pvt_unlock(p);
+			data.state = ast_extension_state_extended(NULL, p->context, p->exten, &device_state_info);
+			sip_pvt_lock(p);
+
+			if (data.state < 0) {
 				ao2_cleanup(device_state_info);
 				if (p->expiry > 0) {
 					ast_log(LOG_NOTICE, "Got SUBSCRIBE for extension %s@%s from %s, but there is no hint for that extension.\n", p->exten, p->context, ast_sockaddr_stringify(&p->sa));




More information about the asterisk-commits mailing list