[Patch v2 08/12] timeserver: Use service timeserver, if any, before system timeservers

Alok Barsode alokbarsode at gmail.com
Fri Feb 3 10:26:02 PST 2012


From: Alok Barsode <alok.barsode at linux.intel.com>

---
 include/service.h |    1 +
 src/service.c     |   11 +++++++++++
 src/timeserver.c  |   11 +++++++++++
 3 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/include/service.h b/include/service.h
index afa51a2..d7aaca5 100644
--- a/include/service.h
+++ b/include/service.h
@@ -107,6 +107,7 @@ char *connman_service_get_interface(struct connman_service *service);
 
 const char *connman_service_get_domainname(struct connman_service *service);
 char **connman_service_get_nameservers(struct connman_service *service);
+char **connman_service_get_timeservers(struct connman_service *service);
 void connman_service_set_proxy_method(struct connman_service *service, enum connman_service_proxy_method method);
 enum connman_service_proxy_method connman_service_get_proxy_method(struct connman_service *service);
 char **connman_service_get_proxy_servers(struct connman_service *service);
diff --git a/src/service.c b/src/service.c
index 2fe93fc..a61824f 100644
--- a/src/service.c
+++ b/src/service.c
@@ -2154,6 +2154,17 @@ char **connman_service_get_nameservers(struct connman_service *service)
 	return NULL;
 }
 
+char **connman_service_get_timeservers(struct connman_service *service)
+{
+	if (service == NULL)
+		return NULL;
+
+	if (service->timeservers != NULL)
+		return service->timeservers;
+
+	return NULL;
+}
+
 void connman_service_set_proxy_method(struct connman_service *service,
 					enum connman_service_proxy_method method)
 {
diff --git a/src/timeserver.c b/src/timeserver.c
index a361433..b00f109 100644
--- a/src/timeserver.c
+++ b/src/timeserver.c
@@ -35,6 +35,7 @@ static GSList *driver_list = NULL;
 static GHashTable *server_hash = NULL;
 
 static char **system_timeservers = NULL;
+static char **timeservers = NULL;
 
 static GResolv *resolv = NULL;
 static int resolv_id = 0;
@@ -289,6 +290,14 @@ int __connman_timeserver_sync(struct connman_service *service)
 
 	system_timeservers = load_timeservers();
 
+	timeservers = connman_service_get_timeservers(service);
+
+	if (timeservers != NULL && timeservers[0] != NULL) {
+		DBG("Using service tiemservers");
+		__connman_ntp_start(timeservers[0]);
+		return 0;
+	}
+
 	if (system_timeservers == NULL || system_timeservers[count] == NULL) {
 		DBG("No timeservers set.");
 		return 0;
@@ -315,6 +324,8 @@ void __connman_timeserver_stop()
 		system_timeservers = NULL;
 	}
 
+	timeservers = NULL;
+
 	count = 0;
 
 	__connman_ntp_stop();
-- 
1.7.5.4




More information about the connman mailing list