[mod_sofia] Fix crash from double profile unlock on outgoing channel from a gateway on a paused profile

This commit is contained in:
Andrey Volk 2019-12-21 01:15:57 +04:00
parent f7ec94c9c4
commit 6f0ad146d2
1 changed files with 4 additions and 3 deletions

View File

@ -4775,6 +4775,8 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
goto error; goto error;
} }
profile = gateway_ptr->profile;
if (gateway_ptr->status != SOFIA_GATEWAY_UP) { if (gateway_ptr->status != SOFIA_GATEWAY_UP) {
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Gateway \'%s\' is down!\n", gw); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "Gateway \'%s\' is down!\n", gw);
cause = SWITCH_CAUSE_GATEWAY_DOWN; cause = SWITCH_CAUSE_GATEWAY_DOWN;
@ -4815,8 +4817,6 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
goto error; goto error;
} }
profile = gateway_ptr->profile;
if (profile && sofia_test_pflag(profile, PFLAG_STANDBY)) { if (profile && sofia_test_pflag(profile, PFLAG_STANDBY)) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "System Paused\n"); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "System Paused\n");
cause = SWITCH_CAUSE_SYSTEM_SHUTDOWN; cause = SWITCH_CAUSE_SYSTEM_SHUTDOWN;
@ -5180,7 +5180,8 @@ static switch_call_cause_t sofia_outgoing_channel(switch_core_session_t *session
goto done; goto done;
error: error:
if (gateway_ptr) { /* gateway pointer lock is really a readlock of the profile so we let the profile release below free that lock if we have a profile */
if (gateway_ptr && !profile) {
sofia_reg_release_gateway(gateway_ptr); sofia_reg_release_gateway(gateway_ptr);
} }