*
* Connection Manager
*
- * Copyright (C) 2007-2010 Intel Corporation. All rights reserved.
+ * Copyright (C) 2007-2012 Intel Corporation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
static char *timeserver = NULL;
static gint poll_id = 0;
+static gint timeout_id = 0;
static void send_packet(int fd, const char *server)
{
}
}
+static gboolean next_server(gpointer user_data)
+{
+ if (timeserver != NULL) {
+ g_free(timeserver);
+ timeserver = NULL;
+ }
+
+ __connman_timeserver_sync_next();
+
+ return FALSE;
+}
+
static gboolean next_poll(gpointer user_data)
{
if (timeserver == NULL || transmit_fd == 0)
DBG("offset=%f delay=%f", offset, delay);
- /* Timeserver has responded.
+ /* Remove the timeout, as timeserver has responded */
+ if (timeout_id > 0)
+ g_source_remove(timeout_id);
+
+ /*
* Now poll the server every transmit_delay seconds
* for time correction.
*/
int __connman_ntp_start(char *server)
{
- DBG("");
+ DBG("%s", server);
if (server == NULL)
return -EINVAL;
start_ntp(timeserver);
+ /*
+ * Add a fallback timeout , preferably short, 5 sec here,
+ * to fallback on the next server.
+ */
+
+ timeout_id = g_timeout_add_seconds(5, next_server, NULL);
+
return 0;
}
if (poll_id > 0)
g_source_remove(poll_id);
+ if (timeout_id > 0)
+ g_source_remove(timeout_id);
+
if (channel_watch > 0) {
g_source_remove(channel_watch);
channel_watch = 0;