summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKay Sievers <kay@vrfy.org>2014-09-02 15:28:56 +0200
committerKay Sievers <kay@vrfy.org>2014-09-02 15:29:15 +0200
commitab4df227d466e881e4279821b5fc1563f0e7e933 (patch)
tree8df38b8fa3f2a880c1acc6a08a2b5eb71ebc83b0
parent80cd2606b91ce2735a0609c6f964917cf12685aa (diff)
Revert "timesyncd: remove retry_timer logic which is covered by the server timeout"
This reverts commit 665c6a9eab46b0b253af6566ca9fc70c866b3fcd. On Tue, Sep 2, 2014 at 3:17 PM, Miroslav Lichvar <mlichvar@redhat.com> wrote: > > With the other patch allowing missed replies included it's now getting > stuck as there is no timer to send the 2nd and 3rd request.
-rw-r--r--src/timesync/timesyncd-manager.c14
-rw-r--r--src/timesync/timesyncd-manager.h1
2 files changed, 15 insertions, 0 deletions
diff --git a/src/timesync/timesyncd-manager.c b/src/timesync/timesyncd-manager.c
index 3261bc1fb1..a5678ccaed 100644
--- a/src/timesync/timesyncd-manager.c
+++ b/src/timesync/timesyncd-manager.c
@@ -209,6 +209,19 @@ static int manager_send_request(Manager *m) {
return manager_connect(m);
}
+ /* re-arm timer with increasing timeout, in case the packets never arrive back */
+ if (m->retry_interval > 0) {
+ if (m->retry_interval < NTP_POLL_INTERVAL_MAX_SEC * USEC_PER_SEC)
+ m->retry_interval *= 2;
+ } else
+ m->retry_interval = NTP_POLL_INTERVAL_MIN_SEC * USEC_PER_SEC;
+
+ r = manager_arm_timer(m, m->retry_interval);
+ if (r < 0) {
+ log_error("Failed to rearm timer: %s", strerror(-r));
+ return r;
+ }
+
m->missed_replies++;
if (m->missed_replies > NTP_MAX_MISSED_REPLIES) {
r = sd_event_add_time(
@@ -596,6 +609,7 @@ static int manager_receive_response(sd_event_source *source, int fd, uint32_t re
/* valid packet */
m->pending = false;
+ m->retry_interval = 0;
/* announce leap seconds */
if (NTP_FIELD_LEAP(ntpmsg.field) & NTP_LEAP_PLUSSEC)
diff --git a/src/timesync/timesyncd-manager.h b/src/timesync/timesyncd-manager.h
index 8296d41295..c7efdc5dfb 100644
--- a/src/timesync/timesyncd-manager.h
+++ b/src/timesync/timesyncd-manager.h
@@ -60,6 +60,7 @@ struct Manager {
/* last sent packet */
struct timespec trans_time_mon;
struct timespec trans_time;
+ usec_t retry_interval;
bool pending;
/* poll timer */