aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-12-17 12:17:41 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2009-12-17 12:17:41 +0100
commite99c8d2ef5bb94e64ea55f5900c5d9a513684ec8 (patch)
treeae5a4cd39ca164c206a2ad88a0ad07f2ed2484d5 /networking
parent8a936cfab718aee9f304f1b41e6b16cf6b5999f9 (diff)
downloadbusybox-e99c8d2ef5bb94e64ea55f5900c5d9a513684ec8.tar.gz
ntpd: eliminate one time(NULL) call
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking')
-rw-r--r--networking/ntpd.c7
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)
*
* Save the real transmit timestamp locally.
*/
-
p->msg.m_xmttime.int_partl = random();
p->msg.m_xmttime.fractionl = random();
p->xmttime = gettime1900d();
@@ -577,6 +576,9 @@ recv_and_process_peer_pkt(ntp_peer_t *p)
|| msg.m_stratum == 0
|| msg.m_stratum > NTP_MAXSTRATUM
) {
+// TODO: stratum 0 responses may have commands in 32-bit m_refid field:
+// "DENY", "RSTR" - peer does not like us at all
+// "RATE" - peer is overloaded, reduce polling freq
interval = error_interval();
bb_error_msg("reply from %s: not synced, next query in %us", p->dotted, interval);
goto close_sock;
@@ -596,7 +598,6 @@ recv_and_process_peer_pkt(ntp_peer_t *p)
*
* d = (T4 - T1) - (T3 - T2) t = ((T2 - T1) + (T3 - T4)) / 2.
*/
-
T4 = gettime1900d();
T1 = p->xmttime;
T2 = lfp_to_d(msg.m_rectime);
@@ -613,7 +614,7 @@ recv_and_process_peer_pkt(ntp_peer_t *p)
goto close_sock;
}
//UNUSED: offset->o_error = (T2 - T1) - (T3 - T4);
- offset->o_rcvd = time(NULL); /* can use (time_t)(T4 - OFFSET_1900_1970) too */
+ offset->o_rcvd = (time_t)(T4 - OFFSET_1900_1970); /* = time(NULL); */
offset->o_good = 1;
offset->o_leap = (msg.m_status & LI_MASK);