From 565f83f13d731e5ed90fe1a466c5f21a55eb44ce Mon Sep 17 00:00:00 2001 From: Simon Morlat Date: Fri, 14 Oct 2016 18:57:34 +0200 Subject: [PATCH] improve and fix management of REGISTER in LinphoneProxyConfig --- coreapi/private.h | 3 +-- coreapi/proxy.c | 17 +++++++++++------ tester/register_tester.c | 5 +---- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/coreapi/private.h b/coreapi/private.h index d22658dd9..a56e47449 100644 --- a/coreapi/private.h +++ b/coreapi/private.h @@ -651,8 +651,7 @@ struct _LinphoneProxyConfig /*use to check if server config has changed between edit() and done()*/ LinphoneAddress *saved_proxy; LinphoneAddress *saved_identity; - int saved_expires; - bool_t saved_sendregister; + bool_t register_changed; bool_t unused[3]; /*---*/ LinphoneAddress *pending_contact; /*use to store previous contact in case of network failure*/ diff --git a/coreapi/proxy.c b/coreapi/proxy.c index 5dec09c55..f339e5938 100644 --- a/coreapi/proxy.c +++ b/coreapi/proxy.c @@ -29,8 +29,6 @@ Copyright (C) 2000 Simon MORLAT (simon.morlat@linphone.org) /*store current config related to server location*/ static void linphone_proxy_config_store_server_config(LinphoneProxyConfig* cfg) { - cfg->saved_sendregister = cfg->reg_sendregister; - cfg->saved_expires = cfg->expires; if (cfg->saved_identity) linphone_address_destroy(cfg->saved_identity); if (cfg->identity_address) cfg->saved_identity = linphone_address_clone(cfg->identity_address); @@ -356,11 +354,13 @@ bool_t linphone_proxy_config_check(LinphoneCore *lc, LinphoneProxyConfig *cfg){ } void linphone_proxy_config_enableregister(LinphoneProxyConfig *cfg, bool_t val){ + if (val != cfg->reg_sendregister) cfg->register_changed = TRUE; cfg->reg_sendregister=val; } void linphone_proxy_config_set_expires(LinphoneProxyConfig *cfg, int val){ if (val<0) val=600; + if (val != cfg->expires) cfg->register_changed = TRUE; cfg->expires=val; } @@ -380,8 +380,7 @@ void linphone_proxy_config_edit(LinphoneProxyConfig *cfg){ if (cfg->publish && cfg->long_term_event){ linphone_event_pause_publish(cfg->long_term_event); } - /*stop refresher in any case*/ - linphone_proxy_config_pause_register(cfg); + /*Don't stop refresher*/ } void linphone_proxy_config_apply(LinphoneProxyConfig *cfg,LinphoneCore *lc){ @@ -784,9 +783,12 @@ int linphone_proxy_config_done(LinphoneProxyConfig *cfg) } cfg->commit = TRUE; } - if ((cfg->saved_sendregister != cfg->reg_sendregister) - || (cfg->saved_expires != cfg->expires)){ + if (cfg->register_changed){ cfg->commit = TRUE; + cfg->register_changed = FALSE; + } + if (cfg->commit){ + linphone_proxy_config_pause_register(cfg); } if (linphone_proxy_config_compute_publish_params_hash(cfg)) { @@ -917,6 +919,7 @@ void linphone_proxy_config_set_contact_parameters(LinphoneProxyConfig *cfg, cons if (contact_params){ cfg->contact_params=ms_strdup(contact_params); } + cfg->register_changed = TRUE; } void linphone_proxy_config_set_contact_uri_parameters(LinphoneProxyConfig *cfg, const char *contact_uri_params){ @@ -927,6 +930,7 @@ void linphone_proxy_config_set_contact_uri_parameters(LinphoneProxyConfig *cfg, if (contact_uri_params){ cfg->contact_uri_params=ms_strdup(contact_uri_params); } + cfg->register_changed = TRUE; } const char *linphone_proxy_config_get_contact_parameters(const LinphoneProxyConfig *cfg){ @@ -950,6 +954,7 @@ const char *linphone_proxy_config_get_custom_header(LinphoneProxyConfig *cfg, co void linphone_proxy_config_set_custom_header(LinphoneProxyConfig *cfg, const char *header_name, const char *header_value){ cfg->sent_headers=sal_custom_header_append(cfg->sent_headers, header_name, header_value); + cfg->register_changed = TRUE; } int linphone_core_add_proxy_config(LinphoneCore *lc, LinphoneProxyConfig *cfg){ diff --git a/tester/register_tester.c b/tester/register_tester.c index 1ae32c7e8..ed32e2b80 100644 --- a/tester/register_tester.c +++ b/tester/register_tester.c @@ -240,21 +240,18 @@ static void change_expires(void){ proxy_config = linphone_core_get_default_proxy_config(lcm->lc); linphone_proxy_config_edit(proxy_config); - reset_counters(counters); /*clear stats*/ /*nothing is supposed to arrive until done*/ BC_ASSERT_FALSE(wait_for_until(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationCleared,1,3000)); linphone_proxy_config_set_expires(proxy_config,3); - + reset_counters(counters); /*clear stats*/ linphone_proxy_config_done(proxy_config); BC_ASSERT_TRUE(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,1)); /*wait 2s without receive refresh*/ BC_ASSERT_FALSE(wait_for_until(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,2,2000)); /* now, it should be ok*/ BC_ASSERT_TRUE(wait_for(lcm->lc,lcm->lc,&counters->number_of_LinphoneRegistrationOk,2)); - - linphone_core_manager_destroy(lcm); }