From 1a36b0626c41fc255e48688440bd204452bc4823 Mon Sep 17 00:00:00 2001
From: Jehan Monnier <jehan.monnier@linphone.org>
Date: Thu, 17 Feb 2011 17:41:08 +0100
Subject: [PATCH] -uninit sal upon network is no more reachable -create new
 function to refreash registration

---
 coreapi/linphonecore.c | 18 +++++++++++++++++-
 coreapi/linphonecore.h |  6 +++++-
 coreapi/sal_eXosip2.c  |  1 +
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/coreapi/linphonecore.c b/coreapi/linphonecore.c
index 928209827d..8db39dd515 100644
--- a/coreapi/linphonecore.c
+++ b/coreapi/linphonecore.c
@@ -3904,8 +3904,24 @@ static void set_network_reachable(LinphoneCore* lc,bool_t isReachable, time_t cu
 	}
 	lc->netup_time=curtime;
 	lc->network_reachable=isReachable;
-}
+	if(!isReachable) {
+		sal_unlisten_ports (lc->sal);
+	} else {
+		apply_transports(lc);
+	}
 
+}
+void linphone_core_refresh_registers(LinphoneCore* lc) {
+	const MSList *elem=linphone_core_get_proxy_config_list(lc);
+	for(;elem!=NULL;elem=elem->next){
+		LinphoneProxyConfig *cfg=(LinphoneProxyConfig*)elem->data;
+		if (linphone_proxy_config_register_enabled(cfg) ) {
+			cfg->registered=0;
+			cfg->commit=TRUE;
+		}
+	}
+	
+}
 void linphone_core_set_network_reachable(LinphoneCore* lc,bool_t isReachable) {
 	//first disable automatic mode
 	if (lc->auto_net_state_mon) {
diff --git a/coreapi/linphonecore.h b/coreapi/linphonecore.h
index 82709208d5..81ab3e9499 100644
--- a/coreapi/linphonecore.h
+++ b/coreapi/linphonecore.h
@@ -972,7 +972,11 @@ int linphone_core_get_current_call_stats(LinphoneCore *lc, rtp_stats_t *local, r
 const MSList *linphone_core_get_calls(LinphoneCore *lc);
 
 LinphoneGlobalState linphone_core_get_global_state(const LinphoneCore *lc);
-
+/**
+ * force registration refresh to be initiated upon next iterate
+ * @ingroup proxies
+ */
+void linphone_core_refresh_registers(LinphoneCore* lc);	
 #ifdef __cplusplus
 }
 #endif
diff --git a/coreapi/sal_eXosip2.c b/coreapi/sal_eXosip2.c
index 61c7c494d0..222e6e5975 100644
--- a/coreapi/sal_eXosip2.c
+++ b/coreapi/sal_eXosip2.c
@@ -329,6 +329,7 @@ int sal_unlisten_ports(Sal *ctx){
 	if (ctx->running){
 		eXosip_quit();
 		eXosip_init();
+		ctx->running=FALSE;
 	}
 	return 0;
 }
-- 
GitLab