]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
ntp_intres.c, ChangeLog:
authorHal Murray <murray@ntp.org>
Mon, 30 Nov 2009 04:36:52 +0000 (23:36 -0500)
committerHal Murray <murray@ntp.org>
Mon, 30 Nov 2009 04:36:52 +0000 (23:36 -0500)
  Fix for bug 1386: Deferred DNS doesn't work on NetBSD

bk: 4b134be4iLsbZHQ4-52aQ7I8-5rdXA

ChangeLog
ntpd/ntp_intres.c

index 8b19a0041248b3abf302b895b79c3efebb6ed51b..7322dd9a0a5d6a3e18829bf2fbd28d82194d0c9d 100644 (file)
--- 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.
index 0ca876be0383dc0788f8f1a86a56ef4b28f6b41e..bf13faa9ac5044fd1d1da4c875b4020c7ac35ecc 100644 (file)
@@ -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<<EVENT_TIMEOUT);
+                           continue;           /* try again */
+                       }
+                       msyslog(LOG_ERR, "ntp_intres: Error from select: %s",
+                           strerror(errno));
                        resolver_exit(1);
+                   }
+               }
 #endif
 
                /* normal timeout, keep on waiting */