diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-04 00:19:13 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2010-01-04 00:19:13 +0100 |
commit | 4168fdd8e6f5ad4d41a30a2350dbd635cc0fa6e1 (patch) | |
tree | 43c1ae5aa9fd90f8500319d01a98a87cad4b3fa1 /networking/ntpd.c | |
parent | d6459685c1a93785d0bdf94e16834a6d4c54842f (diff) | |
download | busybox-w32-4168fdd8e6f5ad4d41a30a2350dbd635cc0fa6e1.tar.gz busybox-w32-4168fdd8e6f5ad4d41a30a2350dbd635cc0fa6e1.tar.bz2 busybox-w32-4168fdd8e6f5ad4d41a30a2350dbd635cc0fa6e1.zip |
ntpd: add -w "watch" option, useful for debugging to look at our own data
Also fixed a small buglet discovered using -w
function old new delta
recv_and_process_peer_pkt 895 944 +49
select_and_cluster 1132 1150 +18
packed_usage 26769 26767 -2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'networking/ntpd.c')
-rw-r--r-- | networking/ntpd.c | 39 |
1 files changed, 26 insertions, 13 deletions
diff --git a/networking/ntpd.c b/networking/ntpd.c index 771a75a69..84ee54307 100644 --- a/networking/ntpd.c +++ b/networking/ntpd.c | |||
@@ -192,8 +192,9 @@ enum { | |||
192 | OPT_x = (1 << 3), | 192 | OPT_x = (1 << 3), |
193 | /* Insert new options above this line. */ | 193 | /* Insert new options above this line. */ |
194 | /* Non-compat options: */ | 194 | /* Non-compat options: */ |
195 | OPT_p = (1 << 4), | 195 | OPT_w = (1 << 4), |
196 | OPT_l = (1 << 5) * ENABLE_FEATURE_NTPD_SERVER, | 196 | OPT_p = (1 << 5), |
197 | OPT_l = (1 << 6) * ENABLE_FEATURE_NTPD_SERVER, | ||
197 | }; | 198 | }; |
198 | 199 | ||
199 | struct globals { | 200 | struct globals { |
@@ -940,7 +941,7 @@ select_and_cluster(void) | |||
940 | double min_jitter = min_jitter; | 941 | double min_jitter = min_jitter; |
941 | 942 | ||
942 | if (num_survivors <= MIN_CLUSTERED) { | 943 | if (num_survivors <= MIN_CLUSTERED) { |
943 | bb_error_msg("num_survivors %d <= %d, not discarding more", | 944 | VERB3 bb_error_msg("num_survivors %d <= %d, not discarding more", |
944 | num_survivors, MIN_CLUSTERED); | 945 | num_survivors, MIN_CLUSTERED); |
945 | break; | 946 | break; |
946 | } | 947 | } |
@@ -1381,8 +1382,8 @@ recv_and_process_peer_pkt(peer_t *p) | |||
1381 | || errno == EAGAIN | 1382 | || errno == EAGAIN |
1382 | ) { | 1383 | ) { |
1383 | //TODO: always do this? | 1384 | //TODO: always do this? |
1384 | set_next(p, retry_interval()); | 1385 | interval = retry_interval(); |
1385 | goto close_sock; | 1386 | goto set_next_and_close_sock; |
1386 | } | 1387 | } |
1387 | xfunc_die(); | 1388 | xfunc_die(); |
1388 | } | 1389 | } |
@@ -1407,7 +1408,7 @@ recv_and_process_peer_pkt(peer_t *p) | |||
1407 | // "RATE" - peer is overloaded, reduce polling freq | 1408 | // "RATE" - peer is overloaded, reduce polling freq |
1408 | interval = poll_interval(0); | 1409 | interval = poll_interval(0); |
1409 | bb_error_msg("reply from %s: not synced, next query in %us", p->p_dotted, interval); | 1410 | bb_error_msg("reply from %s: not synced, next query in %us", p->p_dotted, interval); |
1410 | goto close_sock; | 1411 | goto set_next_and_close_sock; |
1411 | } | 1412 | } |
1412 | 1413 | ||
1413 | // /* Verify valid root distance */ | 1414 | // /* Verify valid root distance */ |
@@ -1466,18 +1467,30 @@ recv_and_process_peer_pkt(peer_t *p) | |||
1466 | 1467 | ||
1467 | p->reachable_bits |= 1; | 1468 | p->reachable_bits |= 1; |
1468 | VERB1 { | 1469 | VERB1 { |
1469 | bb_error_msg("reply from %s: reach 0x%02x offset %f delay %f", | 1470 | bb_error_msg("reply from %s: reach 0x%02x offset %f delay %f status 0x%02x strat %d refid 0x%08x rootdelay %f", |
1470 | p->p_dotted, | 1471 | p->p_dotted, |
1471 | p->reachable_bits, | 1472 | p->reachable_bits, |
1472 | datapoint->d_offset, p->lastpkt_delay); | 1473 | datapoint->d_offset, |
1474 | p->lastpkt_delay, | ||
1475 | p->lastpkt_status, | ||
1476 | p->lastpkt_stratum, | ||
1477 | p->lastpkt_refid, | ||
1478 | p->lastpkt_rootdelay | ||
1479 | /* not shown: m_ppoll, m_precision_exp, m_rootdisp, | ||
1480 | * m_reftime, m_orgtime, m_rectime, m_xmttime | ||
1481 | */ | ||
1482 | ); | ||
1473 | } | 1483 | } |
1474 | 1484 | ||
1475 | /* Muck with statictics and update the clock */ | 1485 | /* Muck with statictics and update the clock */ |
1476 | filter_datapoints(p); | 1486 | filter_datapoints(p); |
1477 | q = select_and_cluster(); | 1487 | q = select_and_cluster(); |
1478 | rc = -1; | 1488 | rc = -1; |
1479 | if (q) | 1489 | if (q) { |
1480 | rc = update_local_clock(q); | 1490 | rc = 0; |
1491 | if (!(option_mask32 & OPT_w)) | ||
1492 | rc = update_local_clock(q); | ||
1493 | } | ||
1481 | 1494 | ||
1482 | if (rc != 0) { | 1495 | if (rc != 0) { |
1483 | /* Adjust the poll interval by comparing the current offset | 1496 | /* Adjust the poll interval by comparing the current offset |
@@ -1537,9 +1550,9 @@ recv_and_process_peer_pkt(peer_t *p) | |||
1537 | 1550 | ||
1538 | /* Decide when to send new query for this peer */ | 1551 | /* Decide when to send new query for this peer */ |
1539 | interval = poll_interval(0); | 1552 | interval = poll_interval(0); |
1540 | set_next(p, interval); | ||
1541 | 1553 | ||
1542 | close_sock: | 1554 | set_next_and_close_sock: |
1555 | set_next(p, interval); | ||
1543 | /* We do not expect any more packets from this peer for now. | 1556 | /* We do not expect any more packets from this peer for now. |
1544 | * Closing the socket informs kernel about it. | 1557 | * Closing the socket informs kernel about it. |
1545 | * We open a new socket when we send a new query. | 1558 | * We open a new socket when we send a new query. |
@@ -1723,7 +1736,7 @@ static NOINLINE void ntp_init(char **argv) | |||
1723 | opt_complementary = "dd:p::"; /* d: counter, p: list */ | 1736 | opt_complementary = "dd:p::"; /* d: counter, p: list */ |
1724 | opts = getopt32(argv, | 1737 | opts = getopt32(argv, |
1725 | "nqNx" /* compat */ | 1738 | "nqNx" /* compat */ |
1726 | "p:"IF_FEATURE_NTPD_SERVER("l") /* NOT compat */ | 1739 | "wp:"IF_FEATURE_NTPD_SERVER("l") /* NOT compat */ |
1727 | "d" /* compat */ | 1740 | "d" /* compat */ |
1728 | "46aAbgL", /* compat, ignored */ | 1741 | "46aAbgL", /* compat, ignored */ |
1729 | &peers, &G.verbose); | 1742 | &peers, &G.verbose); |