From 162f121348d175e217d18141bbb2839f73b8dbb3 Mon Sep 17 00:00:00 2001 From: Jehan Monnier Date: Fri, 11 Apr 2014 17:16:29 +0200 Subject: [PATCH] better mgt of refresher in case of registration error --- coreapi/proxy.c | 6 ++++++ tester/register_tester.c | 28 ++++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/coreapi/proxy.c b/coreapi/proxy.c index 74c8a7730..a526f337b 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -270,6 +270,9 @@ void linphone_proxy_config_edit(LinphoneProxyConfig *obj){ if (obj->state == LinphoneRegistrationOk || obj->state == LinphoneRegistrationProgress) { sal_unregister(obj->op); + } else { + /*stop refresher*/ + if (obj->op) sal_op_stop_refreshing(obj->op); } } } @@ -351,6 +354,9 @@ static void linphone_proxy_config_register(LinphoneProxyConfig *obj){ linphone_proxy_config_set_state(obj,LinphoneRegistrationFailed,"Registration failed"); } ms_free(proxy_string); + } else { + /*stop refresher, just in case*/ + if (obj->op) sal_op_stop_refreshing(obj->op); } } diff --git a/tester/register_tester.c b/tester/register_tester.c index 28850e141..a0d63e278 100644 --- a/tester/register_tester.c +++ b/tester/register_tester.c @@ -332,8 +332,7 @@ static void authenticated_register_with_wrong_late_credentials(){ linphone_core_manager_destroy(mgr); } -static void authenticated_register_with_wrong_credentials_with_params(const char* user_agent) { - LinphoneCoreManager *mgr; +static void authenticated_register_with_wrong_credentials_with_params_base(const char* user_agent,LinphoneCoreManager *mgr) { stats* counters; LCSipTransports transport = {5070,5070,0,5071}; LinphoneAuthInfo *info=linphone_auth_info_new(test_username,NULL,"wrong passwd",NULL,auth_domain,NULL); /*create authentication structure from identity*/ @@ -341,8 +340,6 @@ static void authenticated_register_with_wrong_credentials_with_params(const char sprintf(route,"sip:%s",test_route); - mgr=linphone_core_manager_new(NULL); - mgr->lc->vtable.auth_info_requested=auth_info_requested2; sal_set_refresher_retry_after(mgr->lc->sal,500); @@ -372,11 +369,33 @@ static void authenticated_register_with_wrong_credentials_with_params(const char } } + } +static void authenticated_register_with_wrong_credentials_with_params(const char* user_agent) { + LinphoneCoreManager *mgr = linphone_core_manager_new(NULL); + authenticated_register_with_wrong_credentials_with_params_base(user_agent,mgr); linphone_core_manager_destroy(mgr); } static void authenticated_register_with_wrong_credentials() { authenticated_register_with_wrong_credentials_with_params(NULL); } +static void authenticated_register_with_wrong_credentials_2() { + LinphoneCoreManager *mgr = linphone_core_manager_new(NULL); + stats* counters = get_stats(mgr->lc); + int current_in_progress; + LinphoneProxyConfig* proxy; + + authenticated_register_with_wrong_credentials_with_params_base(NULL,mgr); + + linphone_core_get_default_proxy(mgr->lc,&proxy); + /*Make sure registration attempts are stopped*/ + linphone_proxy_config_edit(proxy); + linphone_proxy_config_enable_register(proxy,FALSE); + linphone_proxy_config_done(proxy); + current_in_progress=counters->number_of_LinphoneRegistrationProgress; + CU_ASSERT_FALSE(wait_for(mgr->lc,mgr->lc,&counters->number_of_LinphoneRegistrationProgress,current_in_progress+1)); + + linphone_core_manager_destroy(mgr); +} static void authenticated_register_with_wrong_credentials_without_403() { authenticated_register_with_wrong_credentials_with_params("tester-no-403"); } @@ -655,6 +674,7 @@ test_t register_tests[] = { { "Ha1 authenticated register", ha1_authenticated_register }, { "Digest auth without initial credentials", authenticated_register_with_no_initial_credentials }, { "Digest auth with wrong credentials", authenticated_register_with_wrong_credentials }, + { "Digest auth with wrong credentials, check if registration attempts are stopped", authenticated_register_with_wrong_credentials_2 }, { "Digest auth with wrong credentials without 403", authenticated_register_with_wrong_credentials_without_403}, { "Authenticated register with wrong late credentials", authenticated_register_with_wrong_late_credentials}, { "Authenticated register with late credentials", authenticated_register_with_late_credentials },