aboutsummaryrefslogtreecommitdiff
path: root/lib/roles/h1
diff options
context:
space:
mode:
authorAndy Green <andy@warmcat.com>2020-01-20 10:02:56 +0000
committerAndy Green <andy@warmcat.com>2020-01-20 10:02:56 +0000
commit270f2f48c8ad544a3818e4ddeac65530fb886b35 (patch)
treef4b5f165c83fc5776a2405c450215a46e9ec5f53 /lib/roles/h1
parent46c5b289862851aae2c78be3edae2b50d1a0bbfe (diff)
downloadlibwebsockets-270f2f48c8ad544a3818e4ddeac65530fb886b35.tar.gz
lws_buflist_aware_read: restrict to incoming ebuf length if non-NULL ebuf.token incoming
(Includes fixes from Yichen Gu) Currently the incoming ebuf is always replaced to point to either a whole buflist segment, or up to the (pt_serv_buf - LWS_PRE) length in the pt_serv_buf. This is called on path for handling http read... some user code reasonably wants to restrict the read size to what it can handle. Change the other lws_buflist_aware_read() callers to zero ebuf before calling, and for those have it keep the current behaviour; but if non-NULL ebuf.token on incoming, as in http read path case, restrict both reported len of buflist content and the read length to the incoming ebuf.len so the user code can control what it will get at one time. Additionally muxed protocol wsi have no choice but to read what was sent to them since it's HOL-blocking for other streams and its own WINDOW_UPDATEs. So add an internal param to lws_buflist_aware_read() forcing read even if buflist content is available.
Diffstat (limited to 'lib/roles/h1')
-rw-r--r--lib/roles/h1/ops-h1.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/roles/h1/ops-h1.c b/lib/roles/h1/ops-h1.c
index 3a93cebf..12d1860c 100644
--- a/lib/roles/h1/ops-h1.c
+++ b/lib/roles/h1/ops-h1.c
@@ -352,7 +352,9 @@ lws_h1_server_socket_service(struct lws *wsi, struct lws_pollfd *pollfd)
* exhausted and we tried to do a read of some kind.
*/
- buffered = lws_buflist_aware_read(pt, wsi, &ebuf, __func__);
+ ebuf.token = NULL;
+ ebuf.len = 0;
+ buffered = lws_buflist_aware_read(pt, wsi, &ebuf, 0, __func__);
switch (ebuf.len) {
case 0:
lwsl_info("%s: read 0 len a\n", __func__);