]> git.ipfire.org Git - thirdparty/asterisk.git/commit
PJSIP: Prevent deadlock due to dialog/transaction lock inversion. 30/1930/3
authorMark Michelson <mmichelson@digium.com>
Thu, 7 Jan 2016 21:37:36 +0000 (15:37 -0600)
committerMark Michelson <mmichelson@digium.com>
Thu, 7 Jan 2016 22:22:37 +0000 (16:22 -0600)
commit96094feab6185de6fb26ad3a6dfe908f34d6cdcf
treec3af7cb7e9f9fa1e3423fb799b8a7d7eff5d0006
parentf42036bf6b4a188dd9a083669c9a00e37203e51c
PJSIP: Prevent deadlock due to dialog/transaction lock inversion.

A deadlock was observed where the monitor thread was stuck, therefore
resulting in no incoming SIP traffic being processed.

The problem occurred when two 200 OK responses arrived in response to a
terminating NOTIFY request sent from Asterisk. The first 200 OK was
dispatched to a threadpool worker, who locked the corresponding
transaction. The second 200 OK arrived, resulting in the monitor thread
locking the dialog. At this point, the two threads are at odds, because
the monitor thread attempts to lock the transaction, and the threadpool
thread loops attempting to try to lock the dialog.

In this case, the fix is to not have the monitor thread attempt to hold
both the dialog and transaction locks at the same time. Instead, we
release the dialog lock before attempting to lock the transaction.

There have also been some debug messages added to the process in an
attempt to make it more clear what is going on in the process.

ASTERISK-25668 #close
Reported by Mark Michelson

Change-Id: I4db0705f1403737b4360e33a8e6276805d086d4a
res/res_pjsip/pjsip_distributor.c