]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mux: Add a ctl parameter to get the exit status of the multiplexers
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 6 Oct 2020 12:59:17 +0000 (14:59 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 4 Dec 2020 13:41:49 +0000 (14:41 +0100)
The ctl param MUX_EXIT_STATUS can be request to get the exit status of a
multiplexer. For instance, it may be an HTTP status code or an H2 error. For
now, 0 is always returned. When the mux h1 will be able to return HTTP
errors itself, this ctl param will be used to get the HTTP status code from
the logs.

the mux_exit_status enum has been created to map internal mux exist status
to generic one. Thus there is 5 possible status for now: success, invalid
error, timeout error, internal error and unknown.

include/haproxy/connection-t.h
src/mux_fcgi.c
src/mux_h1.c
src/mux_h2.c
src/mux_pt.c

index 61602e741576dcf63c47315353881b3b3d2ace57..c79f8503078d2f8f8e181e17ff875858bd341dc8 100644 (file)
@@ -312,11 +312,20 @@ enum proto_proxy_side {
 /* ctl command used by mux->ctl() */
 enum mux_ctl_type {
        MUX_STATUS, /* Expects an int as output, sets it to a combinaison of MUX_STATUS flags */
+       MUX_EXIT_STATUS, /* Expects an int as output, sets the mux exist/error/http status, if known or 0 */
 };
 
 /* response for ctl MUX_STATUS */
 #define MUX_STATUS_READY (1 << 0)
 
+enum mux_exit_status {
+       MUX_ES_SUCCESS,      /* Success */
+       MUX_ES_INVALID_ERR,  /* invalid input */
+       MUX_ES_TOUT_ERR,     /* timeout */
+       MUX_ES_INTERNAL_ERR, /* internal error */
+       MUX_ES_UNKNOWN       /* unknown status (must be the last) */
+};
+
 /* socks4 response length */
 #define SOCKS4_HS_RSP_LEN 8
 
index 46c77cb8fe26963f520b9201ae616c919197d453..2c2611bdb04aa466e6a580bc626f00ed1c88d703 100644 (file)
@@ -3083,6 +3083,8 @@ static int fcgi_ctl(struct connection *conn, enum mux_ctl_type mux_ctl, void *ou
                if (!(conn->flags & CO_FL_WAIT_XPRT))
                        ret |= MUX_STATUS_READY;
                return ret;
+       case MUX_EXIT_STATUS:
+               return MUX_ES_UNKNOWN;
        default:
                return -1;
        }
index ad9eb51935f1b0e2f826739a70b876196e5777fd..d2bafffb57172c395384e9a4bfa176935aa702d5 100644 (file)
@@ -2922,6 +2922,8 @@ static int h1_ctl(struct connection *conn, enum mux_ctl_type mux_ctl, void *outp
                if (!(conn->flags & CO_FL_WAIT_XPRT))
                        ret |= MUX_STATUS_READY;
                return ret;
+       case MUX_EXIT_STATUS:
+               return MUX_ES_UNKNOWN;
        default:
                return -1;
        }
index 75874a38e64406a12733b89b0c59dd1c131d43bd..b90c0a17ac2fda473f9fdce575b47dc2564e1dab 100644 (file)
@@ -4048,6 +4048,8 @@ static int h2_ctl(struct connection *conn, enum mux_ctl_type mux_ctl, void *outp
                if (h2c->st0 >= H2_CS_FRAME_H && h2c->st0 < H2_CS_ERROR)
                        ret |= MUX_STATUS_READY;
                return ret;
+       case MUX_EXIT_STATUS:
+               return MUX_ES_UNKNOWN;
        default:
                return -1;
        }
index 3161d16768e58393f9e78c3fc0ddeb942e32b086..b9ad8dc67f4a8cdb5f0392a8d8ad336734b5050b 100644 (file)
@@ -347,6 +347,8 @@ static int mux_pt_ctl(struct connection *conn, enum mux_ctl_type mux_ctl, void *
                if (!(conn->flags & CO_FL_WAIT_XPRT))
                        ret |= MUX_STATUS_READY;
                return ret;
+       case MUX_EXIT_STATUS:
+               return MUX_ES_UNKNOWN;
        default:
                return -1;
        }