diff options
author | Andy Green <andy@warmcat.com> | 2021-07-18 11:16:45 +0100 |
---|---|---|
committer | Andy Green <andy@warmcat.com> | 2021-07-18 11:25:24 +0100 |
commit | c11311ff5a00f0db013059da907bdb688e21e518 (patch) | |
tree | dc1c4b9aab90d0c67c5745b91768d22c746edd49 /lib/roles | |
parent | 4b089788bc33b5a74c3c69bdbcf01980c223de06 (diff) | |
download | libwebsockets-c11311ff5a00f0db013059da907bdb688e21e518.tar.gz |
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.
Diffstat (limited to 'lib/roles')
-rw-r--r-- | lib/roles/ws/ops-ws.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/roles/ws/ops-ws.c b/lib/roles/ws/ops-ws.c index 08299ca6..705c7acd 100644 --- a/lib/roles/ws/ops-ws.c +++ b/lib/roles/ws/ops-ws.c @@ -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 */ |