diff --git a/lib/core-net/client/connect3.c b/lib/core-net/client/connect3.c index ee08ffc54..311a4e79d 100644 --- a/lib/core-net/client/connect3.c +++ b/lib/core-net/client/connect3.c @@ -430,7 +430,9 @@ ads_known: lws_metrics_caliper_bind(wsi->cal_conn, wsi->a.context->mt_conn_tcp); #endif + wsi->socket_is_permanently_unusable = 0; m = connect(wsi->desc.sockfd, (const struct sockaddr *)psa, (unsigned int)n); + if (m == -1) { /* * Since we're nonblocking, connect not having completed is not diff --git a/lib/core-net/service.c b/lib/core-net/service.c index 5e0370521..6737f40bc 100644 --- a/lib/core-net/service.c +++ b/lib/core-net/service.c @@ -672,7 +672,7 @@ lws_service_fd_tsi(struct lws_context *context, struct lws_pollfd *pollfd, * is possible. */ - if (pollfd->revents & LWS_POLLHUP) { + if ((pollfd->revents & LWS_POLLHUP) == LWS_POLLHUP) { wsi->socket_is_permanently_unusable = 1; if (!(pollfd->revents & pollfd->events & LWS_POLLIN)) {