]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
Changes in support for I/O Completion Ports. Added additional argument to call.
authorDanny Mayer <mayer@ntp.org>
Mon, 2 Jun 2003 12:54:15 +0000 (08:54 -0400)
committerDanny Mayer <mayer@ntp.org>
Mon, 2 Jun 2003 12:54:15 +0000 (08:54 -0400)
Added support for broadcast socket through I/O Completion Ports, which was
not previously being added.

bk: 3edb48f7Qi-g7MAUH6YFuYYRz5iUWQ

ntpd/ntp_io.c
ports/winnt/include/ntp_iocompletionport.h
ports/winnt/ntpd/ntp_iocompletionport.c

index 8947fba6a671331edd399eeae5f886bad4d3efc4..74f086a7d904493708135a713fd2cf7331591960 100644 (file)
@@ -435,6 +435,11 @@ create_sockets(
                        msyslog(LOG_INFO, "Listening on broadcast address %s#%d",
                                stoa((&inter_list[i].bcast)),
                                NTP_PORT);
+#if defined (HAVE_IO_COMPLETION_PORT)
+               if (inter_list[i].fd != INVALID_SOCKET) {
+                       io_completion_port_add_socket(inter_list[i].fd, &inter_list[i]);
+               }
+#endif
        }
 
        /*
@@ -482,12 +487,6 @@ create_sockets(
                               stoa((&inter_list[i].mask)));
                }
        }
-#endif
-#if defined (HAVE_IO_COMPLETION_PORT)
-       for (i = 0; i < ninterfaces; i++) {
-               io_completion_port_add_socket(&inter_list[i]);
-               add_socket_to_list(inter_list[i].fd);
-       }
 #endif
        return ninterfaces;
 }
@@ -522,8 +521,12 @@ io_setbclient(void)
 #ifdef OPEN_BCAST_SOCKET /* Was: !SYS_DOMAINOS && !SYS_LINUX */
                inter_list[i].bfd = open_socket(&inter_list[i].bcast,
                    INT_BROADCAST, 1);
-               if (inter_list[i].bfd != INVALID_SOCKET)
+               if (inter_list[i].bfd != INVALID_SOCKET) {
                        inter_list[i].flags |= INT_BCASTOPEN;
+#if defined (HAVE_IO_COMPLETION_PORT)
+                       io_completion_port_add_socket(inter_list[i].bfd, &inter_list[i]);
+#endif
+               }
 #ifdef DEBUG
                if (debug) {
                        if (inter_list[i].bfd != INVALID_SOCKET)
@@ -650,6 +653,9 @@ io_multicast_add(
                        (void) strncpy(inter_list[i].name, "multicast",
                        sizeof(inter_list[i].name));
                        ((struct sockaddr_in*)&inter_list[i].mask)->sin_addr.s_addr = htonl(~(u_int32)0);
+#if defined (HAVE_IO_COMPLETION_PORT)
+                       io_completion_port_add_socket(inter_list[i].fd, &inter_list[i]);
+#endif
                }
 
                /*
@@ -728,6 +734,9 @@ io_multicast_add(
                        (void)strncpy(inter_list[i].name, "multicast",
                           sizeof(inter_list[i].name));
                        memset(&(((struct sockaddr_in6*)&inter_list[i].mask)->sin6_addr), 1, sizeof(struct in6_addr));
+#if defined (HAVE_IO_COMPLETION_PORT)
+                       io_completion_port_add_socket(inter_list[i].fd, &inter_list[i]);
+#endif
                }
 
                /*
@@ -1063,7 +1072,7 @@ open_socket(
            maxactivefd = fd;
        FD_SET(fd, &activefds);
 #endif
-
+       add_socket_to_list(fd);
        /*
         * set non-blocking,
         */
@@ -1195,9 +1204,9 @@ close_socket(
                                newmax = i;
                maxactivefd = newmax;
        }
-#else
-       delete_socket_from_list(fd);
 #endif
+       delete_socket_from_list(fd);
+
 }
 
 
@@ -1226,9 +1235,9 @@ close_file(
                                newmax = i;
                maxactivefd = newmax;
        }
-#else
-       delete_socket_from_list(fd);
 #endif
+       delete_socket_from_list(fd);
+
 }
 
 
index a7282000f439adf6701d004fd98d82ddd5d2af07..6e63ef76063483e4f3bf724c225aab5926c5a081 100644 (file)
@@ -20,7 +20,7 @@ extern        void    uninit_io_completion_port (void);
 
 extern int     io_completion_port_add_clock_io (struct refclockio * /*rio */);
 
-extern void    io_completion_port_add_socket (struct interface *);
+extern void    io_completion_port_add_socket (SOCKET fd, struct interface *);
 
 extern DWORD   io_completion_port_sendto (struct interface *, struct pkt *, int, struct sockaddr_storage*);
 
index b5d8ede258e7243432970261edd8cd284bc0d0fe..16de6ff9235cad52291e3681f969285ba682c037 100644 (file)
@@ -207,7 +207,7 @@ io_completion_port_add_clock_io(
        return 0;
 }
 
-/* Queue a receiver on a socket. Returns 0 if no buffer can be queud */
+/* Queue a receiver on a socket. Returns 0 if no buffer can be queued */
 
 static unsigned long QueueSocketRecv(SOCKET s) {
        
@@ -305,12 +305,15 @@ OnSocketRecv(DWORD i, struct IoCompletionInfo *Info, DWORD Bytes)
  *        ReadFile() is less efficient.
  */
 extern void
-io_completion_port_add_socket(struct interface *inter)
+io_completion_port_add_socket(SOCKET fd, struct interface *inter)
 {
-       if (NULL == CreateIoCompletionPort((HANDLE) inter->fd, hIoCompletionPort, (DWORD) inter, 0)) {
-               msyslog(LOG_ERR, "Can't add socket to i/o completion port: %m");
+       if (fd != INVALID_SOCKET) {
+               if (NULL == CreateIoCompletionPort((HANDLE) fd, hIoCompletionPort,
+                                                  (DWORD) inter, 0)) {
+                       msyslog(LOG_ERR, "Can't add socket to i/o completion port: %m");
+               }
+               else QueueSocketRecv(fd);
        }
-       else QueueSocketRecv(inter->fd);
 }