>From 5fb549c45319ab49f9c0f7c9fa2a4d22e9e2496a Mon Sep 17 00:00:00 2001
From: Christopher Faulet <cfaulet@haproxy.com>
Date: Thu, 1 Aug 2024 15:42:09 +0200
Subject: [PATCH 4/6] BUG/MEDIUM: http-ana: Report error on write error waiting
 for the response

When we are waiting for the server response, if an error is pending on the
frontend side (a write error on client), it is handled as an abort and all
regular response analyzers are removed, except the one responsible to
release the filters, if any. However, while it is handled as an abort, the
error is not reported, as usual, via http_reply_and_close() function. It is
an issue because in that, the channels buffers are not reset.

Because of this bug, it is possible to block a stream infinitely. The
request side is waiting for the response side and the response side is
blocked because filters must be released and this cannot be done because
data remain blocked in channels buffers.

So, in that case, calling http_reply_and_close() with no message is enough
to unblock the stream.

This patch must be backported as far as 2.8.

(cherry picked from commit 0ba6202796fe24099aeff89a5a4b83af99fc027b)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
---
 src/http_ana.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/http_ana.c b/src/http_ana.c
index 97594c6a28..12228b1fe5 100644
--- a/src/http_ana.c
+++ b/src/http_ana.c
@@ -1373,6 +1373,7 @@ int http_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
 			http_set_term_flags(s);
 
 			/* process_stream() will take care of the error */
+			http_reply_and_close(s, txn->status, NULL);
 			DBG_TRACE_DEVEL("leaving on error",
 					STRM_EV_STRM_ANA|STRM_EV_HTTP_ANA|STRM_EV_HTTP_ERR, s, txn);
 			return 0;
-- 
2.45.2
