diff options
author | Marco Pfatschbacher <mpf@cvs.openbsd.org> | 2008-01-28 11:46:00 +0000 |
---|---|---|
committer | Marco Pfatschbacher <mpf@cvs.openbsd.org> | 2008-01-28 11:46:00 +0000 |
commit | db1b1fbbd5ffb142c081faa22509b666fb442987 (patch) | |
tree | ea1b19bc5cf7d2c142b29fb08e5dacd336886272 /usr.sbin/ntpd/ntp.c | |
parent | 9322ea58b54a9487a1c51406bcb230b860b3b076 (diff) |
Reconnect a client socket after three consecutive send failures.
This allows recovery after an IP address change (e.g. on dialup links).
Also move the update of "nextaction" timeout below the deadline check.
OK henning@
Diffstat (limited to 'usr.sbin/ntpd/ntp.c')
-rw-r--r-- | usr.sbin/ntpd/ntp.c | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/usr.sbin/ntpd/ntp.c b/usr.sbin/ntpd/ntp.c index 1da3eef6ca1..28234875813 100644 --- a/usr.sbin/ntpd/ntp.c +++ b/usr.sbin/ntpd/ntp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntp.c,v 1.102 2007/12/27 01:46:50 stevesk Exp $ */ +/* $OpenBSD: ntp.c,v 1.103 2008/01/28 11:45:59 mpf Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -229,11 +229,6 @@ ntp_main(int pipe_prnt[2], struct ntpd_conf *nconf, struct passwd *pw) if (client_query(p) == 0) sent_cnt++; } - if (p->next > 0 && p->next < nextaction) - nextaction = p->next; - - if (p->deadline > 0 && p->deadline < nextaction) - nextaction = p->deadline; if (p->deadline > 0 && p->deadline <= getmonotime()) { timeout = error_interval(); log_debug("no reply from %s received in time, " @@ -247,6 +242,19 @@ ntp_main(int pipe_prnt[2], struct ntpd_conf *nconf, struct passwd *pw) client_nextaddr(p); set_next(p, timeout); } + if (p->senderrors > MAX_SEND_ERRORS) { + log_debug("failed to send query to %s, " + "next query %ds", log_sockaddr( + (struct sockaddr *)&p->addr->ss), + INTERVAL_QUERY_PATHETIC); + p->senderrors = 0; + client_nextaddr(p); + set_next(p, INTERVAL_QUERY_PATHETIC); + } + if (p->next > 0 && p->next < nextaction) + nextaction = p->next; + if (p->deadline > 0 && p->deadline < nextaction) + nextaction = p->deadline; if (p->state == STATE_QUERY_SENT && p->query->fd != -1) { |