diff --git a/lib/plat/windows/windows-service.c b/lib/plat/windows/windows-service.c index aef7f6b52..4a9ff2c6a 100644 --- a/lib/plat/windows/windows-service.c +++ b/lib/plat/windows/windows-service.c @@ -127,16 +127,13 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi) lws_pt_unlock(pt); } - { - unsigned int eIdx; - - for (eIdx = 0; eIdx < pt->fds_count; ++eIdx) - WSAEventSelect(pt->fds[eIdx].fd, pt->events, - FD_READ | FD_WRITE | FD_OOB | FD_ACCEPT | - FD_CONNECT | FD_CLOSE | FD_QOS | - FD_ROUTING_INTERFACE_CHANGE | - FD_ADDRESS_LIST_CHANGE); - } + for (n = 0; n < (int)pt->fds_count; n++) + WSAEventSelect(pt->fds[n].fd, pt->events, + FD_READ | (!!(pt->fds[n].events & LWS_POLLOUT) * FD_WRITE) | + FD_OOB | FD_ACCEPT | + FD_CONNECT | FD_CLOSE | FD_QOS | + FD_ROUTING_INTERFACE_CHANGE | + FD_ADDRESS_LIST_CHANGE); ev = WSAWaitForMultipleEvents(1, &pt->events, FALSE, timeout_ms, FALSE); if (ev == WSA_WAIT_EVENT_0) { diff --git a/lib/plat/windows/windows-sockets.c b/lib/plat/windows/windows-sockets.c index b4ff326b0..6ebff31bb 100644 --- a/lib/plat/windows/windows-sockets.c +++ b/lib/plat/windows/windows-sockets.c @@ -132,10 +132,15 @@ void lws_plat_insert_socket_into_fds(struct lws_context *context, struct lws *wsi) { struct lws_context_per_thread *pt = &context->pt[(int)wsi->tsi]; + int n = LWS_POLLIN | LWS_POLLHUP | FD_CONNECT; + + if (wsi->udp) { + lwsl_info("%s: UDP\n", __func__); + n = LWS_POLLIN; + } pt->fds[pt->fds_count++].revents = 0; - WSAEventSelect(wsi->desc.sockfd, pt->events, - LWS_POLLIN | LWS_POLLHUP | FD_CONNECT); + WSAEventSelect(wsi->desc.sockfd, pt->events, n); } void @@ -170,16 +175,15 @@ lws_plat_change_pollfd(struct lws_context *context, struct lws *wsi, struct lws_pollfd *pfd) { struct lws_context_per_thread *pt = &context->pt[(int)wsi->tsi]; - long networkevents = LWS_POLLHUP | FD_CONNECT; + long e = LWS_POLLHUP | FD_CONNECT; if ((pfd->events & LWS_POLLIN)) - networkevents |= LWS_POLLIN; + e |= LWS_POLLIN; if ((pfd->events & LWS_POLLOUT)) - networkevents |= LWS_POLLOUT; + e |= LWS_POLLOUT; - if (WSAEventSelect(wsi->desc.sockfd, pt->events, - networkevents) != SOCKET_ERROR) + if (WSAEventSelect(wsi->desc.sockfd, pt->events, e) != SOCKET_ERROR) return 0; lwsl_err("WSAEventSelect() failed with error %d\n", LWS_ERRNO);