]> git.ipfire.org Git - thirdparty/asterisk.git/commit
res_pjsip_exten_state: Fix race condition between sending NOTIFY and termination 89/389/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:32:58 +0000 (09:32 -0300)
commitd649d682c4d28c1f22b8c106d25d0ad982caeebb
treea5d214c6e3612e39402af9d583c5c0bdf48ccedf
parent9322bc6ff6157f730a82d5c52259f899028c052c
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