[ovs-dev] [PATCH v3 1/3] poll-loop: Make poll_fd_wait_event() cross-platform.
Ben Pfaff
blp at nicira.com
Tue Feb 11 16:07:55 UTC 2014
On Mon, Feb 10, 2014 at 03:25:36PM -0800, Gurucharan Shetty wrote:
> This is helpful if we want to wait either on 'fd' for POSIX or
> events for Windows.
>
> For Windows, if both 'fd' and 'wevent' is specified, we associate
> that event with the 'fd' using WSAEventSelect() in poll_block().
> So any 'events' on that 'fd' will wake us up from WaitForMultipleObjects().
>
> WSAEventSelect() does not understand POLLIN, POLLOUT etc. Instead the
> macros it understands are FD_READ, FD_ACCEPT, FD_CONNECT, FD_CLOSE etc.
> So we need to make that transition.
>
> CC: Linda Sun <lsun at vmware.com>
> Signed-off-by: Gurucharan Shetty <gshetty at nicira.com>
...
> #ifdef _WIN32
> wevents[i] = node->wevent;
> + if (node->pollfd.fd && node->wevent) {
> + short int wsa_events = 0;
This "if" condition is always true, the | should be &. Also in the
second if statement:
> + if (node->pollfd.events | POLLIN) {
> + wsa_events |= FD_READ | FD_ACCEPT | FD_CLOSE;
> + }
> + if (node->pollfd.events | POLLOUT) {
> + wsa_events |= FD_WRITE | FD_CONNECT | FD_CLOSE;
> + }
> + WSAEventSelect(node->pollfd.fd, node->wevent, wsa_events);
> + }
> #endif
> i++;
> }
Otherwise:
Acked-by: Ben Pfaff <blp at nicira.com>
More information about the dev
mailing list