Commit 09f2e64b authored by Pekka Pessi's avatar Pekka Pessi

Fixed memory leaks in nea test code.

darcs-hash:20060110135636-65a35-0acdf541ab50b7fb60d78cef8dd8d796d87bf8ee.gz
parent 838c7e1f
......@@ -2207,48 +2207,49 @@ CONDITION_FUNCTION(reject_401)
}
}
CONDITION_FUNCTION(authenticate_call)
CONDITION_FUNCTION(reject_403)
{
if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
return 0;
save_event_in_list(ctx, event, ep, call);
if (event == nua_r_invite && status == 401) {
authenticate(ep, call, nh, NUTAG_AUTH("Digest:\"test_nua\":jaska:secret"),
SIPTAG_SUBJECT_STR("Got 401"),
TAG_END());
return 0;
}
if (event == nua_r_invite && status == 407) {
authenticate(ep, call, nh, NUTAG_AUTH("Digest:\"test_nua\":erkki:secret"),
SIPTAG_SUBJECT_STR("Got 407"),
TAG_END());
return 0;
}
switch (callstate(tags)) {
case nua_callstate_received:
respond(ep, call, nh, SIP_403_FORBIDDEN, TAG_END());
return 0;
case nua_callstate_terminated:
if (call)
nua_handle_destroy(call->nh), call->nh = NULL;
ep->next_condition = NULL;
return 1;
default:
return 0;
}
}
CONDITION_FUNCTION(reject_403)
CONDITION_FUNCTION(authenticate_call)
{
if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
return 0;
save_event_in_list(ctx, event, ep, call);
switch (callstate(tags)) {
case nua_callstate_received:
respond(ep, call, nh, SIP_403_FORBIDDEN, TAG_END());
if (event == nua_r_invite && status == 401) {
authenticate(ep, call, nh, NUTAG_AUTH("Digest:\"test_nua\":jaska:secret"),
SIPTAG_SUBJECT_STR("Got 401"),
TAG_END());
return 0;
}
if (event == nua_r_invite && status == 407) {
authenticate(ep, call, nh, NUTAG_AUTH("Digest:\"test_nua\":erkki:secret"),
SIPTAG_SUBJECT_STR("Got 407"),
TAG_END());
return 0;
}
switch (callstate(tags)) {
case nua_callstate_terminated:
if (call)
nua_handle_destroy(call->nh), call->nh = NULL;
......@@ -2286,7 +2287,6 @@ int test_reject_401(struct context *ctx)
INIT -(C1)-> CALLING -(C2)-> PROCEEDING -(C6b)-> TERMINATED/INIT
INIT -(C1)-> CALLING -(C6a)-> TERMINATED
*/
TEST_1(e = a_call->events.head); TEST_E(e->data->e_event, nua_i_state);
TEST(callstate(e->data->e_tags), nua_callstate_calling); /* CALLING */
TEST_1(is_offer_sent(e->data->e_tags));
......@@ -2311,6 +2311,8 @@ int test_reject_401(struct context *ctx)
TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
TEST_1(!e->next);
free_events_in_list(ctx, a_call);
/*
Server transitions:
INIT -(S1)-> RECEIVED -(S6a)-> TERMINATED/INIT
......@@ -2351,7 +2353,6 @@ int test_reject_401(struct context *ctx)
TEST(callstate(e->data->e_tags), nua_callstate_terminated); /* TERMINATED */
TEST_1(!e->next);
free_events_in_list(ctx, a_call);
free_events_in_list(ctx, b_call);
nua_handle_destroy(a_call->nh), a_call->nh = NULL;
......@@ -5095,6 +5096,8 @@ int main(int argc, char *argv[])
}
retval |= test_deinit(ctx);
su_home_deinit(ctx->home);
su_deinit();
return retval;
......
......@@ -83,6 +83,7 @@ extern int LIST_DUMMY_VARIABLE
struct proxy {
su_home_t home[1];
su_root_t *parent;
su_clone_r clone;
tagi_t *tags;
......@@ -193,6 +194,8 @@ static void
test_proxy_deinit(su_root_t *root, struct proxy *proxy)
{
struct proxy_transaction *t;
auth_mod_destroy(proxy->auth);
if ((t = proxy->stateless)) {
nta_incoming_destroy(t->server), t->server = NULL;
......@@ -213,6 +216,8 @@ struct proxy *test_proxy_create(su_root_t *root,
if (p) {
ta_list ta;
p->parent = root;
ta_start(ta, tag, value);
p->tags = tl_llist(ta_tags(ta));
ta_end(ta);
......@@ -232,7 +237,7 @@ struct proxy *test_proxy_create(su_root_t *root,
void test_proxy_destroy(struct proxy *p)
{
if (p) {
su_clone_stop(p->clone);
su_clone_wait(p->parent, p->clone);
su_home_unref(p->home);
}
}
......@@ -401,18 +406,21 @@ int process_register(struct proxy *proxy,
sip_t const *sip)
{
auth_status_t *as;
msg_t *msg;
struct registration_entry *e;
sip_contact_t *old_binding, *new_binding;
int unregister;
msg = nta_incoming_getrequest(irq);
as = su_home_clone(proxy->home, (sizeof *as));
as->as_status = 500, as->as_phrase = sip_500_Internal_server_error;
as->as_method = sip->sip_request->rq_method_name;
as->as_source = msg_addrinfo(msg);
{
msg_t *msg;
msg = nta_incoming_getrequest(irq);
as->as_source = msg_addrinfo(msg);
msg_destroy(msg);
}
as->as_user_uri = sip->sip_from->a_url;
as->as_display = sip->sip_from->a_display;
......
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