summaryrefslogtreecommitdiff
path: root/res/res_pjsip_diversion.c
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2015-09-16 17:36:32 -0500
committerMark Michelson <mmichelson@digium.com>2015-09-17 11:12:22 -0500
commite47396721f9c73b16ac7c7632dcd530f4e5b06c7 (patch)
tree3a8a424725fd4a3872371d9ab8ff1b3e755a55b0 /res/res_pjsip_diversion.c
parent0a74c803004c1c7d4d53aecc9e818b63d5a1e9d6 (diff)
res_pjsip_pubsub: Eliminate race during initial NOTIFY.
There is a slim chance of a race condition occurring where two threads can both attempt to manipulate the same area. Thread A can be handling an incoming initial SUBSCRIBE request. Thread A lets the specific subscription handler know that the subscription has been established. At this point, Thread B may detect a state change on the subscribed resource and queue up a notification task on Thread C, the subscription serializer thread. Now Thread A attempts to generate the initial NOTIFY request to send to the subscriber at the same time that Thread C attempts to generate a state change NOTIFY request to send to the subscriber. The result is that Threads A and C can step on the same memory area, resulting in a crash. The crash has been observed as happening when attempting to allocate more space to hold the body for the NOTIFY. The solution presented here is to queue the subscription establishment and initial NOTIFY generation onto the subscription serializer thread (Thread C in the above scenario). This way, there is no way that a state change notification can occur before the initial NOTIFY is sent, and if there is a quick succession of NOTIFYs, we can guarantee that the two NOTIFY requests will be sent in succession. Change-Id: I5a89a77b5f2717928c54d6efb9955e5f6f5cf815
Diffstat (limited to 'res/res_pjsip_diversion.c')
0 files changed, 0 insertions, 0 deletions