Hi Alok,

Just small style issues.
+ */
  void __connman_timeserver_sync_next()
  {
-       if (system_timeservers == NULL ||
-       system_timeservers[count] == NULL)
+       char *server = NULL;
+       GList *l = NULL;
list instead of l? (at least it's more readable)
+
+       __connman_ntp_stop();
+
+       /* Get the 1st server in the list */
+       l = g_list_first(ts_list);
+       if(l == NULL)
+               return;
+
+       server = g_strdup(l->data);
+
+       ts_list = g_list_delete_link(ts_list, l);
+
+       /* if its a IP , directly query it. */
+       if (g_hostname_is_ip_address(server)) {
if (g_hostname_is_ip_address(server) == TRUE) {

+               DBG("Using timeservers %s", server);
+
+               __connman_ntp_start(server);
+
+               g_free(server);
                return;
+       }

-       DBG("Trying timeserver %s", system_timeservers[count]);
+       DBG("Resolving server %s", server);

-       if (resolv)
-               resolv_id = g_resolv_lookup_hostname(resolv,
-                       system_timeservers[count], resolv_result,
-                                               NULL);
+       resolv_id = g_resolv_lookup_hostname(resolv, server,
+                                               resolv_result, NULL);
+
+       g_free(server);
+
+       return;
  }

+/*
+ * __connman_timeserver_sync function recreates the timeserver
+ * list which will be used to determine NTP server for time corrections.
+ * It must be called everytime the default service changes, the service
+ * timeserver(s) changes or the global timeserver(s) changes.The service
+ * settings take priority over the global timeservers.
+ */
  int __connman_timeserver_sync(struct connman_service *service)
  {
+       char **timeservers = NULL;
+       int i;
+
+       if (resolv == NULL)
+               return 0;
+       /*
+        * Before be start creating the new timeserver list we must stop
+        * any ongoing ntp query and server resolution.
+        */
+
+       __connman_ntp_stop();
+
+       if(resolv_id>  0)
+               g_resolv_cancel_lookup(resolv, resolv_id);
+
+       if (ts_list) {
if (ts_list != NULL) {
+               g_list_free_full(ts_list, g_free);
+               ts_list = NULL;
+       }
+


  static void default_changed(struct connman_service *service)
  {
-       DBG("");
-
        if (service)
ok was already there, but if (service != NULL) would have been better.
-               __connman_timeserver_sync(service);
+               timeserver_start(service);
        else
-               __connman_timeserver_stop();
+               timeserver_stop();
  }

  static struct connman_notifier timeserver_notifier = {

Cheers,

Tomasz
_______________________________________________
connman mailing list
[email protected]
http://lists.connman.net/listinfo/connman

Reply via email to