Commit fe1cddbf authored by jehan's avatar jehan
Browse files

no longuer return registration failure in case of first retry

parent 6e3c6551
......@@ -40,7 +40,10 @@ void sal_op_release(SalOp *op){
void sal_op_release_impl(SalOp *op){
ms_message("Destroying op [%p] of type [%s]",op,sal_op_type_to_string(op->type));
if (op->pending_auth_transaction) belle_sip_object_unref(op->pending_auth_transaction);
if (op->auth_info) sal_auth_info_delete(op->auth_info);
if (op->auth_info) {
sal_remove_pending_auth(op->base.root,op);
sal_auth_info_delete(op->auth_info);
}
if (op->sdp_answer) belle_sip_object_unref(op->sdp_answer);
if (op->refresher) {
belle_sip_object_unref(op->refresher);
......@@ -259,6 +262,10 @@ void sal_compute_sal_errors_from_code(int code ,SalError* sal_err,SalReason* sal
case 400:
*sal_err=SalErrorUnknown;
break;
case 403:
*sal_err=SalErrorFailure;
*sal_reason=SalReasonForbidden;
break;
case 404:
*sal_err=SalErrorFailure;
*sal_reason=SalReasonNotFound;
......@@ -280,6 +287,10 @@ void sal_compute_sal_errors_from_code(int code ,SalError* sal_err,SalReason* sal
break;
case 487:
break;
case 503:
*sal_err=SalErrorFailure;
*sal_reason=SalReasonServiceUnavailable;
break;
case 600:
*sal_err=SalErrorFailure;
*sal_reason=SalReasonDoNotDisturb;
......
......@@ -68,10 +68,6 @@ static void register_refresher_listener ( const belle_sip_refresher_t* refresher
if (op->auth_info) {
/*add pending auth*/
sal_add_pending_auth(op->base.root,op);
if (status_code == 403 || status_code == 401 || status_code == 407) { /*in case of 401 or 407, auth requested already invoked previously but maybe*/
/*auth previouly pending, probably wrong pasword, give a chance to authenticate again*/
op->base.root->callbacks.auth_failure(op,op->auth_info); /*fixme*/
}
}
}
}
......
......@@ -779,7 +779,14 @@ static void register_failure(SalOp *op, SalError error, SalReason reason, const
} else if (error == SalErrorNoResponse) {
linphone_proxy_config_set_error(cfg, LinphoneReasonNoResponse);
}
linphone_proxy_config_set_state(cfg,LinphoneRegistrationFailed,details);
if (error== SalErrorFailure
&& reason == SalReasonServiceUnavailable
&& linphone_proxy_config_get_state(cfg) == LinphoneRegistrationOk) {
linphone_proxy_config_set_state(cfg,LinphoneRegistrationProgress,_("Service unavailable, retrying"));
} else {
linphone_proxy_config_set_state(cfg,LinphoneRegistrationFailed,details);
}
if (error== SalErrorFailure && reason == SalReasonForbidden) {
const char *realm=NULL,*username=NULL;
if (sal_op_get_auth_requested(op,&realm,&username)==0){
......
......@@ -1310,9 +1310,19 @@ void * linphone_proxy_config_get_user_data(LinphoneProxyConfig *cr) {
void linphone_proxy_config_set_state(LinphoneProxyConfig *cfg, LinphoneRegistrationState state, const char *message){
LinphoneCore *lc=cfg->lc;
cfg->state=state;
if (lc && lc->vtable.registration_state_changed){
lc->vtable.registration_state_changed(lc,cfg,state,message);
ms_message("Proxy config [%p] for identity [%s] moving from state [%s] to [%s]" , cfg
, linphone_proxy_config_get_identity(cfg)
, linphone_registration_state_to_string(cfg->state)
, linphone_registration_state_to_string(state));
if (cfg->state!=state || state==LinphoneRegistrationOk) { /*allow multiple notification of LinphoneRegistrationOk for refreshing*/
cfg->state=state;
if (lc && lc->vtable.registration_state_changed){
lc->vtable.registration_state_changed(lc,cfg,state,message);
}
} else {
/*state already reported*/
}
}
......
......@@ -525,6 +525,7 @@ const char* sal_reason_to_string(const SalReason reason) {
case SalReasonMedia: return "SalReasonMedia";
case SalReasonForbidden: return "SalReasonForbidden";
case SalReasonUnknown: return "SalReasonUnknown";
case SalReasonServiceUnavailable: return "SalReasonServiceUnavailable";
default: return "Unkown reason";
}
}
......
......@@ -270,7 +270,8 @@ typedef enum SalReason{
SalReasonDoNotDisturb,
SalReasonMedia,
SalReasonForbidden,
SalReasonUnknown
SalReasonUnknown,
SalReasonServiceUnavailable
}SalReason;
const char* sal_reason_to_string(const SalReason reason);
......
......@@ -44,7 +44,7 @@ const char* test_route="sip2.linphone.org";
#if WINAPI_FAMILY_PHONE_APP
const char *liblinphone_tester_file_prefix="Assets";
#else
const char *liblinphone_tester_file_prefix="./tester";
const char *liblinphone_tester_file_prefix=".";
#endif
const char *userhostsfile = "tester_hosts";
......
......@@ -126,11 +126,12 @@ static void register_with_refresh_with_send_error() {
register_with_refresh_base(lc,TRUE,auth_domain,route);
/*simultate a network error*/
sal_set_send_error(lc->sal, -1);
while (counters->number_of_LinphoneRegistrationFailed<1 && retry++ <20) {
while (counters->number_of_LinphoneRegistrationProgress<2 && retry++ <20) {
linphone_core_iterate(lc);
ms_usleep(100000);
}
CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,1);
CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,0);
CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationProgress,2);
linphone_core_destroy(lc);
CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationCleared,0);
......@@ -348,7 +349,7 @@ static void transport_change(){
linphone_core_set_sip_transports(lc,&sip_tr);
CU_ASSERT_TRUE(wait_for(lc,lc,&counters->number_of_LinphoneRegistrationOk,register_ok+number_of_udp_proxy));
CU_ASSERT_TRUE(wait_for(lc,lc,&counters->number_of_LinphoneRegistrationFailed,register_ok+(total_number_of_proxies-number_of_udp_proxy)));
CU_ASSERT_TRUE(wait_for(lc,lc,&counters->number_of_LinphoneRegistrationFailed,total_number_of_proxies-number_of_udp_proxy));
linphone_core_destroy(lc);
}
......@@ -368,7 +369,9 @@ static void io_recv_error(){
number_of_udp_proxy=get_number_of_udp_proxy(lc);
sal_set_recv_error(lc->sal, 0);
CU_ASSERT_TRUE(wait_for(lc,lc,&counters->number_of_LinphoneRegistrationFailed,register_ok-number_of_udp_proxy /*because 1 udp*/));
CU_ASSERT_TRUE(wait_for(lc,lc,&counters->number_of_LinphoneRegistrationProgress,2*(register_ok-number_of_udp_proxy) /*because 1 udp*/));
CU_ASSERT_EQUAL(counters->number_of_LinphoneRegistrationFailed,0)
sal_set_recv_error(lc->sal, 1); /*reset*/
linphone_core_destroy(lc);
......
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