From 7fe515c3dd6bfb2e72ae840f2da43048bf48e5df Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Sun, 1 Nov 2026 21:23:40 +0100 Subject: [PATCH] BUG/MINOR: compression: pass the configured level to slz Since its integration in 1.6 with commit 418b8c0c4 ("MAJOR: compression: integrate support for libslz"), the slz backend only knew levels 0 and 1, so the init functions forced the level to 0 or 1 using !!level, and the rate limiting code only raised the level back up to 1. Since slz 1.4-dev3 was imported in commit 32582812a ("IMPORT: slz: update slz to version 1.4-dev3"), slz supports levels 1 to 3 (higher ones behave as 3), but tune.comp.maxlevel was still capped to 1. Let's pass the configured level to slz's init functions, and let the rate limiting code raise the level back up to tune.comp.maxlevel. Note that configurations with tune.comp.maxlevel above 1 will now use the higher slz levels, which compress better but consume more CPU. This must be backported wherever commit 32582812a is backported. --- src/compression.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/compression.c b/src/compression.c index d0fceb15d..1d98cb759 100644 --- a/src/compression.c +++ b/src/compression.c @@ -339,8 +339,8 @@ static int comp_rfc1952_init(struct comp_ctx **comp_ctx, int level) if (init_comp_ctx(comp_ctx) < 0) return -1; - (*comp_ctx)->cur_lvl = !!level; - return slz_rfc1952_init(&(*comp_ctx)->strm, !!level); + (*comp_ctx)->cur_lvl = level; + return slz_rfc1952_init(&(*comp_ctx)->strm, level); } /* SLZ's raw deflate format (RFC1951). Returns < 0 on error. */ @@ -349,8 +349,8 @@ static int comp_rfc1951_init(struct comp_ctx **comp_ctx, int level) if (init_comp_ctx(comp_ctx) < 0) return -1; - (*comp_ctx)->cur_lvl = !!level; - return slz_rfc1951_init(&(*comp_ctx)->strm, !!level); + (*comp_ctx)->cur_lvl = level; + return slz_rfc1951_init(&(*comp_ctx)->strm, level); } /* SLZ's zlib format (RFC1950). Returns < 0 on error. */ @@ -359,8 +359,8 @@ static int comp_rfc1950_init(struct comp_ctx **comp_ctx, int level) if (init_comp_ctx(comp_ctx) < 0) return -1; - (*comp_ctx)->cur_lvl = !!level; - return slz_rfc1950_init(&(*comp_ctx)->strm, !!level); + (*comp_ctx)->cur_lvl = level; + return slz_rfc1950_init(&(*comp_ctx)->strm, level); } /* Return the size of consumed data. The caller is responsible for guaranteeing @@ -407,7 +407,7 @@ static int comp_rfc195x_flush_or_finish(struct comp_ctx *comp_ctx, struct buffer if (comp_ctx->cur_lvl > 0) strm->level = --comp_ctx->cur_lvl; } - else if (comp_ctx->cur_lvl < global.tune.comp_maxlevel && comp_ctx->cur_lvl < 1) { + else if (comp_ctx->cur_lvl < global.tune.comp_maxlevel) { strm->level = ++comp_ctx->cur_lvl; } -- 2.47.3