diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2013-12-04 16:32:09 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2013-12-04 16:32:09 +0100 |
commit | a14958c69da798e2284e8ab29492bdbdd52a2278 (patch) | |
tree | ce342918f76f643aed5780512cc5670558580f66 | |
parent | cb1dc1d1d1c0132636454ecfdb6cac3eade323e6 (diff) | |
download | busybox-w32-a14958c69da798e2284e8ab29492bdbdd52a2278.tar.gz busybox-w32-a14958c69da798e2284e8ab29492bdbdd52a2278.tar.bz2 busybox-w32-a14958c69da798e2284e8ab29492bdbdd52a2278.zip |
ntpd: promote log level 3 to production
Without it, peer selection logic is hard to debug
function old new delta
update_local_clock 861 982 +121
select_and_cluster 962 1065 +103
common_ping_main 1788 1821 +33
huft_build 1287 1296 +9
chpst_main 708 704 -4
INET6_resolve 127 119 -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 4/2 up/down: 266/-12) Total: 254 bytes
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/ntpd.c | 99 |
1 files changed, 54 insertions, 45 deletions
diff --git a/networking/ntpd.c b/networking/ntpd.c index 13cca3e77..aeef0431a 100644 --- a/networking/ntpd.c +++ b/networking/ntpd.c | |||
@@ -57,10 +57,10 @@ | |||
57 | 57 | ||
58 | 58 | ||
59 | /* Verbosity control (max level of -dddd options accepted). | 59 | /* Verbosity control (max level of -dddd options accepted). |
60 | * max 5 is very talkative (and bloated). 2 is non-bloated, | 60 | * max 6 is very talkative (and bloated). 3 is non-bloated, |
61 | * production level setting. | 61 | * production level setting. |
62 | */ | 62 | */ |
63 | #define MAX_VERBOSE 2 | 63 | #define MAX_VERBOSE 3 |
64 | 64 | ||
65 | 65 | ||
66 | /* High-level description of the algorithm: | 66 | /* High-level description of the algorithm: |
@@ -367,6 +367,7 @@ static const int const_IPTOS_LOWDELAY = IPTOS_LOWDELAY; | |||
367 | #define VERB3 if (MAX_VERBOSE >= 3 && G.verbose >= 3) | 367 | #define VERB3 if (MAX_VERBOSE >= 3 && G.verbose >= 3) |
368 | #define VERB4 if (MAX_VERBOSE >= 4 && G.verbose >= 4) | 368 | #define VERB4 if (MAX_VERBOSE >= 4 && G.verbose >= 4) |
369 | #define VERB5 if (MAX_VERBOSE >= 5 && G.verbose >= 5) | 369 | #define VERB5 if (MAX_VERBOSE >= 5 && G.verbose >= 5) |
370 | #define VERB6 if (MAX_VERBOSE >= 6 && G.verbose >= 6) | ||
370 | 371 | ||
371 | 372 | ||
372 | static double LOG2D(int a) | 373 | static double LOG2D(int a) |
@@ -568,7 +569,7 @@ filter_datapoints(peer_t *p) | |||
568 | got_newest = 0; | 569 | got_newest = 0; |
569 | sum = 0; | 570 | sum = 0; |
570 | for (i = 0; i < NUM_DATAPOINTS; i++) { | 571 | for (i = 0; i < NUM_DATAPOINTS; i++) { |
571 | VERB4 { | 572 | VERB5 { |
572 | bb_error_msg("datapoint[%d]: off:%f disp:%f(%f) age:%f%s", | 573 | bb_error_msg("datapoint[%d]: off:%f disp:%f(%f) age:%f%s", |
573 | i, | 574 | i, |
574 | fdp[idx].d_offset, | 575 | fdp[idx].d_offset, |
@@ -665,7 +666,7 @@ filter_datapoints(peer_t *p) | |||
665 | sum = SQRT(sum / NUM_DATAPOINTS); | 666 | sum = SQRT(sum / NUM_DATAPOINTS); |
666 | p->filter_jitter = sum > G_precision_sec ? sum : G_precision_sec; | 667 | p->filter_jitter = sum > G_precision_sec ? sum : G_precision_sec; |
667 | 668 | ||
668 | VERB3 bb_error_msg("filter offset:%+f disp:%f jitter:%f", | 669 | VERB4 bb_error_msg("filter offset:%+f disp:%f jitter:%f", |
669 | p->filter_offset, | 670 | p->filter_offset, |
670 | p->filter_dispersion, | 671 | p->filter_dispersion, |
671 | p->filter_jitter); | 672 | p->filter_jitter); |
@@ -700,7 +701,7 @@ reset_peer_stats(peer_t *p, double offset) | |||
700 | p->lastpkt_recv_time = G.cur_time; | 701 | p->lastpkt_recv_time = G.cur_time; |
701 | } | 702 | } |
702 | filter_datapoints(p); /* recalc p->filter_xxx */ | 703 | filter_datapoints(p); /* recalc p->filter_xxx */ |
703 | VERB5 bb_error_msg("%s->lastpkt_recv_time=%f", p->p_dotted, p->lastpkt_recv_time); | 704 | VERB6 bb_error_msg("%s->lastpkt_recv_time=%f", p->p_dotted, p->lastpkt_recv_time); |
704 | } | 705 | } |
705 | 706 | ||
706 | static void | 707 | static void |
@@ -972,20 +973,20 @@ fit(peer_t *p, double rd) | |||
972 | { | 973 | { |
973 | if ((p->reachable_bits & (p->reachable_bits-1)) == 0) { | 974 | if ((p->reachable_bits & (p->reachable_bits-1)) == 0) { |
974 | /* One or zero bits in reachable_bits */ | 975 | /* One or zero bits in reachable_bits */ |
975 | VERB3 bb_error_msg("peer %s unfit for selection: unreachable", p->p_dotted); | 976 | VERB4 bb_error_msg("peer %s unfit for selection: unreachable", p->p_dotted); |
976 | return 0; | 977 | return 0; |
977 | } | 978 | } |
978 | #if 0 /* we filter out such packets earlier */ | 979 | #if 0 /* we filter out such packets earlier */ |
979 | if ((p->lastpkt_status & LI_ALARM) == LI_ALARM | 980 | if ((p->lastpkt_status & LI_ALARM) == LI_ALARM |
980 | || p->lastpkt_stratum >= MAXSTRAT | 981 | || p->lastpkt_stratum >= MAXSTRAT |
981 | ) { | 982 | ) { |
982 | VERB3 bb_error_msg("peer %s unfit for selection: bad status/stratum", p->p_dotted); | 983 | VERB4 bb_error_msg("peer %s unfit for selection: bad status/stratum", p->p_dotted); |
983 | return 0; | 984 | return 0; |
984 | } | 985 | } |
985 | #endif | 986 | #endif |
986 | /* rd is root_distance(p) */ | 987 | /* rd is root_distance(p) */ |
987 | if (rd > MAXDIST + FREQ_TOLERANCE * (1 << G.poll_exp)) { | 988 | if (rd > MAXDIST + FREQ_TOLERANCE * (1 << G.poll_exp)) { |
988 | VERB3 bb_error_msg("peer %s unfit for selection: root distance too high", p->p_dotted); | 989 | VERB4 bb_error_msg("peer %s unfit for selection: root distance too high", p->p_dotted); |
989 | return 0; | 990 | return 0; |
990 | } | 991 | } |
991 | //TODO | 992 | //TODO |
@@ -1025,7 +1026,7 @@ select_and_cluster(void) | |||
1025 | continue; | 1026 | continue; |
1026 | } | 1027 | } |
1027 | 1028 | ||
1028 | VERB4 bb_error_msg("interval: [%f %f %f] %s", | 1029 | VERB5 bb_error_msg("interval: [%f %f %f] %s", |
1029 | offset - rd, | 1030 | offset - rd, |
1030 | offset, | 1031 | offset, |
1031 | offset + rd, | 1032 | offset + rd, |
@@ -1050,7 +1051,7 @@ select_and_cluster(void) | |||
1050 | } | 1051 | } |
1051 | num_candidates = num_points / 3; | 1052 | num_candidates = num_points / 3; |
1052 | if (num_candidates == 0) { | 1053 | if (num_candidates == 0) { |
1053 | VERB3 bb_error_msg("no valid datapoints, no peer selected"); | 1054 | VERB3 bb_error_msg("no valid datapoints%s", ", no peer selected"); |
1054 | return NULL; | 1055 | return NULL; |
1055 | } | 1056 | } |
1056 | //TODO: sorting does not seem to be done in reference code | 1057 | //TODO: sorting does not seem to be done in reference code |
@@ -1108,12 +1109,13 @@ select_and_cluster(void) | |||
1108 | break; | 1109 | break; |
1109 | num_falsetickers++; | 1110 | num_falsetickers++; |
1110 | if (num_falsetickers * 2 >= num_candidates) { | 1111 | if (num_falsetickers * 2 >= num_candidates) { |
1111 | VERB3 bb_error_msg("too many falsetickers:%d (candidates:%d), no peer selected", | 1112 | VERB3 bb_error_msg("falsetickers:%d, candidates:%d%s", |
1112 | num_falsetickers, num_candidates); | 1113 | num_falsetickers, num_candidates, |
1114 | ", no peer selected"); | ||
1113 | return NULL; | 1115 | return NULL; |
1114 | } | 1116 | } |
1115 | } | 1117 | } |
1116 | VERB3 bb_error_msg("selected interval: [%f, %f]; candidates:%d falsetickers:%d", | 1118 | VERB4 bb_error_msg("selected interval: [%f, %f]; candidates:%d falsetickers:%d", |
1117 | low, high, num_candidates, num_falsetickers); | 1119 | low, high, num_candidates, num_falsetickers); |
1118 | 1120 | ||
1119 | /* Clustering */ | 1121 | /* Clustering */ |
@@ -1131,7 +1133,7 @@ select_and_cluster(void) | |||
1131 | survivor[num_survivors].p = p; | 1133 | survivor[num_survivors].p = p; |
1132 | /* x.opt_rd == root_distance(p); */ | 1134 | /* x.opt_rd == root_distance(p); */ |
1133 | survivor[num_survivors].metric = MAXDIST * p->lastpkt_stratum + point[i].opt_rd; | 1135 | survivor[num_survivors].metric = MAXDIST * p->lastpkt_stratum + point[i].opt_rd; |
1134 | VERB4 bb_error_msg("survivor[%d] metric:%f peer:%s", | 1136 | VERB5 bb_error_msg("survivor[%d] metric:%f peer:%s", |
1135 | num_survivors, survivor[num_survivors].metric, p->p_dotted); | 1137 | num_survivors, survivor[num_survivors].metric, p->p_dotted); |
1136 | num_survivors++; | 1138 | num_survivors++; |
1137 | } | 1139 | } |
@@ -1141,8 +1143,9 @@ select_and_cluster(void) | |||
1141 | * is acceptable. | 1143 | * is acceptable. |
1142 | */ | 1144 | */ |
1143 | if (num_survivors < MIN_SELECTED) { | 1145 | if (num_survivors < MIN_SELECTED) { |
1144 | VERB3 bb_error_msg("num_survivors %d < %d, no peer selected", | 1146 | VERB3 bb_error_msg("survivors:%d%s", |
1145 | num_survivors, MIN_SELECTED); | 1147 | num_survivors, |
1148 | ", no peer selected"); | ||
1146 | return NULL; | 1149 | return NULL; |
1147 | } | 1150 | } |
1148 | 1151 | ||
@@ -1162,7 +1165,7 @@ select_and_cluster(void) | |||
1162 | double min_jitter = min_jitter; | 1165 | double min_jitter = min_jitter; |
1163 | 1166 | ||
1164 | if (num_survivors <= MIN_CLUSTERED) { | 1167 | if (num_survivors <= MIN_CLUSTERED) { |
1165 | VERB3 bb_error_msg("num_survivors %d <= %d, not discarding more", | 1168 | VERB4 bb_error_msg("num_survivors %d <= %d, not discarding more", |
1166 | num_survivors, MIN_CLUSTERED); | 1169 | num_survivors, MIN_CLUSTERED); |
1167 | break; | 1170 | break; |
1168 | } | 1171 | } |
@@ -1188,11 +1191,11 @@ select_and_cluster(void) | |||
1188 | max_selection_jitter = selection_jitter_sq; | 1191 | max_selection_jitter = selection_jitter_sq; |
1189 | max_idx = i; | 1192 | max_idx = i; |
1190 | } | 1193 | } |
1191 | VERB5 bb_error_msg("survivor %d selection_jitter^2:%f", | 1194 | VERB6 bb_error_msg("survivor %d selection_jitter^2:%f", |
1192 | i, selection_jitter_sq); | 1195 | i, selection_jitter_sq); |
1193 | } | 1196 | } |
1194 | max_selection_jitter = SQRT(max_selection_jitter / num_survivors); | 1197 | max_selection_jitter = SQRT(max_selection_jitter / num_survivors); |
1195 | VERB4 bb_error_msg("max_selection_jitter (at %d):%f min_jitter:%f", | 1198 | VERB5 bb_error_msg("max_selection_jitter (at %d):%f min_jitter:%f", |
1196 | max_idx, max_selection_jitter, min_jitter); | 1199 | max_idx, max_selection_jitter, min_jitter); |
1197 | 1200 | ||
1198 | /* If the maximum selection jitter is less than the | 1201 | /* If the maximum selection jitter is less than the |
@@ -1201,7 +1204,7 @@ select_and_cluster(void) | |||
1201 | * as well stop. | 1204 | * as well stop. |
1202 | */ | 1205 | */ |
1203 | if (max_selection_jitter < min_jitter) { | 1206 | if (max_selection_jitter < min_jitter) { |
1204 | VERB3 bb_error_msg("max_selection_jitter:%f < min_jitter:%f, num_survivors:%d, not discarding more", | 1207 | VERB4 bb_error_msg("max_selection_jitter:%f < min_jitter:%f, num_survivors:%d, not discarding more", |
1205 | max_selection_jitter, min_jitter, num_survivors); | 1208 | max_selection_jitter, min_jitter, num_survivors); |
1206 | break; | 1209 | break; |
1207 | } | 1210 | } |
@@ -1209,7 +1212,7 @@ select_and_cluster(void) | |||
1209 | /* Delete survivor[max_idx] from the list | 1212 | /* Delete survivor[max_idx] from the list |
1210 | * and go around again. | 1213 | * and go around again. |
1211 | */ | 1214 | */ |
1212 | VERB5 bb_error_msg("dropping survivor %d", max_idx); | 1215 | VERB6 bb_error_msg("dropping survivor %d", max_idx); |
1213 | num_survivors--; | 1216 | num_survivors--; |
1214 | while (max_idx < num_survivors) { | 1217 | while (max_idx < num_survivors) { |
1215 | survivor[max_idx] = survivor[max_idx + 1]; | 1218 | survivor[max_idx] = survivor[max_idx + 1]; |
@@ -1251,7 +1254,7 @@ select_and_cluster(void) | |||
1251 | /* Starting from 1 is ok here */ | 1254 | /* Starting from 1 is ok here */ |
1252 | for (i = 1; i < num_survivors; i++) { | 1255 | for (i = 1; i < num_survivors; i++) { |
1253 | if (G.last_update_peer == survivor[i].p) { | 1256 | if (G.last_update_peer == survivor[i].p) { |
1254 | VERB4 bb_error_msg("keeping old synced peer"); | 1257 | VERB5 bb_error_msg("keeping old synced peer"); |
1255 | p = G.last_update_peer; | 1258 | p = G.last_update_peer; |
1256 | goto keep_old; | 1259 | goto keep_old; |
1257 | } | 1260 | } |
@@ -1259,7 +1262,7 @@ select_and_cluster(void) | |||
1259 | } | 1262 | } |
1260 | G.last_update_peer = p; | 1263 | G.last_update_peer = p; |
1261 | keep_old: | 1264 | keep_old: |
1262 | VERB3 bb_error_msg("selected peer %s filter_offset:%+f age:%f", | 1265 | VERB4 bb_error_msg("selected peer %s filter_offset:%+f age:%f", |
1263 | p->p_dotted, | 1266 | p->p_dotted, |
1264 | p->filter_offset, | 1267 | p->filter_offset, |
1265 | G.cur_time - p->lastpkt_recv_time | 1268 | G.cur_time - p->lastpkt_recv_time |
@@ -1278,7 +1281,7 @@ set_new_values(int disc_state, double offset, double recv_time) | |||
1278 | * of the last clock filter sample, which must be earlier than | 1281 | * of the last clock filter sample, which must be earlier than |
1279 | * the current time. | 1282 | * the current time. |
1280 | */ | 1283 | */ |
1281 | VERB3 bb_error_msg("disc_state=%d last update offset=%f recv_time=%f", | 1284 | VERB4 bb_error_msg("disc_state=%d last update offset=%f recv_time=%f", |
1282 | disc_state, offset, recv_time); | 1285 | disc_state, offset, recv_time); |
1283 | G.discipline_state = disc_state; | 1286 | G.discipline_state = disc_state; |
1284 | G.last_update_offset = offset; | 1287 | G.last_update_offset = offset; |
@@ -1316,8 +1319,8 @@ update_local_clock(peer_t *p) | |||
1316 | * an old sample or the same sample twice. | 1319 | * an old sample or the same sample twice. |
1317 | */ | 1320 | */ |
1318 | if (recv_time <= G.last_update_recv_time) { | 1321 | if (recv_time <= G.last_update_recv_time) { |
1319 | VERB3 bb_error_msg("same or older datapoint: %f >= %f, not using it", | 1322 | VERB3 bb_error_msg("update from %s: same or older datapoint, not using it", |
1320 | G.last_update_recv_time, recv_time); | 1323 | p->p_dotted); |
1321 | return 0; /* "leave poll interval as is" */ | 1324 | return 0; /* "leave poll interval as is" */ |
1322 | } | 1325 | } |
1323 | 1326 | ||
@@ -1333,7 +1336,7 @@ update_local_clock(peer_t *p) | |||
1333 | if (G.discipline_state == STATE_FREQ) { | 1336 | if (G.discipline_state == STATE_FREQ) { |
1334 | /* Ignore updates until the stepout threshold */ | 1337 | /* Ignore updates until the stepout threshold */ |
1335 | if (since_last_update < WATCH_THRESHOLD) { | 1338 | if (since_last_update < WATCH_THRESHOLD) { |
1336 | VERB3 bb_error_msg("measuring drift, datapoint ignored, %f sec remains", | 1339 | VERB4 bb_error_msg("measuring drift, datapoint ignored, %f sec remains", |
1337 | WATCH_THRESHOLD - since_last_update); | 1340 | WATCH_THRESHOLD - since_last_update); |
1338 | return 0; /* "leave poll interval as is" */ | 1341 | return 0; /* "leave poll interval as is" */ |
1339 | } | 1342 | } |
@@ -1349,10 +1352,15 @@ update_local_clock(peer_t *p) | |||
1349 | if (abs_offset > STEP_THRESHOLD) { | 1352 | if (abs_offset > STEP_THRESHOLD) { |
1350 | double remains; | 1353 | double remains; |
1351 | 1354 | ||
1355 | // TODO: this "spike state" seems to be useless, peer selection already drops | ||
1356 | // occassional "bad" datapoints. If we are here, there were _many_ large offsets - | ||
1357 | // looks like _our_ clock is off. | ||
1352 | switch (G.discipline_state) { | 1358 | switch (G.discipline_state) { |
1353 | case STATE_SYNC: | 1359 | case STATE_SYNC: |
1354 | /* The first outlyer: ignore it, switch to SPIK state */ | 1360 | /* The first outlyer: ignore it, switch to SPIK state */ |
1355 | VERB2 bb_error_msg("offset:%+f - spike", offset); | 1361 | VERB3 bb_error_msg("update from %s: offset:%+f, spike%s", |
1362 | p->p_dotted, offset, | ||
1363 | ""); | ||
1356 | G.discipline_state = STATE_SPIK; | 1364 | G.discipline_state = STATE_SPIK; |
1357 | return -1; /* "decrease poll interval" */ | 1365 | return -1; /* "decrease poll interval" */ |
1358 | 1366 | ||
@@ -1362,8 +1370,9 @@ update_local_clock(peer_t *p) | |||
1362 | */ | 1370 | */ |
1363 | remains = WATCH_THRESHOLD - since_last_update; | 1371 | remains = WATCH_THRESHOLD - since_last_update; |
1364 | if (remains > 0) { | 1372 | if (remains > 0) { |
1365 | VERB2 bb_error_msg("spike, datapoint ignored, %f sec remains", | 1373 | VERB3 bb_error_msg("update from %s: offset:%+f, spike%s", |
1366 | remains); | 1374 | p->p_dotted, offset, |
1375 | ", datapoint ignored"); | ||
1367 | return -1; /* "decrease poll interval" */ | 1376 | return -1; /* "decrease poll interval" */ |
1368 | } | 1377 | } |
1369 | /* fall through: we need to step */ | 1378 | /* fall through: we need to step */ |
@@ -1390,7 +1399,7 @@ update_local_clock(peer_t *p) | |||
1390 | * is always suppressed, even at the longer poll | 1399 | * is always suppressed, even at the longer poll |
1391 | * intervals. | 1400 | * intervals. |
1392 | */ | 1401 | */ |
1393 | VERB3 bb_error_msg("stepping time by %+f; poll_exp=MINPOLL", offset); | 1402 | VERB4 bb_error_msg("stepping time by %+f; poll_exp=MINPOLL", offset); |
1394 | step_time(offset); | 1403 | step_time(offset); |
1395 | if (option_mask32 & OPT_q) { | 1404 | if (option_mask32 & OPT_q) { |
1396 | /* We were only asked to set time once. Done. */ | 1405 | /* We were only asked to set time once. Done. */ |
@@ -1415,7 +1424,7 @@ update_local_clock(peer_t *p) | |||
1415 | } else { /* abs_offset <= STEP_THRESHOLD */ | 1424 | } else { /* abs_offset <= STEP_THRESHOLD */ |
1416 | 1425 | ||
1417 | if (G.poll_exp < MINPOLL && G.initial_poll_complete) { | 1426 | if (G.poll_exp < MINPOLL && G.initial_poll_complete) { |
1418 | VERB3 bb_error_msg("small offset:%+f, disabling burst mode", offset); | 1427 | VERB4 bb_error_msg("small offset:%+f, disabling burst mode", offset); |
1419 | G.polladj_count = 0; | 1428 | G.polladj_count = 0; |
1420 | G.poll_exp = MINPOLL; | 1429 | G.poll_exp = MINPOLL; |
1421 | } | 1430 | } |
@@ -1444,7 +1453,7 @@ update_local_clock(peer_t *p) | |||
1444 | #else | 1453 | #else |
1445 | set_new_values(STATE_SYNC, offset, recv_time); | 1454 | set_new_values(STATE_SYNC, offset, recv_time); |
1446 | #endif | 1455 | #endif |
1447 | VERB3 bb_error_msg("transitioning to FREQ, datapoint ignored"); | 1456 | VERB4 bb_error_msg("transitioning to FREQ, datapoint ignored"); |
1448 | return 0; /* "leave poll interval as is" */ | 1457 | return 0; /* "leave poll interval as is" */ |
1449 | 1458 | ||
1450 | #if 0 /* this is dead code for now */ | 1459 | #if 0 /* this is dead code for now */ |
@@ -1513,7 +1522,7 @@ update_local_clock(peer_t *p) | |||
1513 | dtemp = p->filter_jitter; // SQRT(SQUARE(p->filter_jitter) + SQUARE(G.cluster_jitter)); | 1522 | dtemp = p->filter_jitter; // SQRT(SQUARE(p->filter_jitter) + SQUARE(G.cluster_jitter)); |
1514 | dtemp += MAXD(p->filter_dispersion + FREQ_TOLERANCE * (G.cur_time - p->lastpkt_recv_time) + abs_offset, MINDISP); | 1523 | dtemp += MAXD(p->filter_dispersion + FREQ_TOLERANCE * (G.cur_time - p->lastpkt_recv_time) + abs_offset, MINDISP); |
1515 | G.rootdisp = p->lastpkt_rootdisp + dtemp; | 1524 | G.rootdisp = p->lastpkt_rootdisp + dtemp; |
1516 | VERB3 bb_error_msg("updating leap/refid/reftime/rootdisp from peer %s", p->p_dotted); | 1525 | VERB4 bb_error_msg("updating leap/refid/reftime/rootdisp from peer %s", p->p_dotted); |
1517 | 1526 | ||
1518 | /* We are in STATE_SYNC now, but did not do adjtimex yet. | 1527 | /* We are in STATE_SYNC now, but did not do adjtimex yet. |
1519 | * (Any other state does not reach this, they all return earlier) | 1528 | * (Any other state does not reach this, they all return earlier) |
@@ -1533,13 +1542,13 @@ update_local_clock(peer_t *p) | |||
1533 | dtemp = SQUARE(dtemp); | 1542 | dtemp = SQUARE(dtemp); |
1534 | G.discipline_wander = SQRT(etemp + (dtemp - etemp) / AVG); | 1543 | G.discipline_wander = SQRT(etemp + (dtemp - etemp) / AVG); |
1535 | 1544 | ||
1536 | VERB3 bb_error_msg("discipline freq_drift=%.9f(int:%ld corr:%e) wander=%f", | 1545 | VERB4 bb_error_msg("discipline freq_drift=%.9f(int:%ld corr:%e) wander=%f", |
1537 | G.discipline_freq_drift, | 1546 | G.discipline_freq_drift, |
1538 | (long)(G.discipline_freq_drift * 65536e6), | 1547 | (long)(G.discipline_freq_drift * 65536e6), |
1539 | freq_drift, | 1548 | freq_drift, |
1540 | G.discipline_wander); | 1549 | G.discipline_wander); |
1541 | #endif | 1550 | #endif |
1542 | VERB3 { | 1551 | VERB4 { |
1543 | memset(&tmx, 0, sizeof(tmx)); | 1552 | memset(&tmx, 0, sizeof(tmx)); |
1544 | if (adjtimex(&tmx) < 0) | 1553 | if (adjtimex(&tmx) < 0) |
1545 | bb_perror_msg_and_die("adjtimex"); | 1554 | bb_perror_msg_and_die("adjtimex"); |
@@ -1587,7 +1596,7 @@ update_local_clock(peer_t *p) | |||
1587 | /* NB: here kernel returns constant == G.poll_exp, not == G.poll_exp - 4. | 1596 | /* NB: here kernel returns constant == G.poll_exp, not == G.poll_exp - 4. |
1588 | * Not sure why. Perhaps it is normal. | 1597 | * Not sure why. Perhaps it is normal. |
1589 | */ | 1598 | */ |
1590 | VERB3 bb_error_msg("adjtimex:%d freq:%ld offset:%+ld status:0x%x", | 1599 | VERB4 bb_error_msg("adjtimex:%d freq:%ld offset:%+ld status:0x%x", |
1591 | rc, tmx.freq, tmx.offset, tmx.status); | 1600 | rc, tmx.freq, tmx.offset, tmx.status); |
1592 | G.kernel_freq_drift = tmx.freq / 65536; | 1601 | G.kernel_freq_drift = tmx.freq / 65536; |
1593 | VERB2 bb_error_msg("update from:%s offset:%+f jitter:%f clock drift:%+.3fppm tc:%d", | 1602 | VERB2 bb_error_msg("update from:%s offset:%+f jitter:%f clock drift:%+.3fppm tc:%d", |
@@ -1609,7 +1618,7 @@ retry_interval(void) | |||
1609 | interval = RETRY_INTERVAL; | 1618 | interval = RETRY_INTERVAL; |
1610 | r = random(); | 1619 | r = random(); |
1611 | interval += r % (unsigned)(RETRY_INTERVAL / 4); | 1620 | interval += r % (unsigned)(RETRY_INTERVAL / 4); |
1612 | VERB3 bb_error_msg("chose retry interval:%u", interval); | 1621 | VERB4 bb_error_msg("chose retry interval:%u", interval); |
1613 | return interval; | 1622 | return interval; |
1614 | } | 1623 | } |
1615 | static unsigned | 1624 | static unsigned |
@@ -1622,7 +1631,7 @@ poll_interval(int exponent) | |||
1622 | interval = 1 << exponent; | 1631 | interval = 1 << exponent; |
1623 | r = random(); | 1632 | r = random(); |
1624 | interval += ((r & (interval-1)) >> 4) + ((r >> 8) & 1); /* + 1/16 of interval, max */ | 1633 | interval += ((r & (interval-1)) >> 4) + ((r >> 8) & 1); /* + 1/16 of interval, max */ |
1625 | VERB3 bb_error_msg("chose poll interval:%u (poll_exp:%d exp:%d)", interval, G.poll_exp, exponent); | 1634 | VERB4 bb_error_msg("chose poll interval:%u (poll_exp:%d exp:%d)", interval, G.poll_exp, exponent); |
1626 | return interval; | 1635 | return interval; |
1627 | } | 1636 | } |
1628 | static NOINLINE void | 1637 | static NOINLINE void |
@@ -1716,7 +1725,7 @@ recv_and_process_peer_pkt(peer_t *p) | |||
1716 | T4 = G.cur_time; | 1725 | T4 = G.cur_time; |
1717 | 1726 | ||
1718 | p->lastpkt_recv_time = T4; | 1727 | p->lastpkt_recv_time = T4; |
1719 | VERB5 bb_error_msg("%s->lastpkt_recv_time=%f", p->p_dotted, p->lastpkt_recv_time); | 1728 | VERB6 bb_error_msg("%s->lastpkt_recv_time=%f", p->p_dotted, p->lastpkt_recv_time); |
1720 | 1729 | ||
1721 | /* The delay calculation is a special case. In cases where the | 1730 | /* The delay calculation is a special case. In cases where the |
1722 | * server and client clocks are running at different rates and | 1731 | * server and client clocks are running at different rates and |
@@ -1779,7 +1788,7 @@ recv_and_process_peer_pkt(peer_t *p) | |||
1779 | * drop poll interval one step down. | 1788 | * drop poll interval one step down. |
1780 | */ | 1789 | */ |
1781 | if (fabs(q->filter_offset) >= POLLDOWN_OFFSET) { | 1790 | if (fabs(q->filter_offset) >= POLLDOWN_OFFSET) { |
1782 | VERB3 bb_error_msg("offset:%+f > POLLDOWN_OFFSET", q->filter_offset); | 1791 | VERB4 bb_error_msg("offset:%+f > POLLDOWN_OFFSET", q->filter_offset); |
1783 | goto poll_down; | 1792 | goto poll_down; |
1784 | } | 1793 | } |
1785 | } | 1794 | } |
@@ -1801,11 +1810,11 @@ recv_and_process_peer_pkt(peer_t *p) | |||
1801 | G.polladj_count = 0; | 1810 | G.polladj_count = 0; |
1802 | if (G.poll_exp < MAXPOLL) { | 1811 | if (G.poll_exp < MAXPOLL) { |
1803 | G.poll_exp++; | 1812 | G.poll_exp++; |
1804 | VERB3 bb_error_msg("polladj: discipline_jitter:%f ++poll_exp=%d", | 1813 | VERB4 bb_error_msg("polladj: discipline_jitter:%f ++poll_exp=%d", |
1805 | G.discipline_jitter, G.poll_exp); | 1814 | G.discipline_jitter, G.poll_exp); |
1806 | } | 1815 | } |
1807 | } else { | 1816 | } else { |
1808 | VERB3 bb_error_msg("polladj: incr:%d", G.polladj_count); | 1817 | VERB4 bb_error_msg("polladj: incr:%d", G.polladj_count); |
1809 | } | 1818 | } |
1810 | } else { | 1819 | } else { |
1811 | G.polladj_count -= G.poll_exp * 2; | 1820 | G.polladj_count -= G.poll_exp * 2; |
@@ -1827,11 +1836,11 @@ recv_and_process_peer_pkt(peer_t *p) | |||
1827 | if (pp->p_fd < 0) | 1836 | if (pp->p_fd < 0) |
1828 | pp->next_action_time -= (1 << G.poll_exp); | 1837 | pp->next_action_time -= (1 << G.poll_exp); |
1829 | } | 1838 | } |
1830 | VERB3 bb_error_msg("polladj: discipline_jitter:%f --poll_exp=%d", | 1839 | VERB4 bb_error_msg("polladj: discipline_jitter:%f --poll_exp=%d", |
1831 | G.discipline_jitter, G.poll_exp); | 1840 | G.discipline_jitter, G.poll_exp); |
1832 | } | 1841 | } |
1833 | } else { | 1842 | } else { |
1834 | VERB3 bb_error_msg("polladj: decr:%d", G.polladj_count); | 1843 | VERB4 bb_error_msg("polladj: decr:%d", G.polladj_count); |
1835 | } | 1844 | } |
1836 | } | 1845 | } |
1837 | } | 1846 | } |