diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2015-01-29 16:31:36 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2015-01-29 16:31:36 +0100 |
commit | ff3f3accc68c84851d1ea8cd995f9491b32bedef (patch) | |
tree | a7c01d5c96af6c0082fe0a04d0f7479a0bb6a16f | |
parent | 936c401077cc68d9e3dd7f1b0b293ee03ce02bf5 (diff) | |
download | busybox-w32-ff3f3accc68c84851d1ea8cd995f9491b32bedef.tar.gz busybox-w32-ff3f3accc68c84851d1ea8cd995f9491b32bedef.tar.bz2 busybox-w32-ff3f3accc68c84851d1ea8cd995f9491b32bedef.zip |
ntpd: get rid of G.initial_poll_complete
This speeds up syncing - now happens only just
two replies from a peer. Especially useful for "ntpd -q".
Shouldn't have ill effects: if we chose a bad peer,
we will discover it later and switch to another one.
The code is even smaller this way.
Suggested by Miroslav Lichvar <mlichvar@redhat.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/ntpd.c | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/networking/ntpd.c b/networking/ntpd.c index 33cb1dcb1..c016bfc50 100644 --- a/networking/ntpd.c +++ b/networking/ntpd.c | |||
@@ -376,8 +376,6 @@ struct globals { | |||
376 | */ | 376 | */ |
377 | #define G_precision_sec 0.002 | 377 | #define G_precision_sec 0.002 |
378 | uint8_t stratum; | 378 | uint8_t stratum; |
379 | /* Bool. After set to 1, never goes back to 0: */ | ||
380 | smallint initial_poll_complete; | ||
381 | 379 | ||
382 | #define STATE_NSET 0 /* initial state, "nothing is set" */ | 380 | #define STATE_NSET 0 /* initial state, "nothing is set" */ |
383 | //#define STATE_FSET 1 /* frequency set from file */ | 381 | //#define STATE_FSET 1 /* frequency set from file */ |
@@ -1084,7 +1082,7 @@ select_and_cluster(void) | |||
1084 | 1082 | ||
1085 | num_points = 0; | 1083 | num_points = 0; |
1086 | item = G.ntp_peers; | 1084 | item = G.ntp_peers; |
1087 | if (G.initial_poll_complete) while (item != NULL) { | 1085 | while (item != NULL) { |
1088 | double rd, offset; | 1086 | double rd, offset; |
1089 | 1087 | ||
1090 | p = (peer_t *) item->data; | 1088 | p = (peer_t *) item->data; |
@@ -1649,7 +1647,7 @@ update_local_clock(peer_t *p) | |||
1649 | if (G.ntp_status & LI_MINUSSEC) | 1647 | if (G.ntp_status & LI_MINUSSEC) |
1650 | tmx.status |= STA_DEL; | 1648 | tmx.status |= STA_DEL; |
1651 | 1649 | ||
1652 | tmx.constant = G.poll_exp - 4; | 1650 | tmx.constant = (int)G.poll_exp - 4 > 0 ? (int)G.poll_exp - 4 : 0; |
1653 | /* EXPERIMENTAL. | 1651 | /* EXPERIMENTAL. |
1654 | * The below if statement should be unnecessary, but... | 1652 | * The below if statement should be unnecessary, but... |
1655 | * It looks like Linux kernel's PLL is far too gentle in changing | 1653 | * It looks like Linux kernel's PLL is far too gentle in changing |
@@ -2285,7 +2283,6 @@ int ntpd_main(int argc UNUSED_PARAM, char **argv) | |||
2285 | VERB4 bb_error_msg("disabling burst mode"); | 2283 | VERB4 bb_error_msg("disabling burst mode"); |
2286 | G.polladj_count = 0; | 2284 | G.polladj_count = 0; |
2287 | G.poll_exp = MINPOLL; | 2285 | G.poll_exp = MINPOLL; |
2288 | G.initial_poll_complete = 1; | ||
2289 | } | 2286 | } |
2290 | send_query_to_peer(p); | 2287 | send_query_to_peer(p); |
2291 | } else { | 2288 | } else { |