From 6486ff8cabb1495f8fc76d66fc37c66613773cf4 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Fri, 2 Sep 2022 11:42:50 +0200 Subject: [PATCH] BUG/MINOR: httpclient: only ask for more room on failed writes There's a tiny issue in the I/O handler by which both a failed request emission and missing response data will want to subscribe for more room on output. That's not correct in that only the case where the request buffer is full should cause this, the other one should just wait for incoming data. This could theoretically cause spurious wakeups at certain key points (e.g. connect() time maybe) though this could not be reproduced but better fix this while it's easy enough. It doesn't seem necessary to backport it right now, though this may have to in case a concrete reproducible case is discovered. --- src/http_client.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/http_client.c b/src/http_client.c index 8bc65553f..4e7f0a43a 100644 --- a/src/http_client.c +++ b/src/http_client.c @@ -660,14 +660,14 @@ static void httpclient_applet_io_handler(struct appctx *appctx) * request from the httpclient buffer */ ret = b_xfer(&req->buf, &hc->req.buf, b_data(&hc->req.buf)); if (!ret) - goto more; + goto full; if (!b_data(&hc->req.buf)) b_free(&hc->req.buf); htx = htx_from_buf(&req->buf); if (!htx) - goto more; + goto full; channel_add_input(req, htx->data); @@ -912,11 +912,12 @@ static void httpclient_applet_io_handler(struct appctx *appctx) sc_will_read(sc); return; -more: - /* There was not enough data in the response channel */ - +full: + /* There was not enough room in the response channel */ sc_need_room(sc); +more: + /* we'll automatically be called again on missing data */ if (appctx->st0 == HTTPCLIENT_S_RES_END) goto end;