From 5867d0424d299ec4bd5225e7f3ebc9dce143a31a Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Wed, 18 Jul 2012 21:47:31 -0500 Subject: [PATCH] FS-4079 please try this --- libs/sofia-sip/.update | 2 +- .../libsofia-sip-ua/nua/nua_server.c | 40 ++++++++++++------- src/mod/endpoints/mod_sofia/mod_sofia.c | 24 ----------- 3 files changed, 27 insertions(+), 39 deletions(-) diff --git a/libs/sofia-sip/.update b/libs/sofia-sip/.update index 7a0987854e..9521702c60 100644 --- a/libs/sofia-sip/.update +++ b/libs/sofia-sip/.update @@ -1 +1 @@ -Wed Jul 11 16:48:51 CDT 2012 +Wed Jul 18 21:45:15 CDT 2012 diff --git a/libs/sofia-sip/libsofia-sip-ua/nua/nua_server.c b/libs/sofia-sip/libsofia-sip-ua/nua/nua_server.c index f27c83fb92..deae102ca2 100644 --- a/libs/sofia-sip/libsofia-sip-ua/nua/nua_server.c +++ b/libs/sofia-sip/libsofia-sip-ua/nua/nua_server.c @@ -295,31 +295,43 @@ int nua_base_server_preprocess(nua_server_request_t *sr) void nua_server_request_destroy(nua_server_request_t *sr) { + nua_server_request_t *sr0 = NULL; + if (sr == NULL) return; if (SR_HAS_SAVED_SIGNAL(sr)) nua_destroy_signal(sr->sr_signal); - if (sr->sr_irq) { - if (sr->sr_method == sip_method_bye && sr->sr_status < 200) { - nta_incoming_treply(sr->sr_irq, SIP_200_OK, TAG_END()); - } - nta_incoming_destroy(sr->sr_irq), sr->sr_irq = NULL; - } - - if (sr->sr_request.msg) - msg_destroy(sr->sr_request.msg), sr->sr_request.msg = NULL; - - if (sr->sr_response.msg) - msg_destroy(sr->sr_response.msg), sr->sr_response.msg = NULL; - if (sr->sr_prev) { /* Allocated from heap */ if ((*sr->sr_prev = sr->sr_next)) sr->sr_next->sr_prev = sr->sr_prev; - su_free(sr->sr_owner->nh_home, sr); + sr0 = sr; } + + if (sr->sr_irq) { + nta_incoming_t *irq = sr->sr_irq; + if (sr->sr_method == sip_method_bye && sr->sr_status < 200) { + nta_incoming_treply(sr->sr_irq, SIP_200_OK, TAG_END()); + } + sr->sr_irq = NULL; + nta_incoming_destroy(irq); + } + + if (sr->sr_request.msg) { + msg_t *msg = sr->sr_request.msg; + sr->sr_request.msg = NULL; + msg_destroy(msg); + } + + if (sr->sr_response.msg) { + msg_t *msg = sr->sr_response.msg; + sr->sr_response.msg = NULL; + msg_destroy(msg); + } + + if (sr0) su_free(sr->sr_owner->nh_home, sr0); } /**@fn void nua_respond(nua_handle_t *nh, int status, char const *phrase, tag_type_t tag, tag_value_t value, ...); diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.c b/src/mod/endpoints/mod_sofia/mod_sofia.c index e158e48318..0bcb383421 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.c +++ b/src/mod/endpoints/mod_sofia/mod_sofia.c @@ -2321,19 +2321,6 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi if (!zstr(msg->string_arg)) { - int status = 0; - - if (tech_pvt->nh && tech_pvt->nh->nh_ds && tech_pvt->nh->nh_ds->ds_sr && nua_server_request_is_pending(tech_pvt->nh->nh_ds->ds_sr)) { - status = tech_pvt->nh->nh_ds->ds_sr->sr_status; - } - - if (status == 0 || status > 199 || tech_pvt->nh->nh_destroyed) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s Cannot call respond on handle at status %d\n", - switch_channel_get_name(channel), status); - goto end_lock; - } - - if (!switch_channel_test_flag(channel, CF_ANSWERED) && !sofia_test_flag(tech_pvt, TFLAG_BYE)) { char *dest = (char *) msg->string_arg; char *argv[128] = { 0 }; @@ -2417,17 +2404,6 @@ static switch_status_t sofia_receive_message(switch_core_session_t *session, swi case SWITCH_MESSAGE_INDICATE_RESPOND: { - int status = 0; - - if (tech_pvt->nh && tech_pvt->nh->nh_ds && tech_pvt->nh->nh_ds->ds_sr && nua_server_request_is_pending(tech_pvt->nh->nh_ds->ds_sr)) { - status = tech_pvt->nh->nh_ds->ds_sr->sr_status; - } - - if (status == 0 || status > 199 || tech_pvt->nh->nh_destroyed) { - switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_WARNING, "%s Cannot call respond on handle at status %d\n", - switch_channel_get_name(channel), status); - goto end_lock; - } if (msg->numeric_arg || msg->string_arg) { int code = msg->numeric_arg;