A couple adjustemnt for windows.

- Do not set the X flags as events to be watched.
  - Do not use POLLPRI as a R flag.

Not doing so causes WSAPoll() to fail with an "invalid argument" error.
This commit is contained in:
henri 2012-10-22 17:57:58 +00:00
parent ef9f4fcba5
commit 4b1e2a94bb

View file

@ -89,7 +89,12 @@
#define POLLFD struct pollfd
#endif
#define POLL_R_FLAGS (POLLIN | POLLPRI)
#ifdef WIN32
#define POLL_R_FLAGS (POLLIN)
#else
#define POLL_R_FLAGS (POLLIN | POLLPRI)
#endif /* WIN32 */
#define POLL_W_FLAGS POLLOUT
#ifdef POLLRDHUP
#define POLL_X_FLAGS (POLLERR | POLLHUP | POLLRDHUP)
@ -98,6 +103,7 @@
#define POLL_X_FLAGS (POLLERR | POLLHUP)
#endif /* POLLRDHUP */
#define LOWER_MAX_FD(pinfo) \
do { \
pinfo->max_fd--; \
@ -221,8 +227,10 @@ int poll_iod_register(mspool *nsp, msiod *iod, int ev) {
pinfo->events[sd].events |= POLL_R_FLAGS;
if (ev & EV_WRITE)
pinfo->events[sd].events |= POLL_W_FLAGS;
#ifndef WIN32
if (ev & EV_EXCEPT)
pinfo->events[sd].events |= POLL_X_FLAGS;
#endif
IOD_PROPSET(iod, IOD_REGISTERED);
return 1;
@ -278,8 +286,10 @@ int poll_iod_modify(mspool *nsp, msiod *iod, int ev_set, int ev_clr) {
pinfo->events[sd].events |= POLL_R_FLAGS;
if (iod->watched_events & EV_WRITE)
pinfo->events[sd].events |= POLL_W_FLAGS;
#ifndef WIN32
if (iod->watched_events & EV_EXCEPT)
pinfo->events[sd].events |= POLL_X_FLAGS;
#endif
return 1;
}