diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2017-10-31 16:53:23 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2017-10-31 16:53:23 +0100 |
commit | d5c1482fbac71c51e3add52632cdf1f9f9e6661b (patch) | |
tree | d03c559bb5cde43f1101c0a66b3b69fdc3843585 | |
parent | f1fdda45423a0133094840c0367aef1b026635d5 (diff) | |
download | busybox-w32-d5c1482fbac71c51e3add52632cdf1f9f9e6661b.tar.gz busybox-w32-d5c1482fbac71c51e3add52632cdf1f9f9e6661b.tar.bz2 busybox-w32-d5c1482fbac71c51e3add52632cdf1f9f9e6661b.zip |
ntpd: skip over setting next DNS resolution attempt if it is not needed
function old new delta
ntpd_main 1177 1197 +20
resolve_peer_hostname 127 129 +2
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | networking/ntpd.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/networking/ntpd.c b/networking/ntpd.c index add282b1d..0b60d003b 100644 --- a/networking/ntpd.c +++ b/networking/ntpd.c | |||
@@ -805,6 +805,7 @@ resolve_peer_hostname(peer_t *p) | |||
805 | VERB1 if (strcmp(p->p_hostname, p->p_dotted) != 0) | 805 | VERB1 if (strcmp(p->p_hostname, p->p_dotted) != 0) |
806 | bb_error_msg("'%s' is %s", p->p_hostname, p->p_dotted); | 806 | bb_error_msg("'%s' is %s", p->p_hostname, p->p_dotted); |
807 | p->dns_errors = 0; | 807 | p->dns_errors = 0; |
808 | return lsa; | ||
808 | } | 809 | } |
809 | p->dns_errors = ((p->dns_errors << 1) | 1) & DNS_ERRORS_CAP; | 810 | p->dns_errors = ((p->dns_errors << 1) | 1) & DNS_ERRORS_CAP; |
810 | return lsa; | 811 | return lsa; |
@@ -2441,6 +2442,7 @@ int ntpd_main(int argc UNUSED_PARAM, char **argv) | |||
2441 | gettime1900d(); /* sets G.cur_time */ | 2442 | gettime1900d(); /* sets G.cur_time */ |
2442 | if (nfds <= 0) { | 2443 | if (nfds <= 0) { |
2443 | double ct; | 2444 | double ct; |
2445 | int dns_error; | ||
2444 | 2446 | ||
2445 | if (bb_got_signal) | 2447 | if (bb_got_signal) |
2446 | break; /* poll was interrupted by a signal */ | 2448 | break; /* poll was interrupted by a signal */ |
@@ -2456,16 +2458,19 @@ int ntpd_main(int argc UNUSED_PARAM, char **argv) | |||
2456 | * this way, we almost never overlap DNS resolution with | 2458 | * this way, we almost never overlap DNS resolution with |
2457 | * "request-reply" packet round trip. | 2459 | * "request-reply" packet round trip. |
2458 | */ | 2460 | */ |
2461 | dns_error = 0; | ||
2459 | ct = G.cur_time; | 2462 | ct = G.cur_time; |
2460 | for (item = G.ntp_peers; item != NULL; item = item->link) { | 2463 | for (item = G.ntp_peers; item != NULL; item = item->link) { |
2461 | peer_t *p = (peer_t *) item->data; | 2464 | peer_t *p = (peer_t *) item->data; |
2462 | if (p->next_action_time <= ct && !p->p_lsa) { | 2465 | if (p->next_action_time <= ct && !p->p_lsa) { |
2463 | /* This can take up to ~10 sec per each DNS query */ | 2466 | /* This can take up to ~10 sec per each DNS query */ |
2464 | resolve_peer_hostname(p); | 2467 | dns_error |= (!resolve_peer_hostname(p)); |
2465 | } | 2468 | } |
2466 | } | 2469 | } |
2467 | gettime1900d(); /* sets G.cur_time (needed for set_next()) */ | 2470 | if (!dns_error) |
2471 | goto check_unsync; | ||
2468 | /* Set next time for those which are still not resolved */ | 2472 | /* Set next time for those which are still not resolved */ |
2473 | gettime1900d(); /* sets G.cur_time (needed for set_next()) */ | ||
2469 | for (item = G.ntp_peers; item != NULL; item = item->link) { | 2474 | for (item = G.ntp_peers; item != NULL; item = item->link) { |
2470 | peer_t *p = (peer_t *) item->data; | 2475 | peer_t *p = (peer_t *) item->data; |
2471 | if (p->next_action_time <= ct && !p->p_lsa) { | 2476 | if (p->next_action_time <= ct && !p->p_lsa) { |