Commit e3193e58 authored by Pekka Pessi's avatar Pekka Pessi

nua: fixed sr_msg server-side request message handling

darcs-hash:20061027181337-65a35-408e12dfd0a40a4e6d0de24d00fdd7a63cf9a9c8.gz
parent 7d5efc03
......@@ -985,7 +985,7 @@ void nua_event(nua_t *root_magic, su_msg_r sumsg, event_t *e)
SU_DEBUG_9(("nua(%p): freed by application\n", nh));
}
if (e->e_msg)
msg_destroy(e->e_msg);
msg_destroy(e->e_msg), e->e_msg = NULL;
return;
}
......@@ -1018,7 +1018,7 @@ void nua_event(nua_t *root_magic, su_msg_r sumsg, event_t *e)
return;
if (e->e_msg)
msg_destroy(e->e_msg);
msg_destroy(e->e_msg), e->e_msg = NULL;
su_msg_destroy(nua->nua_current);
}
......@@ -1063,7 +1063,7 @@ void nua_destroy_event(nua_saved_event_t saved[1])
nua_handle_t *nh = e->e_nh;
if (e->e_msg)
msg_destroy(e->e_msg);
msg_destroy(e->e_msg), e->e_msg = NULL;
if (nh && !NH_IS_DEFAULT(nh) && nua_handle_unref(nh)) {
SU_DEBUG_9(("nua(%p): freed by application\n", nh));
......
......@@ -365,7 +365,7 @@ void nua_dialog_usage_remove_at(nua_owner_t *own,
own, nua_dialog_usage_name(du),
o ? " with event " : "", o ? o->o_type :""));
du->du_class->usage_remove(own, ds, du);
msg_destroy(du->du_msg);
msg_destroy(du->du_msg), du->du_msg = NULL;
su_home_unref(own);
su_free(own, du);
}
......
......@@ -1639,7 +1639,8 @@ int process_invite(nua_t *nua,
SIPTAG_USER_AGENT_STR(NUA_PGET(nua, nh, user_agent)),
TAG_END());
nua_stack_event(nh->nh_nua, nh, sr->sr_msg,
nua_stack_event(nh->nh_nua, nh,
sr->sr_msg = nta_incoming_getrequest(sr->sr_irq),
nua_i_invite, SIP_100_TRYING,
NH_ACTIVE_MEDIA_TAGS(1, nh->nh_soa),
TAG_END());
......@@ -1822,11 +1823,13 @@ int respond_to_invite(nua_server_request_t *sr, tagi_t const *tags)
}
if (sr->sr_auto) {
nua_stack_event(nh->nh_nua, nh, sr->sr_msg,
nua_i_invite, status, phrase,
NH_ACTIVE_MEDIA_TAGS(1, nh->nh_soa),
TAG_END());
sr->sr_msg = NULL;
msg_t *request = nta_incoming_getrequest(sr->sr_irq);
if (status < 200)
sr->sr_msg = request;
nua_stack_event(nh->nh_nua, nh, request,
nua_i_invite, status, phrase,
NH_ACTIVE_MEDIA_TAGS(1, nh->nh_soa),
TAG_END());
}
else if (status != sr->sr_status)
nua_stack_event(nua, nh, NULL, nua_i_error, status, phrase, TAG_END());
......
......@@ -1769,11 +1769,6 @@ nua_server_request_t *nua_server_request(nua_t *nua,
if (sip->sip_request->rq_method == sip_method_invite)
final = 300;
msg = nta_incoming_getrequest(irq); assert(msg);
if (!msg)
SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
/* Create handle if request does not fail */
if (sr->sr_status >= 300)
;
......@@ -1826,6 +1821,8 @@ void nua_server_request_destroy(nua_server_request_t *sr)
if (sr->sr_irq)
nta_incoming_destroy(sr->sr_irq), sr->sr_irq = NULL;
sr->sr_msg = NULL;
if (sr->sr_prev) {
if ((*sr->sr_prev = sr->sr_next))
sr->sr_next->sr_prev = sr->sr_prev;
......@@ -1852,36 +1849,37 @@ int nua_stack_server_event(nua_t *nua,
status = sr->sr_status;
if (200 <= status)
if (status >= 200)
sr->sr_respond = NULL;
if (status < 300 || !sr->sr_initial) {
ta_list ta;
msg_t *request;
ta_start(ta, tag, value);
assert(sr->sr_owner);
nua_stack_event(nua, sr->sr_owner, sr->sr_msg, event,
request = nta_incoming_getrequest(sr->sr_irq);
nua_stack_event(nua, sr->sr_owner, request, event,
sr->sr_status, sr->sr_phrase,
ta_tags(ta));
ta_end(ta);
if (final)
nua_server_request_destroy(sr);
else if (sr->sr_status < 200)
sr->sr_msg = request;
}
else {
nh = sr->sr_owner;
if (sr->sr_msg)
msg_destroy(sr->sr_msg), sr->sr_msg = NULL;
nua_server_request_destroy(sr);
if (nh && nh != nua->nua_dhandle)
nh_destroy(nua, nh);
}
return final;
return 0;
}
/** Respond to a request. */
......@@ -1943,11 +1941,8 @@ int nua_default_respond(nua_server_request_t *sr,
TAG_NEXT(tags));
if (m) {
nta_incoming_mreply(sr->sr_irq, m);
}
else {
SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
nta_incoming_treply(sr->sr_irq, sr->sr_status, sr->sr_phrase, TAG_END());
if (nta_incoming_mreply(sr->sr_irq, m) < 0)
SR_STATUS1(sr, SIP_500_INTERNAL_SERVER_ERROR);
}
return sr->sr_status >= 200 ? sr->sr_status : 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment