aboutsummaryrefslogtreecommitdiff
path: root/networking/ntpd.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-01-17 03:01:15 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2010-01-17 03:01:15 +0100
commit57f46c1afd28551d8446b80b6e325d67eb44135c (patch)
treedbb5f0457a5953166972482e0a530790fc51198d /networking/ntpd.c
parent9b20adca4b2b59c791b4b5579857e4f028a969ed (diff)
downloadbusybox-w32-57f46c1afd28551d8446b80b6e325d67eb44135c.tar.gz
busybox-w32-57f46c1afd28551d8446b80b6e325d67eb44135c.tar.bz2
busybox-w32-57f46c1afd28551d8446b80b6e325d67eb44135c.zip
ntpd: remove some code which is at best unneeded and at worst wrong
function old new delta step_time 246 256 +10 ntpd_main 855 844 -11 update_local_clock 767 714 -53 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/ntpd.c')
-rw-r--r--networking/ntpd.c21
1 files changed, 3 insertions, 18 deletions
diff --git a/networking/ntpd.c b/networking/ntpd.c
index aca79c95a..95dfdb119 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -294,7 +294,6 @@ struct globals {
294#define G_precision_sec (1.0 / (1 << (- G_precision_exp))) 294#define G_precision_sec (1.0 / (1 << (- G_precision_exp)))
295 uint8_t stratum; 295 uint8_t stratum;
296 /* Bool. After set to 1, never goes back to 0: */ 296 /* Bool. After set to 1, never goes back to 0: */
297 smallint adjtimex_was_done;
298 smallint initial_poll_complete; 297 smallint initial_poll_complete;
299 298
300#define STATE_NSET 0 /* initial state, "nothing is set" */ 299#define STATE_NSET 0 /* initial state, "nothing is set" */
@@ -813,6 +812,7 @@ step_time(double offset)
813 /* Globals: */ 812 /* Globals: */
814 G.cur_time -= offset; 813 G.cur_time -= offset;
815 G.last_update_recv_time -= offset; 814 G.last_update_recv_time -= offset;
815 G.last_script_run -= offset;
816} 816}
817 817
818 818
@@ -1171,7 +1171,6 @@ static NOINLINE int
1171update_local_clock(peer_t *p) 1171update_local_clock(peer_t *p)
1172{ 1172{
1173 int rc; 1173 int rc;
1174 long old_tmx_offset;
1175 struct timex tmx; 1174 struct timex tmx;
1176 /* Note: can use G.cluster_offset instead: */ 1175 /* Note: can use G.cluster_offset instead: */
1177 double offset = p->filter_offset; 1176 double offset = p->filter_offset;
@@ -1423,17 +1422,6 @@ update_local_clock(peer_t *p)
1423 tmx.freq, tmx.offset, tmx.constant, tmx.status); 1422 tmx.freq, tmx.offset, tmx.constant, tmx.status);
1424 } 1423 }
1425 1424
1426 old_tmx_offset = 0;
1427 if (!G.adjtimex_was_done) {
1428 G.adjtimex_was_done = 1;
1429 /* When we use adjtimex for the very first time,
1430 * we need to ADD to pre-existing tmx.offset - it may be !0
1431 */
1432 memset(&tmx, 0, sizeof(tmx));
1433 if (adjtimex(&tmx) < 0)
1434 bb_perror_msg_and_die("adjtimex");
1435 old_tmx_offset = tmx.offset;
1436 }
1437 memset(&tmx, 0, sizeof(tmx)); 1425 memset(&tmx, 0, sizeof(tmx));
1438#if 0 1426#if 0
1439//doesn't work, offset remains 0 (!) in kernel: 1427//doesn't work, offset remains 0 (!) in kernel:
@@ -1446,9 +1434,8 @@ update_local_clock(peer_t *p)
1446 tmx.offset = G.last_update_offset * 1000000; /* usec */ 1434 tmx.offset = G.last_update_offset * 1000000; /* usec */
1447#endif 1435#endif
1448 tmx.modes = ADJ_OFFSET | ADJ_STATUS | ADJ_TIMECONST;// | ADJ_MAXERROR | ADJ_ESTERROR; 1436 tmx.modes = ADJ_OFFSET | ADJ_STATUS | ADJ_TIMECONST;// | ADJ_MAXERROR | ADJ_ESTERROR;
1449 tmx.offset = (G.last_update_offset * 1000000) /* usec */ 1437 tmx.offset = (G.last_update_offset * 1000000); /* usec */
1450 /* + (G.last_update_offset < 0 ? -0.5 : 0.5) - too small to bother */ 1438 /* + (G.last_update_offset < 0 ? -0.5 : 0.5) - too small to bother */
1451 + old_tmx_offset; /* almost always 0 */
1452 tmx.status = STA_PLL; 1439 tmx.status = STA_PLL;
1453 if (G.ntp_status & LI_PLUSSEC) 1440 if (G.ntp_status & LI_PLUSSEC)
1454 tmx.status |= STA_INS; 1441 tmx.status |= STA_INS;
@@ -2020,9 +2007,7 @@ int ntpd_main(int argc UNUSED_PARAM, char **argv)
2020 nfds = poll(pfd, i, timeout * 1000); 2007 nfds = poll(pfd, i, timeout * 1000);
2021 gettime1900d(); /* sets G.cur_time */ 2008 gettime1900d(); /* sets G.cur_time */
2022 if (nfds <= 0) { 2009 if (nfds <= 0) {
2023 if (G.adjtimex_was_done 2010 if (G.cur_time - G.last_script_run > 11*60) {
2024 && G.cur_time - G.last_script_run > 11*60
2025 ) {
2026 /* Useful for updating battery-backed RTC and such */ 2011 /* Useful for updating battery-backed RTC and such */
2027 run_script("periodic", G.last_update_offset); 2012 run_script("periodic", G.last_update_offset);
2028 gettime1900d(); /* sets G.cur_time */ 2013 gettime1900d(); /* sets G.cur_time */