[PATCH 1/2] ntpd: retry name-resolution until success

Mark O'Donovan shiftee at eircom.net
Thu Feb 4 13:43:16 UTC 2016


Fixes bug 8131
Note: process will not daemonise until name is resolved
---
 networking/ntpd.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/networking/ntpd.c b/networking/ntpd.c
index 9732c9b..3273cdd 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -766,7 +766,14 @@ add_peers(const char *s)
 	peer_t *p;
 
 	p = xzalloc(sizeof(*p));
-	p->p_lsa = xhost2sockaddr(s, 123);
+
+	/* loop until ip is resolved */
+	while (true) {
+		p->p_lsa = host2sockaddr(s, 123);
+		if( p->p_lsa != NULL )
+			break;
+		sleep(1);
+	}
 	p->p_dotted = xmalloc_sockaddr2dotted_noport(&p->p_lsa->u.sa);
 	p->p_fd = -1;
 	p->p_xmt_msg.m_status = MODE_CLIENT | (NTP_VERSION << 3);
-- 
1.9.1



More information about the busybox mailing list