Skip to content
Snippets Groups Projects
Commit fdf2c7ae authored by John Kamp's avatar John Kamp Committed by Andy Green
Browse files

windows: proposed fix for CANCELLED

parent 08a2b378
No related branches found
No related tags found
No related merge requests found
...@@ -92,7 +92,10 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi) ...@@ -92,7 +92,10 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi)
if (n < 0) if (n < 0)
return -1; return -1;
/* Force WSAWaitForMultipleEvents() to check events and then return immediately. */ /*
* Force WSAWaitForMultipleEvents() to check events
* and then return immediately.
*/
timeout_ms = 0; timeout_ms = 0;
/* if something closed, retry this slot */ /* if something closed, retry this slot */
...@@ -124,12 +127,21 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi) ...@@ -124,12 +127,21 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi)
lws_pt_unlock(pt); 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);
}
ev = WSAWaitForMultipleEvents(1, &pt->events, FALSE, timeout_ms, FALSE); ev = WSAWaitForMultipleEvents(1, &pt->events, FALSE, timeout_ms, FALSE);
if (ev == WSA_WAIT_EVENT_0) { if (ev == WSA_WAIT_EVENT_0) {
unsigned int eIdx; unsigned int eIdx;
WSAResetEvent(pt->events);
if (pt->context->tls_ops && if (pt->context->tls_ops &&
pt->context->tls_ops->fake_POLLIN_for_buffered) pt->context->tls_ops->fake_POLLIN_for_buffered)
pt->context->tls_ops->fake_POLLIN_for_buffered(pt); pt->context->tls_ops->fake_POLLIN_for_buffered(pt);
...@@ -137,13 +149,16 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi) ...@@ -137,13 +149,16 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi)
for (eIdx = 0; eIdx < pt->fds_count; ++eIdx) { for (eIdx = 0; eIdx < pt->fds_count; ++eIdx) {
unsigned int err; unsigned int err;
if (WSAEnumNetworkEvents(pt->fds[eIdx].fd, 0, if (WSAEnumNetworkEvents(pt->fds[eIdx].fd, pt->events,
&networkevents) == SOCKET_ERROR) { &networkevents) == SOCKET_ERROR) {
lwsl_err("WSAEnumNetworkEvents() failed " lwsl_err("WSAEnumNetworkEvents() failed "
"with error %d\n", LWS_ERRNO); "with error %d\n", LWS_ERRNO);
return -1; return -1;
} }
if (!networkevents.lNetworkEvents)
networkevents.lNetworkEvents = LWS_POLLOUT;
pfd = &pt->fds[eIdx]; pfd = &pt->fds[eIdx];
pfd->revents = (short)networkevents.lNetworkEvents; pfd->revents = (short)networkevents.lNetworkEvents;
...@@ -171,10 +186,10 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi) ...@@ -171,10 +186,10 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi)
lws_service_fd_tsi(context, pfd, tsi); lws_service_fd_tsi(context, pfd, tsi);
} }
} }
} } else if (ev == WSA_WAIT_TIMEOUT) {
if (ev == WSA_WAIT_TIMEOUT)
lws_service_fd(context, NULL); lws_service_fd(context, NULL);
} else if (ev == WSA_WAIT_FAILED)
return 0;
return 0; return 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment