]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
ChangeLog ntpd.h, ntp_io.c:
authorFrank Kardel <kardel@ntp.org>
Sat, 3 Aug 2013 08:15:49 +0000 (08:15 +0000)
committerFrank Kardel <kardel@ntp.org>
Sat, 3 Aug 2013 08:15:49 +0000 (08:15 +0000)
  [Bug 2452] provide io_handler/input_handler only on non HAVE_IO_COMPLETION_PORT platforms

bk: 51fcbc35jGQv4On1yyaR5JKZnE_Gkg

ChangeLog
include/ntpd.h
ntpd/ntp_io.c

index 2a088bc531e166646aa89cc81ef44367f1500a93..ff175794245e5fee990b6c5e3a8d9f44a5df43f3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,5 @@
+* [Bug 2452] provide io_handler/input_handler only on
+  non HAVE_IO_COMPLETION_PORT platforms
 (4.2.7p379) 2013/08/02 Released by Harlan Stenn <stenn@ntp.org>
 * CID 739724: Fix printf arg mismatch in a debug line.
 * [Bug 2425] compile io_handler() in ntp_io.c unconditionally
index 1d3cf85e67a2432eff1211c9eaab11b30d861fa4..1d49a9961b12d618ed097167f7c133efecbf3668 100644 (file)
@@ -117,7 +117,9 @@ extern      endpt * findbcastinter          (sockaddr_u *);
 extern void    enable_broadcast        (endpt *, sockaddr_u *);
 extern void    enable_multicast_if     (endpt *, sockaddr_u *);
 extern void    interface_update        (interface_receiver_t, void *);
+#ifndef HAVE_IO_COMPLETION_PORT
 extern  void    io_handler              (void);
+#endif
 extern void    init_io         (void);
 extern void    io_open_sockets (void);
 extern void    io_clr_stats    (void);
index 58adc20a121dd525ec37ffb499f0aff366d8340d..c5701d294a5ebd17b54e86da8edff39a687cbab2 100644 (file)
@@ -187,8 +187,6 @@ static int maxactivefd;
  */
 static  u_short                sys_interphase = 0;
 
-static input_handler_t input_handler;
-
 static endpt * new_interface(endpt *);
 static void    add_interface(endpt *);
 static int     update_interfaces(u_short, interface_receiver_t,
@@ -320,6 +318,7 @@ static int          cmp_addr_distance(const sockaddr_u *,
 #if !defined(HAVE_IO_COMPLETION_PORT)
 static inline int      read_network_packet     (SOCKET, struct interface *, l_fp);
 static void            ntpd_addremove_io_fd    (int, int, int);
+static input_handler_t  input_handler;
 #ifdef REFCLOCK
 static inline int      read_refclock_packet    (SOCKET, struct refclockio *, l_fp);
 #endif
@@ -3462,6 +3461,68 @@ read_network_packet(
        return (buflen);
 }
 
+/*
+ * attempt to handle io (select()/signaled IO)
+ */
+void
+io_handler(void)
+{
+#  ifndef HAVE_SIGNALED_IO
+       fd_set rdfdes;
+       int nfound;
+
+       /*
+        * Use select() on all on all input fd's for unlimited
+        * time.  select() will terminate on SIGALARM or on the
+        * reception of input.  Using select() means we can't do
+        * robust signal handling and we get a potential race
+        * between checking for alarms and doing the select().
+        * Mostly harmless, I think.
+        */
+       /*
+        * On VMS, I suspect that select() can't be interrupted
+        * by a "signal" either, so I take the easy way out and
+        * have select() time out after one second.
+        * System clock updates really aren't time-critical,
+        * and - lacking a hardware reference clock - I have
+        * yet to learn about anything else that is.
+        */
+       rdfdes = activefds;
+#   if !defined(VMS) && !defined(SYS_VXWORKS)
+       nfound = select(maxactivefd + 1, &rdfdes, NULL,
+                       NULL, NULL);
+#   else       /* VMS, VxWorks */
+       /* make select() wake up after one second */
+       {
+               struct timeval t1;
+
+               t1.tv_sec = 1;
+               t1.tv_usec = 0;
+               nfound = select(maxactivefd + 1,
+                               &rdfdes, NULL, NULL,
+                               &t1);
+       }
+#   endif      /* VMS, VxWorks */
+       if (nfound > 0) {
+               l_fp ts;
+
+               get_systime(&ts);
+
+               input_handler(&ts);
+       } else if (nfound == -1 && errno != EINTR) {
+               msyslog(LOG_ERR, "select() error: %m");
+       }
+#   ifdef DEBUG
+       else if (debug > 4) {
+               msyslog(LOG_DEBUG, "select(): nfound=%d, error: %m", nfound);
+       } else {
+               DPRINTF(1, ("select() returned %d: %m\n", nfound));
+       }
+#   endif /* DEBUG */
+#  else /* HAVE_SIGNALED_IO */
+       wait_for_signal();
+#  endif /* HAVE_SIGNALED_IO */
+}
 
 /*
  * input_handler - receive packets asynchronously
@@ -3682,7 +3743,7 @@ input_handler(
        }
        return;
 }
-#endif
+#endif /* HAVE_IO_COMPLETION_PORT */
 
 
 /*
@@ -4628,64 +4689,3 @@ init_async_notifications(void)
 }
 #endif
 
-void
-io_handler(void)
-{
-#  ifndef HAVE_SIGNALED_IO
-       fd_set rdfdes;
-       int nfound;
-#  endif
-       /*
-        * Use select() on all on all input fd's for unlimited
-        * time.  select() will terminate on SIGALARM or on the
-        * reception of input.  Using select() means we can't do
-        * robust signal handling and we get a potential race
-        * between checking for alarms and doing the select().
-        * Mostly harmless, I think.
-        */
-       /*
-        * On VMS, I suspect that select() can't be interrupted
-        * by a "signal" either, so I take the easy way out and
-        * have select() time out after one second.
-        * System clock updates really aren't time-critical,
-        * and - lacking a hardware reference clock - I have
-        * yet to learn about anything else that is.
-        */
-#  ifndef HAVE_SIGNALED_IO
-       rdfdes = activefds;
-#   if !defined(VMS) && !defined(SYS_VXWORKS)
-       nfound = select(maxactivefd + 1, &rdfdes, NULL,
-                       NULL, NULL);
-#   else       /* VMS, VxWorks */
-       /* make select() wake up after one second */
-       {
-               struct timeval t1;
-
-               t1.tv_sec = 1;
-               t1.tv_usec = 0;
-               nfound = select(maxactivefd + 1,
-                               &rdfdes, NULL, NULL,
-                               &t1);
-       }
-#   endif      /* VMS, VxWorks */
-       if (nfound > 0) {
-               l_fp ts;
-
-               get_systime(&ts);
-
-               input_handler(&ts);
-       } else if (nfound == -1 && errno != EINTR) {
-               msyslog(LOG_ERR, "select() error: %m");
-       }
-#   ifdef DEBUG
-       else if (debug > 4) {
-               msyslog(LOG_DEBUG, "select(): nfound=%d, error: %m", nfound);
-       } else {
-               DPRINTF(1, ("select() returned %d: %m\n", nfound));
-       }
-#   endif /* DEBUG */
-#  else /* HAVE_SIGNALED_IO */
-       wait_for_signal();
-#  endif /* HAVE_SIGNALED_IO */
-}
-