1
0
Fork 0
mirror of https://github.com/warmcat/libwebsockets.git synced 2025-03-09 00:00:04 +01:00

ws: ext: close wsi rather than spin if unable to clear buflist

If there's ssl pending and stuff in the buflist, it was observed we can
spin if the buflist is not cleared due to wsi state.

Add a sanity check for the number of times we will try to deal with that
before dropping the conn.
This commit is contained in:
Andy Green 2021-07-18 11:16:45 +01:00
parent 4b089788bc
commit c11311ff5a

View file

@ -943,7 +943,7 @@ rops_handle_POLLIN_ws(struct lws_context_per_thread *pt, struct lws *wsi,
unsigned int pending = 0;
struct lws_tokens ebuf;
char buffered = 0;
int n = 0, m;
int n = 0, m, sanity = 10;
#if defined(LWS_WITH_HTTP2)
struct lws *wsi1;
#endif
@ -1223,7 +1223,14 @@ drain:
else
pending = pending > wsi->a.context->pt_serv_buf_size ?
wsi->a.context->pt_serv_buf_size : pending;
goto read;
if (--sanity)
goto read;
else
/*
* Something has gone wrong, we are spinning...
* let's bail on this connection
*/
return LWS_HPI_RET_PLEASE_CLOSE_ME;
}
if (buffered && /* were draining, now nothing left */