summaryrefslogtreecommitdiff
path: root/src/ntp.c
diff options
context:
space:
mode:
authorJukka Rissanen <jukka.rissanen@linux.intel.com>2012-07-16 11:00:46 +0300
committerDaniel Wagner <daniel.wagner@bmw-carit.de>2012-07-16 18:03:29 +0200
commite91159d7cea8c5d7a7eadb337233c3d2e32b9bfe (patch)
tree1052d011bd4bac3e3cf30d0f28c94b1db335530c /src/ntp.c
parentfc98abda2a78879285c953d9091b444b04776ba9 (diff)
downloadconnman-e91159d7cea8c5d7a7eadb337233c3d2e32b9bfe.tar.gz
connman-e91159d7cea8c5d7a7eadb337233c3d2e32b9bfe.tar.bz2
connman-e91159d7cea8c5d7a7eadb337233c3d2e32b9bfe.zip
ntp: If the server cannot be contacted, try next one
This could happen if the network routes are not yet setup so the sendto() could fail. In this case try next address and hope for the best. This is a rare issue but I have seen it couple of times.
Diffstat (limited to 'src/ntp.c')
-rw-r--r--src/ntp.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/ntp.c b/src/ntp.c
index 91a8832d..8c31fdb6 100644
--- a/src/ntp.c
+++ b/src/ntp.c
@@ -100,7 +100,12 @@ static void send_packet(int fd, const char *server)
len = sendto(fd, &msg, sizeof(msg), MSG_DONTWAIT,
&addr, sizeof(addr));
if (len < 0) {
- connman_error("Time request for server %s failed", server);
+ connman_error("Time request for server %s failed (%d/%s)",
+ server, errno, strerror(errno));
+
+ if (errno == ENETUNREACH)
+ __connman_timeserver_sync_next();
+
return;
}