From: Christopher Faulet Date: Wed, 14 Apr 2021 13:46:49 +0000 (+0200) Subject: MINOR: connection: Make bc_http_major compatible with tcp-checks X-Git-Tag: v2.4-dev17~103 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=242f8ce060e4d77da16ae43a58598a28b556ee5b;p=thirdparty%2Fhaproxy.git MINOR: connection: Make bc_http_major compatible with tcp-checks bc_http_major sample fetch now works when it is called from a tcp-check. When it happens, the session origin is a check. The backend connection is retrieved from the conn-stream attached to the check. If required, this path may easily be backported as far as 2.2. --- diff --git a/src/connection.c b/src/connection.c index b55890ae2a..c0ba8155f4 100644 --- a/src/connection.c +++ b/src/connection.c @@ -1315,8 +1315,13 @@ static int cfg_parse_pp2_never_send_local(char **args, int section_type, struct static int smp_fetch_fc_http_major(const struct arg *args, struct sample *smp, const char *kw, void *private) { - struct connection *conn = (kw[0] != 'b') ? objt_conn(smp->sess->origin) : - smp->strm ? cs_conn(objt_cs(smp->strm->si[1].end)) : NULL; + struct connection *conn = NULL; + + if (obj_type(smp->sess->origin) == OBJ_TYPE_CHECK) + conn = (kw[0] == 'b') ? cs_conn(__objt_check(smp->sess->origin)->cs) : NULL; + else + conn = (kw[0] != 'b') ? objt_conn(smp->sess->origin) : + smp->strm ? cs_conn(objt_cs(smp->strm->si[1].end)) : NULL; /* No connection or a connection with a RAW muxx */ if (!conn || (conn->mux && !(conn->mux->flags & MX_FL_HTX)))