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