[mod_sofia] Destroy nua handles to avoid memory pool swell when system is unavailable (busy, paused or reached internal limits)

This commit is contained in:
Andrey Volk 2021-10-08 20:24:43 +03:00
parent 7ed2a99eb5
commit b7f908e890
1 changed files with 3 additions and 0 deletions

View File

@ -2462,17 +2462,20 @@ void sofia_event_callback(nua_event_t event,
if (!sofia_private) { if (!sofia_private) {
if (sess_count >= sess_max || !sofia_test_pflag(profile, PFLAG_RUNNING) || !switch_core_ready_inbound()) { 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"), NUTAG_WITH_THIS(nua), TAG_END()); nua_respond(nh, 503, "Maximum Calls In Progress", SIPTAG_RETRY_AFTER_STR("300"), NUTAG_WITH_THIS(nua), TAG_END());
nua_handle_destroy(nh);
goto end; goto end;
} }
if (switch_queue_size(mod_sofia_globals.msg_queue) > (unsigned int)critical) { if (switch_queue_size(mod_sofia_globals.msg_queue) > (unsigned int)critical) {
nua_respond(nh, 503, "System Busy", SIPTAG_RETRY_AFTER_STR("300"), NUTAG_WITH_THIS(nua), TAG_END()); nua_respond(nh, 503, "System Busy", SIPTAG_RETRY_AFTER_STR("300"), NUTAG_WITH_THIS(nua), TAG_END());
nua_handle_destroy(nh);
goto end; goto end;
} }
if (sofia_test_pflag(profile, PFLAG_STANDBY)) { if (sofia_test_pflag(profile, PFLAG_STANDBY)) {
nua_respond(nh, 503, "System Paused", NUTAG_WITH_THIS(nua), TAG_END()); nua_respond(nh, 503, "System Paused", NUTAG_WITH_THIS(nua), TAG_END());
nua_handle_destroy(nh);
goto end; goto end;
} }
} }