From: Danny Mayer Date: Mon, 2 Jun 2003 12:54:15 +0000 (-0400) Subject: Changes in support for I/O Completion Ports. Added additional argument to call. X-Git-Tag: NTP_4_1_80_RC1~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=75d058bd0133646db399f314be76933b9e66f915;p=thirdparty%2Fntp.git Changes in support for I/O Completion Ports. Added additional argument to call. Added support for broadcast socket through I/O Completion Ports, which was not previously being added. bk: 3edb48f7Qi-g7MAUH6YFuYYRz5iUWQ --- diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c index 8947fba6a..74f086a7d 100644 --- a/ntpd/ntp_io.c +++ b/ntpd/ntp_io.c @@ -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); + } diff --git a/ports/winnt/include/ntp_iocompletionport.h b/ports/winnt/include/ntp_iocompletionport.h index a7282000f..6e63ef760 100644 --- a/ports/winnt/include/ntp_iocompletionport.h +++ b/ports/winnt/include/ntp_iocompletionport.h @@ -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*); diff --git a/ports/winnt/ntpd/ntp_iocompletionport.c b/ports/winnt/ntpd/ntp_iocompletionport.c index b5d8ede25..16de6ff92 100644 --- a/ports/winnt/ntpd/ntp_iocompletionport.c +++ b/ports/winnt/ntpd/ntp_iocompletionport.c @@ -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); }