From 4e66b5ce8a7c060c77480995919e5d1ba28394df Mon Sep 17 00:00:00 2001 From: Miroslav Lichvar Date: Wed, 20 Aug 2014 16:41:18 +0200 Subject: [PATCH] ntp: don't stop online burst when sending fails Don't stop online burst for unreachable sources until sending succeeds. This is mainly useful with iburst when chronyd is started before the network is configured. --- ntp_core.c | 4 ++++ sources.c | 8 ++++++++ sources.h | 1 + 3 files changed, 13 insertions(+) diff --git a/ntp_core.c b/ntp_core.c index 55f1e96..53858f6 100644 --- a/ntp_core.c +++ b/ntp_core.c @@ -891,6 +891,10 @@ transmit_timeout(void *arg) switch (inst->opmode) { case MD_BURST_WAS_ONLINE: + /* When not reachable, don't stop online burst until sending succeeds */ + if (!sent && !SRC_IsReachable(inst->source)) + break; + /* Fall through */ case MD_BURST_WAS_OFFLINE: --inst->burst_total_samples_to_go; break; diff --git a/sources.c b/sources.c index b9e095d..e24463d 100644 --- a/sources.c +++ b/sources.c @@ -1167,6 +1167,14 @@ SRC_IsSyncPeer(SRC_Instance inst) /* ================================================== */ +int +SRC_IsReachable(SRC_Instance inst) +{ + return inst->reachability != 0; +} + +/* ================================================== */ + int SRC_ReadNumberOfSources(void) { diff --git a/sources.h b/sources.h index 64c450d..c28102c 100644 --- a/sources.h +++ b/sources.h @@ -171,6 +171,7 @@ extern void SRC_DumpSources(void); extern void SRC_ReloadSources(void); extern int SRC_IsSyncPeer(SRC_Instance inst); +extern int SRC_IsReachable(SRC_Instance inst); extern int SRC_ReadNumberOfSources(void); extern int SRC_ActiveSources(void); extern int SRC_ReportSource(int index, RPT_SourceReport *report, struct timeval *now);