From 4b1e2a94bbe7b1efa547ac6f0033a7d9cca4086e Mon Sep 17 00:00:00 2001 From: henri Date: Mon, 22 Oct 2012 17:57:58 +0000 Subject: [PATCH] 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. --- nsock/src/engine_poll.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/nsock/src/engine_poll.c b/nsock/src/engine_poll.c index da41697c7..0915aac16 100644 --- a/nsock/src/engine_poll.c +++ b/nsock/src/engine_poll.c @@ -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; }