jdk/src/windows/native/sun/nio/ch/WindowsSelectorImpl.c
changeset 22604 9b394795e216
parent 7668 d4a77089c587
equal deleted inserted replaced
22603:816588059f9d 22604:9b394795e216
    31 /* This definition MUST precede the inclusion of winsock2.h */
    31 /* This definition MUST precede the inclusion of winsock2.h */
    32 
    32 
    33 #define FD_SETSIZE 1024
    33 #define FD_SETSIZE 1024
    34 
    34 
    35 #include <stdlib.h>
    35 #include <stdlib.h>
       
    36 #include <winsock2.h>
       
    37 
    36 #include "jvm.h"
    38 #include "jvm.h"
    37 #include "jni.h"
    39 #include "jni.h"
    38 #include "jni_util.h"
    40 #include "jni_util.h"
    39 #include "sun_nio_ch_WindowsSelectorImpl.h"
    41 #include "sun_nio_ch_WindowsSelectorImpl.h"
    40 #include "sun_nio_ch_PollArrayWrapper.h"
    42 #include "sun_nio_ch_PollArrayWrapper.h"
    41 #include "winsock2.h"
    43 
    42 
    44 #include "nio_util.h" /* Needed for POLL* constants (includes "winsock2.h") */
    43 
    45 
    44 typedef struct {
    46 typedef struct {
    45     jint fd;
    47     jint fd;
    46     jshort events;
    48     jshort events;
    47 } pollfd;
    49 } pollfd;
    77         tv->tv_usec = (long)((timeout % 1000) * 1000);
    79         tv->tv_usec = (long)((timeout % 1000) * 1000);
    78     }
    80     }
    79 
    81 
    80     /* Set FD_SET structures required for select */
    82     /* Set FD_SET structures required for select */
    81     for (i = 0; i < numfds; i++) {
    83     for (i = 0; i < numfds; i++) {
    82         if (fds[i].events & sun_nio_ch_PollArrayWrapper_POLLIN) {
    84         if (fds[i].events & POLLIN) {
    83            readfds.fd_array[read_count] = fds[i].fd;
    85            readfds.fd_array[read_count] = fds[i].fd;
    84            read_count++;
    86            read_count++;
    85         }
    87         }
    86         if (fds[i].events & (sun_nio_ch_PollArrayWrapper_POLLOUT |
    88         if (fds[i].events & (POLLOUT | POLLCONN))
    87                              sun_nio_ch_PollArrayWrapper_POLLCONN))
       
    88         {
    89         {
    89            writefds.fd_array[write_count] = fds[i].fd;
    90            writefds.fd_array[write_count] = fds[i].fd;
    90            write_count++;
    91            write_count++;
    91         }
    92         }
    92         exceptfds.fd_array[except_count] = fds[i].fd;
    93         exceptfds.fd_array[except_count] = fds[i].fd;
   108         exceptfds.fd_count = 0;
   109         exceptfds.fd_count = 0;
   109         for (i = 0; i < numfds; i++) {
   110         for (i = 0; i < numfds; i++) {
   110             /* prepare select structures for the i-th socket */
   111             /* prepare select structures for the i-th socket */
   111             errreadfds.fd_count = 0;
   112             errreadfds.fd_count = 0;
   112             errwritefds.fd_count = 0;
   113             errwritefds.fd_count = 0;
   113             if (fds[i].events & sun_nio_ch_PollArrayWrapper_POLLIN) {
   114             if (fds[i].events & POLLIN) {
   114                errreadfds.fd_array[0] = fds[i].fd;
   115                errreadfds.fd_array[0] = fds[i].fd;
   115                errreadfds.fd_count = 1;
   116                errreadfds.fd_count = 1;
   116             }
   117             }
   117             if (fds[i].events & (sun_nio_ch_PollArrayWrapper_POLLOUT |
   118             if (fds[i].events & (POLLOUT | POLLCONN))
   118                                  sun_nio_ch_PollArrayWrapper_POLLCONN))
       
   119             {
   119             {
   120                 errwritefds.fd_array[0] = fds[i].fd;
   120                 errwritefds.fd_array[0] = fds[i].fd;
   121                 errwritefds.fd_count = 1;
   121                 errwritefds.fd_count = 1;
   122             }
   122             }
   123             errexceptfds.fd_array[0] = fds[i].fd;
   123             errexceptfds.fd_array[0] = fds[i].fd;