diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-12-17 12:17:41 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-12-17 12:17:41 +0100 |
commit | e99c8d2ef5bb94e64ea55f5900c5d9a513684ec8 (patch) | |
tree | ae5a4cd39ca164c206a2ad88a0ad07f2ed2484d5 /networking/ntpd.c | |
parent | 8a936cfab718aee9f304f1b41e6b16cf6b5999f9 (diff) | |
download | busybox-w32-e99c8d2ef5bb94e64ea55f5900c5d9a513684ec8.tar.gz busybox-w32-e99c8d2ef5bb94e64ea55f5900c5d9a513684ec8.tar.bz2 busybox-w32-e99c8d2ef5bb94e64ea55f5900c5d9a513684ec8.zip |
ntpd: eliminate one time(NULL) call
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/ntpd.c')
-rw-r--r-- | networking/ntpd.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/networking/ntpd.c b/networking/ntpd.c index ca79e0338..1e6c4da7f 100644 --- a/networking/ntpd.c +++ b/networking/ntpd.c | |||
@@ -326,7 +326,6 @@ send_query_to_peer(ntp_peer_t *p) | |||
326 | * | 326 | * |
327 | * Save the real transmit timestamp locally. | 327 | * Save the real transmit timestamp locally. |
328 | */ | 328 | */ |
329 | |||
330 | p->msg.m_xmttime.int_partl = random(); | 329 | p->msg.m_xmttime.int_partl = random(); |
331 | p->msg.m_xmttime.fractionl = random(); | 330 | p->msg.m_xmttime.fractionl = random(); |
332 | p->xmttime = gettime1900d(); | 331 | p->xmttime = gettime1900d(); |
@@ -577,6 +576,9 @@ recv_and_process_peer_pkt(ntp_peer_t *p) | |||
577 | || msg.m_stratum == 0 | 576 | || msg.m_stratum == 0 |
578 | || msg.m_stratum > NTP_MAXSTRATUM | 577 | || msg.m_stratum > NTP_MAXSTRATUM |
579 | ) { | 578 | ) { |
579 | // TODO: stratum 0 responses may have commands in 32-bit m_refid field: | ||
580 | // "DENY", "RSTR" - peer does not like us at all | ||
581 | // "RATE" - peer is overloaded, reduce polling freq | ||
580 | interval = error_interval(); | 582 | interval = error_interval(); |
581 | bb_error_msg("reply from %s: not synced, next query in %us", p->dotted, interval); | 583 | bb_error_msg("reply from %s: not synced, next query in %us", p->dotted, interval); |
582 | goto close_sock; | 584 | goto close_sock; |
@@ -596,7 +598,6 @@ recv_and_process_peer_pkt(ntp_peer_t *p) | |||
596 | * | 598 | * |
597 | * d = (T4 - T1) - (T3 - T2) t = ((T2 - T1) + (T3 - T4)) / 2. | 599 | * d = (T4 - T1) - (T3 - T2) t = ((T2 - T1) + (T3 - T4)) / 2. |
598 | */ | 600 | */ |
599 | |||
600 | T4 = gettime1900d(); | 601 | T4 = gettime1900d(); |
601 | T1 = p->xmttime; | 602 | T1 = p->xmttime; |
602 | T2 = lfp_to_d(msg.m_rectime); | 603 | T2 = lfp_to_d(msg.m_rectime); |
@@ -613,7 +614,7 @@ recv_and_process_peer_pkt(ntp_peer_t *p) | |||
613 | goto close_sock; | 614 | goto close_sock; |
614 | } | 615 | } |
615 | //UNUSED: offset->o_error = (T2 - T1) - (T3 - T4); | 616 | //UNUSED: offset->o_error = (T2 - T1) - (T3 - T4); |
616 | offset->o_rcvd = time(NULL); /* can use (time_t)(T4 - OFFSET_1900_1970) too */ | 617 | offset->o_rcvd = (time_t)(T4 - OFFSET_1900_1970); /* = time(NULL); */ |
617 | offset->o_good = 1; | 618 | offset->o_good = 1; |
618 | 619 | ||
619 | offset->o_leap = (msg.m_status & LI_MASK); | 620 | offset->o_leap = (msg.m_status & LI_MASK); |