[asterisk-commits] coreyfarrell: branch 11 r410225 - in /branches/11: ./ channels/chan_sip.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Mar 7 16:52:42 CST 2014


Author: coreyfarrell
Date: Fri Mar  7 16:52:38 2014
New Revision: 410225

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=410225
Log:
chan_sip: Fix deadlock of monlock between unload_module and do_monitor

Release monlock before calling pthread_join.  This ensures do_monitor
cannot freeze by locking monlock during module unload.

(closes issue ASTERISK-21406)
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/3284/
........

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

Modified:
    branches/11/   (props changed)
    branches/11/channels/chan_sip.c

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

Modified: branches/11/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/channels/chan_sip.c?view=diff&rev=410225&r1=410224&r2=410225
==============================================================================
--- branches/11/channels/chan_sip.c (original)
+++ branches/11/channels/chan_sip.c Fri Mar  7 16:52:38 2014
@@ -34770,12 +34770,16 @@
 
 	ast_mutex_lock(&monlock);
 	if (monitor_thread && (monitor_thread != AST_PTHREADT_STOP) && (monitor_thread != AST_PTHREADT_NULL)) {
-		pthread_cancel(monitor_thread);
-		pthread_kill(monitor_thread, SIGURG);
-		pthread_join(monitor_thread, NULL);
-	}
-	monitor_thread = AST_PTHREADT_STOP;
-	ast_mutex_unlock(&monlock);
+		pthread_t th = monitor_thread;
+		monitor_thread = AST_PTHREADT_STOP;
+		pthread_cancel(th);
+		pthread_kill(th, SIGURG);
+		ast_mutex_unlock(&monlock);
+		pthread_join(th, NULL);
+	} else {
+		monitor_thread = AST_PTHREADT_STOP;
+		ast_mutex_unlock(&monlock);
+	}
 
 	/* Destroy all the dialogs and free their memory */
 	i = ao2_iterator_init(dialogs, 0);




More information about the asterisk-commits mailing list