]> git.ipfire.org Git - thirdparty/asterisk.git/commit
res_pjsip_session: Handle race condition at shutdown with timer. 49/3049/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:22:29 +0000 (14:22 -0500)
commite94aae00a7e871d789d4196a7c5b38738c5be4e8
treec649be7bf1d7b4e89965162eabf6b648004c5fcd
parentef1e0a65d40040e7695a598a1fab791f8fbe0266
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