From f19312ab4b46ae9f4ddd01b2294c9b2f454003d6 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Tue, 5 May 2026 15:45:12 +0200 Subject: [PATCH] BUG/MINOR: haterm: Immediately report error when draining the request When draining the request data, if an error was reported while some data were received, the error was not processed immediately. This part was copied from tcpchecks where the response should be processed first. For haterm, the request data are ignored. So no reason to wait to handle the error. It may be an issue because the response may be sent in the meanwhile. --- src/haterm.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/haterm.c b/src/haterm.c index 05ec35e97..9afd93e17 100644 --- a/src/haterm.c +++ b/src/haterm.c @@ -238,7 +238,6 @@ static int hstream_htx_buf_rcv(struct connection *conn, struct hstream *hs) int ret = 0; struct buffer *buf; size_t max, read = 0, cur_read = 0; - int is_empty; int fin = 0; TRACE_ENTER(HS_EV_HSTRM_RECV, hs); @@ -282,15 +281,10 @@ static int hstream_htx_buf_rcv(struct connection *conn, struct hstream *hs) } end_recv: - is_empty = (IS_HTX_SC(hs->sc) ? htx_is_empty(htxbuf(&hs->req)) : !b_data(&hs->req)); hs->req_body -= cur_read; - if (is_empty && ((conn->flags & CO_FL_ERROR) || sc_ep_test(hs->sc, SE_FL_ERROR))) { - /* Report network errors only if we got no other data. Otherwise - * we'll let the upper layers decide whether the response is OK - * or not. It is very common that an RST sent by the server is - * reported as an error just after the last data chunk. - */ + if (((conn->flags & CO_FL_ERROR) || sc_ep_test(hs->sc, SE_FL_ERROR))) { + hs->flags |= HS_ST_CONN_ERROR; TRACE_ERROR("connection error during recv", HS_EV_HSTRM_RECV, hs); goto stop; }