From: Hal Murray Date: Mon, 30 Nov 2009 04:36:52 +0000 (-0500) Subject: ntp_intres.c, ChangeLog: X-Git-Tag: NTP_4_2_5P250_RC~4^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d894e9ff542ada5bc8065423b140dcfa50ff0e99;p=thirdparty%2Fntp.git ntp_intres.c, ChangeLog: Fix for bug 1386: Deferred DNS doesn't work on NetBSD bk: 4b134be4iLsbZHQ4-52aQ7I8-5rdXA --- diff --git a/ChangeLog b/ChangeLog index 8b19a0041..7322dd9a0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,4 @@ +* [Bug 1386] Deferred DNS doesn't work on NetBSD * [Bug 761] internal resolver does not seem to honor -4/-6 qualifiers * Pass no_needed to ntp_intres as first part of fixing Bug 975. * Add --enable-force-defer-DNS to help debugging. diff --git a/ntpd/ntp_intres.c b/ntpd/ntp_intres.c index 0ca876be0..bf13faa9a 100644 --- a/ntpd/ntp_intres.c +++ b/ntpd/ntp_intres.c @@ -230,9 +230,10 @@ ntp_intres(void) #ifdef SYS_WINNT DWORD rc; #else - int rc; - struct timeval tv; - fd_set fdset; + int rc; + struct timeval tv; + fd_set fdset; + int time_left; #endif #ifdef DEBUG @@ -323,20 +324,35 @@ ntp_intres(void) resolver_exit(1); #else /* not SYS_WINNT */ - tv.tv_sec = ALARM_TIME; - tv.tv_usec = 0; - FD_ZERO(&fdset); - FD_SET(resolver_pipe_fd[0], &fdset); - rc = select(resolver_pipe_fd[0] + 1, &fdset, (fd_set *)0, (fd_set *)0, &tv); + /* Bug 1386: fork() in NetBSD leaves timers running. */ + /* So we need to retry select on EINTR */ + time_left = ALARM_TIME; + while (time_left > 0) { + tv.tv_sec = time_left; + tv.tv_usec = 0; + FD_ZERO(&fdset); + FD_SET(resolver_pipe_fd[0], &fdset); + rc = select(resolver_pipe_fd[0] + 1, &fdset, (fd_set *)0, (fd_set *)0, &tv); + + if (rc == 0) /* normal timeout */ + break; - if (rc > 0) { /* parent process has written to the pipe */ + if (rc > 0) { /* parent process has written to the pipe */ read(resolver_pipe_fd[0], (char *)&rc, sizeof(rc)); /* make pipe empty */ resolve_timer = 0; /* retry resolving immediately */ - continue; - } + break; + } - if ( rc < 0 ) /* select() returned error */ + if ( rc < 0 ) { /* select() returned error */ + if (errno == EINTR) { /* Timer went off */ + time_left -= (1<