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>
This commit is contained in:
parent
f1fdda4542
commit
d5c1482fba
@ -805,6 +805,7 @@ resolve_peer_hostname(peer_t *p)
|
|||||||
VERB1 if (strcmp(p->p_hostname, p->p_dotted) != 0)
|
VERB1 if (strcmp(p->p_hostname, p->p_dotted) != 0)
|
||||||
bb_error_msg("'%s' is %s", p->p_hostname, p->p_dotted);
|
bb_error_msg("'%s' is %s", p->p_hostname, p->p_dotted);
|
||||||
p->dns_errors = 0;
|
p->dns_errors = 0;
|
||||||
|
return lsa;
|
||||||
}
|
}
|
||||||
p->dns_errors = ((p->dns_errors << 1) | 1) & DNS_ERRORS_CAP;
|
p->dns_errors = ((p->dns_errors << 1) | 1) & DNS_ERRORS_CAP;
|
||||||
return lsa;
|
return lsa;
|
||||||
@ -2441,6 +2442,7 @@ int ntpd_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
gettime1900d(); /* sets G.cur_time */
|
gettime1900d(); /* sets G.cur_time */
|
||||||
if (nfds <= 0) {
|
if (nfds <= 0) {
|
||||||
double ct;
|
double ct;
|
||||||
|
int dns_error;
|
||||||
|
|
||||||
if (bb_got_signal)
|
if (bb_got_signal)
|
||||||
break; /* poll was interrupted by a signal */
|
break; /* poll was interrupted by a signal */
|
||||||
@ -2456,16 +2458,19 @@ int ntpd_main(int argc UNUSED_PARAM, char **argv)
|
|||||||
* this way, we almost never overlap DNS resolution with
|
* this way, we almost never overlap DNS resolution with
|
||||||
* "request-reply" packet round trip.
|
* "request-reply" packet round trip.
|
||||||
*/
|
*/
|
||||||
|
dns_error = 0;
|
||||||
ct = G.cur_time;
|
ct = G.cur_time;
|
||||||
for (item = G.ntp_peers; item != NULL; item = item->link) {
|
for (item = G.ntp_peers; item != NULL; item = item->link) {
|
||||||
peer_t *p = (peer_t *) item->data;
|
peer_t *p = (peer_t *) item->data;
|
||||||
if (p->next_action_time <= ct && !p->p_lsa) {
|
if (p->next_action_time <= ct && !p->p_lsa) {
|
||||||
/* This can take up to ~10 sec per each DNS query */
|
/* This can take up to ~10 sec per each DNS query */
|
||||||
resolve_peer_hostname(p);
|
dns_error |= (!resolve_peer_hostname(p));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
gettime1900d(); /* sets G.cur_time (needed for set_next()) */
|
if (!dns_error)
|
||||||
|
goto check_unsync;
|
||||||
/* Set next time for those which are still not resolved */
|
/* Set next time for those which are still not resolved */
|
||||||
|
gettime1900d(); /* sets G.cur_time (needed for set_next()) */
|
||||||
for (item = G.ntp_peers; item != NULL; item = item->link) {
|
for (item = G.ntp_peers; item != NULL; item = item->link) {
|
||||||
peer_t *p = (peer_t *) item->data;
|
peer_t *p = (peer_t *) item->data;
|
||||||
if (p->next_action_time <= ct && !p->p_lsa) {
|
if (p->next_action_time <= ct && !p->p_lsa) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user