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_prev) {
+ /* Allocated from heap */
+ if ((*sr->sr_prev = sr->sr_next))
+ sr->sr_next->sr_prev = sr->sr_prev;
+ 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());
}
- nta_incoming_destroy(sr->sr_irq), sr->sr_irq = NULL;
+ sr->sr_irq = NULL;
+ nta_incoming_destroy(irq);
}
- 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_request.msg) {
+ msg_t *msg = sr->sr_request.msg;
+ sr->sr_request.msg = NULL;
+ msg_destroy(msg);
+ }
- 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);
+ 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, ...);
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 };
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;