summaryrefslogtreecommitdiff
path: root/res/res_pjsip.c
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2014-06-12 14:15:51 +0000
committerMark Michelson <mmichelson@digium.com>2014-06-12 14:15:51 +0000
commite6cb6974fe8a4ab68ccb78a466e1274aef9d4150 (patch)
treec492e1573d8038bd3d0a565121ac6db471c79add /res/res_pjsip.c
parent58f4c18ab692ad0c43d9cb4418fc2b680bb17b80 (diff)
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 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@415795 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_pjsip.c')
-rw-r--r--res/res_pjsip.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index 339cf1dfe..2602660ee 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;