summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-12-02 11:29:06 (GMT)
committer Denys Vlasenko <vda.linux@googlemail.com>2009-12-02 11:29:06 (GMT)
commitebde6f10fbce0e1843cf1ffa2b1f2697d0139117 (patch)
treebb162d1c1762f4c06cd144b13cadab369c3f617c
parentf91e63cbc3aa46ed0ed39d9aa664594f418da255 (diff)
downloadbusybox-ebde6f10fbce0e1843cf1ffa2b1f2697d0139117.tar.gz
busybox-ebde6f10fbce0e1843cf1ffa2b1f2697d0139117.tar.bz2
ntpd: fix "synced" state detection
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/ntpd.c19
1 files changed, 7 insertions, 12 deletions
diff --git a/networking/ntpd.c b/networking/ntpd.c
index 17748b0..b100caa 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -469,21 +469,16 @@ slew_time(void)
} else {
if (G.verbose >= 2)
bb_error_msg("old adjust: %d.%06u", (int)tv.tv_sec, (unsigned)tv.tv_usec);
- if (G.first_adj_done
- && tv.tv_sec == 0
- && tv.tv_usec == 0 // TODO: allow for tiny values?
- && !G.synced
- ) {
- G.synced = 1;
- bb_error_msg("clock %ssynced", "");
- } else
- if (G.synced) {
- G.synced = 0;
- bb_error_msg("clock %ssynced", "un");
+ if (G.first_adj_done) {
+ uint8_t synced = (tv.tv_sec == 0 && tv.tv_usec == 0);
+ if (synced != G.synced) {
+ G.synced = synced;
+ bb_error_msg("clock is %ssynced", synced ? "" : "un");
+ }
}
+ G.first_adj_done = 1;
}
- G.first_adj_done = 1;
G.reftime = gettime1900fp();
G.scale = updated_scale(offset_median);