mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
client: HUP: defer POLLUP handling while buffered rx
If the server is very close in rtt to the client, the server hangup may get processed before buffered rx. Make sure we clear buffered rx before dealing with the HUP.
This commit is contained in:
parent
52b87c9037
commit
d5178f477f
1 changed files with 9 additions and 11 deletions
|
@ -689,11 +689,16 @@ lws_service_fd_tsi(struct lws_context *context, struct lws_pollfd *pollfd,
|
|||
|
||||
if ((!(pollfd->revents & pollfd->events & LWS_POLLIN)) &&
|
||||
(pollfd->revents & LWS_POLLHUP)) {
|
||||
wsi->socket_is_permanently_unusable = 1;
|
||||
lwsl_debug("Session Socket %s (fd=%d) dead\n",
|
||||
lws_wsi_tag(wsi), pollfd->fd);
|
||||
|
||||
goto close_and_handled;
|
||||
if (lws_buflist_total_len(&wsi->buflist))
|
||||
lws_set_timeout(wsi, PENDING_TIMEOUT_CLOSE_ACK, 3);
|
||||
else {
|
||||
wsi->socket_is_permanently_unusable = 1;
|
||||
lwsl_debug("Session Socket %s (fd=%d) dead\n",
|
||||
lws_wsi_tag(wsi), pollfd->fd);
|
||||
|
||||
goto close_and_handled;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef _WIN32
|
||||
|
@ -701,13 +706,6 @@ lws_service_fd_tsi(struct lws_context *context, struct lws_pollfd *pollfd,
|
|||
wsi->sock_send_blocking = FALSE;
|
||||
#endif
|
||||
|
||||
if ((!(pollfd->revents & pollfd->events & LWS_POLLIN)) &&
|
||||
(pollfd->revents & LWS_POLLHUP)) {
|
||||
lwsl_debug("pollhup\n");
|
||||
wsi->socket_is_permanently_unusable = 1;
|
||||
goto close_and_handled;
|
||||
}
|
||||
|
||||
#if defined(LWS_WITH_TLS)
|
||||
if (lwsi_state(wsi) == LRS_SHUTDOWN &&
|
||||
lws_is_ssl(wsi) && wsi->tls.ssl) {
|
||||
|
|
Loading…
Add table
Reference in a new issue