]> git.ipfire.org Git - thirdparty/asterisk.git/commit
res_pjsip_session: Handle race condition at shutdown with timer. 48/3048/3
authorJoshua Colp <jcolp@digium.com>
Mon, 20 Jun 2016 15:29:13 +0000 (12:29 -0300)
committerJoshua Colp <jcolp@digium.com>
Mon, 20 Jun 2016 19:21:49 +0000 (16:21 -0300)
commitba0d9e7f7af620e27ce3b09062c28a7f8fcc4557
treef4c948aef6c50a9c67beaf9c41e46fe7d01ed2dd
parent4d52b4c3e5fd726ee4006a1dcca082e778deb9a7
res_pjsip_session: Handle race condition at shutdown with timer.

When shutting down res_pjsip_session will get unloaded before res_pjsip.
The act of unloading unregisters all the PJSIP services and sets
their module IDs to -1. In some cases it is possible for a timer to
occur after this happens which calls into res_pjsip_session. The
res_pjsip_session module can then try to get the session from the
INVITE session using the module ID. Since the module ID is now -1
this fails.

This change stores a copy of the module ID and uses it for the timer
callback scenario. If the module ID is -1 the callback immediately
returns but if the module ID is valid then it continues as normal.

This works as the original ID of the module is guaranteed to still
be valid when used with the INVITE session.

ASTERISK-26127 #close

Change-Id: I88df72525c4e9ef9f19c13aedddd3ac4a335c573
res/res_pjsip_session.c