[svn-commits] mmichelson: branch 12 r415794 - /branches/12/res/res_pjsip.c

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


Author: mmichelson
Date: Thu Jun 12 09:03:52 2014
New Revision: 415794

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=415794
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


Modified:
    branches/12/res/res_pjsip.c

Modified: branches/12/res/res_pjsip.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/res_pjsip.c?view=diff&rev=415794&r1=415793&r2=415794
==============================================================================
--- branches/12/res/res_pjsip.c (original)
+++ branches/12/res/res_pjsip.c Thu Jun 12 09:03:52 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