From: Christopher Faulet Date: Mon, 5 Oct 2026 06:30:05 +0000 (+0200) Subject: MINOR: flt-http-comp: Don't uselessly init a compression filter X-Git-Tag: v3.5-dev9~97 X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=5aacf4a61a23753d3a10384934dbf3831ada876a;p=haproxy.git MINOR: flt-http-comp: Don't uselessly init a compression filter When a compression filter, request or response, is attached to a stream, there was no special test to know if the filter will be usable, so when its direction was not enabled or no algorithm was available for it on the proxy that declared it. Now the attach callback returns 0 when the direction is not enabled or when the compression configuration has no algorithm for the filter's direction, so the filter is not attached to the stream at all. Its per-stream state is not allocated and its HTTP callbacks are never called; these filters were already ignored by the http_headers callback, they are just not instantiated anymore. A NULL configuration is also tolerated, so that an implicit instance inherited by a proxy without the matching capability can keep its metadata without applicable options. The check uses the compression options stored in the filter configuration by the preceding change, and only inspects the proxy that declared the filter. When the algorithms are configured on the other proxy, that proxy also gets an implicit filter for the direction, so an instance with a local algorithm remains attached to perform the compression. This also prepares the filter instances, where the same options are shared by the legacy configurations and the instances. --- diff --git a/src/flt_http_comp.c b/src/flt_http_comp.c index c90c23206..0c3650e97 100644 --- a/src/flt_http_comp.c +++ b/src/flt_http_comp.c @@ -68,8 +68,16 @@ comp_flt_init(struct proxy *px, struct flt_conf *fconf) static int comp_strm_init(struct stream *s, struct filter *filter) { + struct comp *comp = FLT_CONF(filter); struct comp_state *st; + if (filter->config->id == http_comp_req_flt_id && + (!comp || !comp->algo_req || !(comp->flags & COMP_FL_DIR_REQ))) + return 0; + else if (filter->config->id == http_comp_res_flt_id && + (!comp || !comp->algos_res || !(comp->flags & COMP_FL_DIR_RES))) + return 0; + st = pool_alloc(pool_head_comp_state); if (st == NULL) return -1;