Commit bd42e7e4 authored by Pekka Pessi's avatar Pekka Pessi

nua: now respecting the retry count limit.

test_call_reject.c: added test for infinite redirection loop.

darcs-hash:20070411165150-65a35-480a03250af7be6e893bcf2db58e7eb25bafbfed.gz
parent 22abd065
......@@ -2040,7 +2040,6 @@ int nua_client_restart_request(nua_client_request_t *cr,
if (sip_add_tagis(cr->cr_msg, NULL, &tags) < 0)
/* XXX */;
cr->cr_retry_count = 0;
cr->cr_terminating = terminating;
return nua_client_request_try(cr);
......@@ -2135,6 +2134,8 @@ int nua_client_request_sendmsg(nua_client_request_t *cr, msg_t *msg, sip_t *sip)
assert(cr->cr_orq == NULL);
cr->cr_retry_count++;
if (ds->ds_leg)
leg = ds->ds_leg;
else
......@@ -2402,7 +2403,7 @@ int nua_client_check_restart(nua_client_request_t *cr,
assert(cr && status >= 200 && phrase && sip);
if (cr->cr_retry_count >= NH_PGET(nh, retry_count))
if (cr->cr_retry_count > NH_PGET(nh, retry_count))
return 0;
if (cr->cr_methods->crm_check_restart)
......@@ -2492,7 +2493,6 @@ int nua_base_client_check_restart(nua_client_request_t *cr,
orq = cr->cr_orq, cr->cr_orq = NULL;
cr->cr_wait_for_cred = 1;
cr->cr_retry_count++;
nua_client_report(cr, status, phrase, NULL, orq, NULL);
nta_outgoing_destroy(orq);
......@@ -2517,7 +2517,7 @@ int nua_client_restart(nua_client_request_t *cr,
msg_t *msg;
sip_t *sip;
if (++cr->cr_retry_count > NH_PGET(nh, retry_count))
if (cr->cr_retry_count > NH_PGET(nh, retry_count))
return 0;
orq = cr->cr_orq, cr->cr_orq = NULL; assert(orq);
......
......@@ -262,6 +262,7 @@ int test_reject_b(struct context *ctx)
/* ------------------------------------------------------------------------ */
int reject_302(CONDITION_PARAMS), reject_305(CONDITION_PARAMS);
int redirect_always(CONDITION_PARAMS);
int reject_604(CONDITION_PARAMS);
/*
......@@ -336,6 +337,26 @@ int reject_305(CONDITION_PARAMS)
}
}
int redirect_always(CONDITION_PARAMS)
{
if (!(check_handle(ep, call, nh, SIP_500_INTERNAL_SERVER_ERROR)))
return 0;
if (event == nua_i_invite) {
char user[30];
sip_contact_t m[1];
*m = *ep->contact;
snprintf(user, sizeof user, "user-%u", ep->flags.n++);
m->m_url->url_user = user;
RESPOND(ep, call, nh, SIP_302_MOVED_TEMPORARILY,
SIPTAG_CONTACT(m), TAG_END());
nua_handle_destroy(nh);
call->nh = NULL;
return 1;
}
return 0;
}
int reject_604(CONDITION_PARAMS)
{
......@@ -473,6 +494,25 @@ int test_reject_302(struct context *ctx)
free_events_in_list(ctx, b->events);
nua_handle_destroy(b_call->nh), b_call->nh = NULL;
if (print_headings)
printf("TEST NUA-4.3: PASSED\n");
if (print_headings)
printf("TEST NUA-4.3.1: redirect until retry count is exceeded\n");
TEST_1(a_call->nh = nua_handle(a->nua, a_call, SIPTAG_TO(b->to), TAG_END()));
INVITE(a, a_call, a_call->nh,
TAG_IF(!ctx->proxy_tests, NUTAG_URL(b->contact->m_url)),
SIPTAG_SUBJECT_STR("redirect always"),
SOATAG_USER_SDP_STR(a_call->sdp),
TAG_END());
run_ab_until(ctx, -1, until_terminated, -1, redirect_always);
free_events_in_list(ctx, a->events);
nua_handle_destroy(a_call->nh), a_call->nh = NULL;
free_events_in_list(ctx, b->events);
nua_handle_destroy(b_call->nh), b_call->nh = NULL;
if (print_headings)
printf("TEST NUA-4.3: PASSED\n");
......
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