[svn-commits] mmichelson: trunk r415795 - in /trunk: ./ res/res_pjsip.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jun 12 09:15:56 CDT 2014


Author: mmichelson
Date: Thu Jun 12 09:15:51 2014
New Revision: 415795

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=415795
Log:
Fix potential deadlock situation in res_pjsip.

SIP transaction timeouts are handled in the PJSIP monitor thread. When
this happens on a subscription, and the subscription is destroyed, the
subscription destruction is dispatched synchronously to the threadpool.
The issue is that the PJSIP dialog is locked by the monitor thread,
and then the dispatched task attempts to lock the dialog. This leads
to a deadlock that causes SIP traffic to no longer be accepted on the
Asterisk server.

The fix here is to treat the monitor thread as if it were a threadpool
thread when it attempts to dispatch synchronous tasks. This way, the
dispatched task turns into a simple function call within the same thread,
and the locking issue is averted.

AST-2014-008

ASTERISK-23802 #close
........

Merged revisions 415794 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    trunk/   (props changed)
    trunk/res/res_pjsip.c

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

Modified: trunk/res/res_pjsip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_pjsip.c?view=diff&rev=415795&r1=415794&r2=415795
==============================================================================
--- trunk/res/res_pjsip.c (original)
+++ trunk/res/res_pjsip.c Thu Jun 12 09:15:51 2014
@@ -2194,6 +2194,11 @@
 {
 	uint32_t *servant_id;
 
+	if (monitor_thread &&
+			pthread_self() == *(pthread_t *)pj_thread_get_os_handle(monitor_thread)) {
+		return 1;
+	}
+
 	servant_id = ast_threadstorage_get(&servant_id_storage, sizeof(*servant_id));
 	if (!servant_id) {
 		return 0;




More information about the svn-commits mailing list