From: Christopher Faulet Date: Tue, 6 Oct 2020 12:59:17 +0000 (+0200) Subject: MINOR: mux: Add a ctl parameter to get the exit status of the multiplexers X-Git-Tag: v2.4-dev3~67 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4c8ad8423268a059e112cad5080d3061bb8e72f2;p=thirdparty%2Fhaproxy.git MINOR: mux: Add a ctl parameter to get the exit status of the multiplexers 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. --- diff --git a/include/haproxy/connection-t.h b/include/haproxy/connection-t.h index 61602e7415..c79f850307 100644 --- a/include/haproxy/connection-t.h +++ b/include/haproxy/connection-t.h @@ -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 diff --git a/src/mux_fcgi.c b/src/mux_fcgi.c index 46c77cb8fe..2c2611bdb0 100644 --- a/src/mux_fcgi.c +++ b/src/mux_fcgi.c @@ -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; } diff --git a/src/mux_h1.c b/src/mux_h1.c index ad9eb51935..d2bafffb57 100644 --- a/src/mux_h1.c +++ b/src/mux_h1.c @@ -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; } diff --git a/src/mux_h2.c b/src/mux_h2.c index 75874a38e6..b90c0a17ac 100644 --- a/src/mux_h2.c +++ b/src/mux_h2.c @@ -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; } diff --git a/src/mux_pt.c b/src/mux_pt.c index 3161d16768..b9ad8dc67f 100644 --- a/src/mux_pt.c +++ b/src/mux_pt.c @@ -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; }