[PATCH 2/2] ntpd: daemonise before adding peers

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


Command otherwise may hang indefinately if unable to resolve peers.
---
 networking/ntpd.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/networking/ntpd.c b/networking/ntpd.c
index 3273cdd..25e19f8 100644
--- a/networking/ntpd.c
+++ b/networking/ntpd.c
@@ -2152,6 +2152,11 @@ static NOINLINE void ntp_init(char **argv)
 #endif
 			&G.verbose);
 
+	if (!(opts & OPT_n)) {
+		bb_daemonize_or_rexec(DAEMON_DEVNULL_STDIO, argv);
+		logmode = LOGMODE_NONE;
+	}
+
 //	if (opts & OPT_x) /* disable stepping, only slew is allowed */
 //		G.time_was_stepped = 1;
 	if (peers) {
@@ -2194,10 +2199,6 @@ static NOINLINE void ntp_init(char **argv)
 		setsockopt_int(G_listen_fd, IPPROTO_IP, IP_TOS, IPTOS_LOWDELAY);
 	}
 #endif
-	if (!(opts & OPT_n)) {
-		bb_daemonize_or_rexec(DAEMON_DEVNULL_STDIO, argv);
-		logmode = LOGMODE_NONE;
-	}
 	/* I hesitate to set -20 prio. -15 should be high enough for timekeeping */
 	if (opts & OPT_N)
 		setpriority(PRIO_PROCESS, 0, -15);
-- 
1.9.1



More information about the busybox mailing list