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.
This commit is contained in:
Willy Tarreau 2022-09-02 11:42:50 +02:00
parent b48292068b
commit 6486ff8cab

View File

@ -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 @@ process_data:
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;