aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-10-28 17:54:24 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-10-28 17:56:43 +0200
commita1e9bc6876f6539805095e9395c604d3675c526d (patch)
tree8e179a204ebceb2415e9f43e0d0a81f3b48d0bdf
parentecce3a1999f3c5ded4baebbc0b17c48d80fe2781 (diff)
downloadbusybox-a1e9bc6876f6539805095e9395c604d3675c526d.tar.gz
ntpd: perform DNS resolution out of send/receive loop - closes 10466
Bad case: send request to server1good.com; then try to resolve server2bad.com - this fails, and failure takes ~5 secs; then receive server1's response 5 seconds later. We'll never sync up in this case... function old new delta ntpd_main 1079 1106 +27 Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--networking/ntpd.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/networking/ntpd.c b/networking/ntpd.c
index 4f881eaf9..8f792d16d 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -866,10 +866,8 @@ do_sendto(int fd,
static void
send_query_to_peer(peer_t *p)
{
- if (!p->p_lsa) {
- if (!resolve_peer_hostname(p))
- return;
- }
+ if (!p->p_lsa)
+ return;
/* Why do we need to bind()?
* See what happens when we don't bind:
@@ -2360,6 +2358,14 @@ int ntpd_main(int argc UNUSED_PARAM, char **argv)
int nfds, timeout;
double nextaction;
+ /* Resolve peer names to IPs, if not resolved yet */
+ for (item = G.ntp_peers; item != NULL; item = item->link) {
+ peer_t *p = (peer_t *) item->data;
+
+ if (p->next_action_time <= G.cur_time && !p->p_lsa)
+ resolve_peer_hostname(p);
+ }
+
/* Nothing between here and poll() blocks for any significant time */
nextaction = G.cur_time + 3600;