diff --git a/include/haproxy/defaults.h b/include/haproxy/defaults.h index d4721a794..80b2e6431 100644 --- a/include/haproxy/defaults.h +++ b/include/haproxy/defaults.h @@ -390,6 +390,15 @@ #define HAPROXY_MEMMAX 0 #endif +/* For USE_ZLIB, DEFAULT_MAXZLIBMEM may be set to a hard-coded value that will + * preset a maxzlibmem value. Just leave it to zero for other configurations. + * Note that it's expressed in megabytes. + */ +#if !defined(DEFAULT_MAXZLIBMEM) || !defined(USE_ZLIB) +#undef DEFAULT_MAXZLIBMEM +#define DEFAULT_MAXZLIBMEM 0 +#endif + /* Pools are always enabled unless explicitly disabled. When disabled, the * calls are directly passed to the underlying OS functions. */ diff --git a/src/compression.c b/src/compression.c index 8095ecb99..3ce2a6005 100644 --- a/src/compression.c +++ b/src/compression.c @@ -713,14 +713,6 @@ static struct cfg_kw_list cfg_kws = {ILH, { INITCALL1(STG_REGISTER, cfg_register_keywords, &cfg_kws); -__attribute__((constructor)) -static void __comp_fetch_init(void) -{ -#if defined(USE_ZLIB) && defined(DEFAULT_MAXZLIBMEM) - global.maxzlibmem = DEFAULT_MAXZLIBMEM * 1024U * 1024U; -#endif -} - static void comp_register_build_opts(void) { char *ptr = NULL; diff --git a/src/haproxy.c b/src/haproxy.c index ddb23e2c8..6fbe85bd3 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -175,7 +175,7 @@ struct global global = { .nbthread = 0, .req_count = 0, .logsrvs = LIST_HEAD_INIT(global.logsrvs), - .maxzlibmem = 0, + .maxzlibmem = DEFAULT_MAXZLIBMEM * 1024U * 1024U, .comp_rate_lim = 0, .ssl_server_verify = SSL_SERVER_VERIFY_REQUIRED, .unix_bind = {