<p>Jenkins2 <strong>merged</strong> this change.</p><p><a href="https://gerrit.asterisk.org/8110">View Change</a></p><div style="white-space:pre-wrap">Approvals:
Joshua Colp: Looks good to me, but someone else must approve
Kevin Harwell: Looks good to me, approved
Jenkins2: Approved for Submit
</div><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_session: Prevent crash during shutdown.<br><br>pjproject does not have a function to reverse pjsip_inv_usage_init.<br>This means we need to ignore any calls to the functions once shutdown is<br>final.<br><br>ASTERISK-27571 #close<br><br>Change-Id: Ia550fcba563e2328f03162d79fb185f16b7c9b9d<br>---<br>M res/res_pjsip_session.c<br>1 file changed, 26 insertions(+), 12 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">diff --git a/res/res_pjsip_session.c b/res/res_pjsip_session.c<br>index 4d4ed47..5a9134b 100644<br>--- a/res/res_pjsip_session.c<br>+++ b/res/res_pjsip_session.c<br>@@ -3425,8 +3425,12 @@<br> <br> static void session_inv_on_state_changed(pjsip_inv_session *inv, pjsip_event *e)<br> {<br>- struct ast_sip_session *session = inv->mod_data[session_module.id];<br>+ struct ast_sip_session *session;<br> pjsip_event_id_e type;<br>+<br>+ if (ast_shutdown_final()) {<br>+ return;<br>+ }<br> <br> if (e) {<br> print_debug_details(inv, NULL, e);<br>@@ -3435,6 +3439,7 @@<br> type = PJSIP_EVENT_UNKNOWN;<br> }<br> <br>+ session = inv->mod_data[session_module.id];<br> if (!session) {<br> return;<br> }<br>@@ -3536,13 +3541,7 @@<br> struct ast_sip_session *session;<br> pjsip_tx_data *tdata;<br> <br>- /*<br>- * A race condition exists at shutdown where the res_pjsip_session can be<br>- * unloaded but this callback may still get called afterwards. In this case<br>- * the id may end up being -1 which is useless to us. To work around this<br>- * we store the current value and check/use it.<br>- */<br>- if (id < 0) {<br>+ if (ast_shutdown_final()) {<br> return;<br> }<br> <br>@@ -3991,9 +3990,14 @@<br> <br> static void session_inv_on_rx_offer(pjsip_inv_session *inv, const pjmedia_sdp_session *offer)<br> {<br>- struct ast_sip_session *session = inv->mod_data[session_module.id];<br>+ struct ast_sip_session *session;<br> pjmedia_sdp_session *answer;<br> <br>+ if (ast_shutdown_final()) {<br>+ return;<br>+ }<br>+<br>+ session = inv->mod_data[session_module.id];<br> if (handle_incoming_sdp(session, offer)) {<br> return;<br> }<br>@@ -4012,9 +4016,14 @@<br> <br> static void session_inv_on_media_update(pjsip_inv_session *inv, pj_status_t status)<br> {<br>- struct ast_sip_session *session = inv->mod_data[session_module.id];<br>+ struct ast_sip_session *session;<br> const pjmedia_sdp_session *local, *remote;<br> <br>+ if (ast_shutdown_final()) {<br>+ return;<br>+ }<br>+<br>+ session = inv->mod_data[session_module.id];<br> if (!session || !session->channel) {<br> /*<br> * If we don't have a session or channel then we really<br>@@ -4037,10 +4046,15 @@<br> <br> static pjsip_redirect_op session_inv_on_redirected(pjsip_inv_session *inv, const pjsip_uri *target, const pjsip_event *e)<br> {<br>- struct ast_sip_session *session = inv->mod_data[session_module.id];<br>+ struct ast_sip_session *session;<br> const pjsip_sip_uri *uri;<br> <br>- if (!session->channel) {<br>+ if (ast_shutdown_final()) {<br>+ return PJSIP_REDIRECT_STOP;<br>+ }<br>+<br>+ session = inv->mod_data[session_module.id];<br>+ if (!session || !session->channel) {<br> return PJSIP_REDIRECT_STOP;<br> }<br> <br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/8110">change 8110</a>. To unsubscribe, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/8110"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: merged </div>
<div style="display:none"> Gerrit-Change-Id: Ia550fcba563e2328f03162d79fb185f16b7c9b9d </div>
<div style="display:none"> Gerrit-Change-Number: 8110 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Corey Farrell <git@cfware.com> </div>
<div style="display:none"> Gerrit-Reviewer: Jenkins2 </div>
<div style="display:none"> Gerrit-Reviewer: Joshua Colp <jcolp@digium.com> </div>
<div style="display:none"> Gerrit-Reviewer: Kevin Harwell <kharwell@digium.com> </div>