res_pjsip: Fix deadlock when sending out-of-dialog requests.
authorRichard Mudgett <rmudgett@digium.com>
Tue, 6 Oct 2015 23:01:37 +0000 (18:01 -0500)
committerRichard Mudgett <rmudgett@digium.com>
Wed, 7 Oct 2015 17:40:09 +0000 (12:40 -0500)
commit34d7fa6c4a6d335732901edf42894b20aea39e9e
tree4d345674adbb18a919b15441dd6fcbfecddbb297
parent7cbb091110525e7c650cce96478a59151db0bc03
res_pjsip: Fix deadlock when sending out-of-dialog requests.

The struct send_request_wrapper has a pjsip lock associated with it that
is created non-recursive.  There is a code path for the struct
send_request_wrapper lock that will attempt to lock it recursively.  The
reporter's deadlock showed that the thread calling endpt_send_request()
deadlocked itself right after the wrapper object got created.

Out-of-dialog requests such as MESSAGE, qualify OPTIONS, and unsolicited
MWI NOTIFY messages can hit this deadlock.

* Replaced the struct send_request_wrapper pjsip lock with the mutex lock
that can come with an ao2 object since all of Asterisk's mutexes are
recursive.  Benefits include removal of code maintaining the pjsip
non-recursive lock since ao2 objects already know how to maintain their
own lock and the lock will show up in the CLI "core show locks" output.

ASTERISK-25435 #close
Reported by: Dmitriy Serov

Change-Id: I458e131dd1b9816f9e963f796c54136e9e84322d
res/res_pjsip.c