]> git.ipfire.org Git - thirdparty/asterisk.git/commit
pjsip_distributor.c: Fix deadlock with TCP type transports.
authorRichard Mudgett <rmudgett@digium.com>
Thu, 29 Jun 2017 23:27:20 +0000 (18:27 -0500)
committerRichard Mudgett <rmudgett@digium.com>
Fri, 30 Jun 2017 17:17:06 +0000 (12:17 -0500)
commitaa10dd31d044c65aaecdd76629f53fd4cbdf013b
tree4fd1bb361d62cae547f4c9bcde71d4a190acd285
parent74cf3e1e4814dda1a459493b8a8f7bb872fb3b2f
pjsip_distributor.c: Fix deadlock with TCP type transports.

When a SIP message comes in on a transport, pjproject obtains the lock on
the transport and pulls the data out of the socket.  Unlike UDP, the TCP
transport does not allow concurrent access.  Without concurrency the
transport lock is not released when the transport's message complete
callback is called.  The processing continues and eventually Asterisk
starts processing the SIP message.  The first thing Asterisk tries to do
is determine the associated dialog of the message to determine the
associated serializer.  To get the associated serializer safely requires
us to get the dialog lock.

To send a request or response message for a dialog, pjproject obtains the
dialog lock and then obtains the transport lock.  Deadlock can result
because of the opposite order the locks are obtained.

* Fix the deadlock by obtaining the serializer associated with the dialog
another way that doesn't involve obtaining the dialog lock.  In this case,
we use an ao2 container to hold the associated endpoint and serializer.
The new locks are held a brief time and won't overlap other existing lock
times.

ASTERISK-27090 #close

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