From: Mark Michelson Date: Thu, 12 Jun 2014 14:03:52 +0000 (+0000) Subject: Fix potential deadlock situation in res_pjsip. X-Git-Tag: 12.4.0-rc1~60 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ceef709d48aab43c6ea35de65cfc5fc2d1fd357d;p=thirdparty%2Fasterisk.git 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 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@415794 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/res/res_pjsip.c b/res/res_pjsip.c index 0fb802ca00..08d86537d4 100644 --- a/res/res_pjsip.c +++ b/res/res_pjsip.c @@ -2194,6 +2194,11 @@ int ast_sip_thread_is_servant(void) { 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;