]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: mcli: Properly handle errors and timeouts during reponse processing
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 7 Mar 2022 17:20:21 +0000 (18:20 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 8 Mar 2022 17:31:44 +0000 (18:31 +0100)
The response analyzer of the master CLI only handles read errors. So if
there is a write error, the session remains stuck because some outgoing data
are blocked in the channel and the response analyzer waits everything to be
sent. Because the maxconn is set to 10 for the master CLI, it may be
unresponsive if this happens to many times.

Now read and write errors, timeouts and client aborts are handled.

This patch should solve the issue #1512. It must be backported as far as
2.0.

src/cli.c

index 63ca4c6d083926c9afb02bddc381760eab71e0a3..6f617b2fd883c544c84e152f7af08b55b9c3bfb0 100644 (file)
--- a/src/cli.c
+++ b/src/cli.c
@@ -2615,7 +2615,8 @@ int pcli_wait_for_response(struct stream *s, struct channel *rep, int an_bit)
        struct proxy *fe = strm_fe(s);
        struct proxy *be = s->be;
 
-       if (rep->flags & CF_READ_ERROR) {
+       if ((rep->flags & (CF_READ_ERROR|CF_READ_TIMEOUT|CF_WRITE_ERROR|CF_WRITE_TIMEOUT)) ||
+           ((rep->flags & CF_SHUTW) && (rep->to_forward || co_data(rep)))) {
                pcli_reply_and_close(s, "Can't connect to the target CLI!\n");
                s->req.analysers &= ~AN_REQ_WAIT_CLI;
                s->res.analysers &= ~AN_RES_WAIT_CLI;