]> git.ipfire.org Git - thirdparty/asterisk.git/commit
res_pjsip_pubsub: Prevent sending NOTIFY on destroyed dialog. 12/1512/1
authorMark Michelson <mmichelson@digium.com>
Fri, 2 Oct 2015 20:32:09 +0000 (15:32 -0500)
committerRichard Mudgett <rmudgett@digium.com>
Thu, 22 Oct 2015 21:19:10 +0000 (16:19 -0500)
commitdd4d4e40e57a0013c6861f6441f30eadbd1698c6
treec84de163c0e82ea0a5828ec47079c5fc8e10960f
parentbda0a24206a56219f7738f3abbb45c6801746832
res_pjsip_pubsub: Prevent sending NOTIFY on destroyed dialog.

A certain situation can result in our attempting to send a NOTIFY on a
destroyed dialog. Say we attempt to send a NOTIFY to a subscriber, but
that subscriber has dropped off the network. We end up retransmitting
that NOTIFY until the appropriate SIP timer says to destroy the NOTIFY
transaction. When the pjsip evsub code is told that the transaction has
been terminated, it responds in kind by alerting us that the
subscription has been terminated, destroying the subscription, and then
removing its reference to the dialog, thus destroying the dialog.

The problem is that when we get told that the subscription is being
terminated, we detect that we have not sent a terminating NOTIFY
request, so we queue up such a NOTIFY to be sent out. By the time that
queued NOTIFY gets sent, the dialog has been destroyed, so attempting to
send that NOTIFY can result in a crash.

The fix being introduced here is actually a reintroduction of something
the pubsub code used to employ. We hold a reference to the dialog and
wait to decrement our reference to the dialog until our subscription
tree object is destroyed. This way, we can send messages on the dialog
even if the PJSIP evsub code wants to terminate earlier than we would
like.

In doing this, some NULL checks for subscription tree dialogs have been
removed since NULL dialogs are no longer actually possible.

Change-Id: I013f43cddd9408bb2a31b77f5db87a7972bfe1e5
res/res_pjsip_pubsub.c