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.
This commit is contained in:
Christopher Faulet 2020-10-06 14:59:17 +02:00
parent 7d0c19e82d
commit 4c8ad84232
5 changed files with 17 additions and 0 deletions

View 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

View 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;
}

View 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;
}

View 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;
}

View 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;
}