fix endless 5xx race when system is paused or overloaded

This commit is contained in:
Anthony Minessale 2012-08-21 16:19:25 -05:00 committed by Ken Rice
parent f0659b2605
commit dd467cc0e8
1 changed files with 26 additions and 15 deletions

View File

@ -1657,6 +1657,13 @@ void sofia_event_callback(nua_event_t event,
uint32_t sess_count = switch_core_session_count();
uint32_t sess_max = switch_core_session_limit(0);
switch(event) {
case nua_i_invite:
case nua_i_register:
case nua_i_options:
case nua_i_notify:
case nua_i_info:
if (sess_count >= sess_max || !sofia_test_pflag(profile, PFLAG_RUNNING) || !switch_core_ready_inbound()) {
nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), TAG_END());
goto end;
@ -1669,11 +1676,15 @@ void sofia_event_callback(nua_event_t event,
}
if (sofia_test_pflag(profile, PFLAG_STANDBY)) {
if (event < nua_r_set_params || event > nua_r_authenticate) {
nua_respond(nh, 503, "System Paused", TAG_END());
}
goto end;
}
break;
default:
break;
}
switch_mutex_lock(profile->flag_mutex);
profile->queued_events++;