mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
windows: proposed fix for CANCELLED
https://github.com/warmcat/libwebsockets/issues/1291
This commit is contained in:
parent
31d1d73f74
commit
30315ec688
1 changed files with 22 additions and 7 deletions
|
@ -92,7 +92,10 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi)
|
|||
if (n < 0)
|
||||
return -1;
|
||||
|
||||
/* Force WSAWaitForMultipleEvents() to check events and then return immediately. */
|
||||
/*
|
||||
* Force WSAWaitForMultipleEvents() to check events
|
||||
* and then return immediately.
|
||||
*/
|
||||
timeout_ms = 0;
|
||||
|
||||
/* if something closed, retry this slot */
|
||||
|
@ -124,12 +127,21 @@ _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);
|
||||
}
|
||||
|
||||
ev = WSAWaitForMultipleEvents(1, &pt->events, FALSE, timeout_ms, FALSE);
|
||||
if (ev == WSA_WAIT_EVENT_0) {
|
||||
unsigned int eIdx;
|
||||
|
||||
WSAResetEvent(pt->events);
|
||||
|
||||
if (pt->context->tls_ops &&
|
||||
pt->context->tls_ops->fake_POLLIN_for_buffered)
|
||||
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)
|
|||
for (eIdx = 0; eIdx < pt->fds_count; ++eIdx) {
|
||||
unsigned int err;
|
||||
|
||||
if (WSAEnumNetworkEvents(pt->fds[eIdx].fd, 0,
|
||||
if (WSAEnumNetworkEvents(pt->fds[eIdx].fd, pt->events,
|
||||
&networkevents) == SOCKET_ERROR) {
|
||||
lwsl_err("WSAEnumNetworkEvents() failed "
|
||||
"with error %d\n", LWS_ERRNO);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!networkevents.lNetworkEvents)
|
||||
networkevents.lNetworkEvents = LWS_POLLOUT;
|
||||
|
||||
pfd = &pt->fds[eIdx];
|
||||
pfd->revents = (short)networkevents.lNetworkEvents;
|
||||
|
||||
|
@ -171,10 +186,10 @@ _lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi)
|
|||
lws_service_fd_tsi(context, pfd, tsi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ev == WSA_WAIT_TIMEOUT)
|
||||
} else if (ev == WSA_WAIT_TIMEOUT) {
|
||||
lws_service_fd(context, NULL);
|
||||
} else if (ev == WSA_WAIT_FAILED)
|
||||
return 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue