]> git.ipfire.org Git - thirdparty/asterisk.git/commit
res_pjsip_exten_state: Fix race condition between sending NOTIFY and termination 91/391/1
authorJoshua Colp <jcolp@digium.com>
Wed, 6 May 2015 18:24:29 +0000 (15:24 -0300)
committerJoshua Colp <jcolp@digium.com>
Thu, 7 May 2015 12:42:17 +0000 (07:42 -0500)
commit6433b697ae95f5d4599ae70a4999cf6b864200cf
tree68d4ec6f46a8f464dfb2b7e605fed35b8c1b2d8b
parent5602fc3e2e9fabc363b5f6ce9a1e66ed39eed76e
res_pjsip_exten_state: Fix race condition between sending NOTIFY and termination

The res_pjsip_exten_state module currently has a race condition between
processing the extension state callback from the PBX core and processing
the subscription shutdown callback from res_pjsip_pubsub. There is currently
no synchronization between the two. This can present a problem as while
the SIP subscription will remain valid the tree it points to may not.
This is in particular a problem as a task to send a NOTIFY may get queued
which will try to use the tree that may no longer be valid.

This change does the following to fix this problem:

1. All access to the subscription tree is done within the task that
sends the NOTIFY to ensure that no other thread is modifying or
destroying the tree. This task executes on the serializer for the
subscriptions.

2. A reference to the subscription serializer is kept to ensure it
remains valid for the lifetime of the extension state subscription.

3. The NOTIFY task has been changed so it will no longer attempt
to send a NOTIFY if the subscription has already been terminated.

ASTERISK-25057 #close
Reported by: Matt Jordan

Change-Id: I0b3cd2fac5be8d9b3dc5e693aaa79846eeaf5643
include/asterisk/res_pjsip_pubsub.h
res/res_pjsip_exten_state.c
res/res_pjsip_pubsub.c
res/res_pjsip_pubsub.exports.in