From: Amaury Denoyelle Date: Thu, 6 Aug 2026 07:20:29 +0000 (+0200) Subject: MINOR: config: support "all" and "none" on "tune.defaults.purge" X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fa403952558e46b84ee5211082e9e6814f06b7ba;p=thirdparty%2Fhaproxy.git MINOR: config: support "all" and "none" on "tune.defaults.purge" Extends "tune.defaults.purge" to support new arguments value. The values "all" is equivalent to "proxies,servers". The value "none" instructs to preserve all instances, which is similar to the default behavior when the keyword is absent. It is added mainly to simplify configuration by external APIs. Both these values are exclusive : they cannot be mixed into the comma-delimited list of tokens. --- diff --git a/doc/configuration.txt b/doc/configuration.txt index 270fe5b78..0656a7783 100644 --- a/doc/configuration.txt +++ b/doc/configuration.txt @@ -4225,16 +4225,9 @@ tune.comp.maxlevel Each stream using compression initializes the compression algorithm with this value. The default value is 1. -tune.defaults.purge [] +tune.defaults.purge [{ all | none | }] Define what default instances to purge after configuration parsing. - The elements to be purged are defined by a comma-delimited list of tokens. - The currently supported entries are : - - "proxies" to purge "defaults" sections - - "servers" to purge "default-server" instances - - If the list is empty, only proxies "defaults" sections will be purged. - Default-server instances are kept in memory after parsing as they may be reused for dynamic servers added at runtime. Similarly, named defaults proxies sections are preserved as dynamic backends rely on them. The command @@ -4248,8 +4241,22 @@ tune.defaults.purge [] cannot be copied by their referencing proxies (e.g. TCP/HTTP rules or tcpcheck ruleset) will be preserved, regardless of the global purge setting. + Here are the values supported as argument : + - "all" to purge "defaults" sections and "default-server" instances + - "none" to keep these elements, which is also the default behavior when the + setting is absent + + Alternatively, a comma-delimited list of tokens can be used for fine-grained + control. The currently supported entries are : + - "proxies" to purge "defaults" sections + - "servers" to purge "default-server" instances + + If no argument is specified, only proxies "defaults" sections will be purged. + Example: # reclaim the maximum memory possible + # both syntax are equivalent + tune.defaults.purge all tune.defaults.purge proxies,servers # purge proxies defaults sections diff --git a/src/cfgparse-global.c b/src/cfgparse-global.c index e0b12f29e..d2eb94b7d 100644 --- a/src/cfgparse-global.c +++ b/src/cfgparse-global.c @@ -1435,20 +1435,35 @@ static int cfg_parse_global_tune_opts(char **args, int section_type, else if (strcmp(args[0], "tune.defaults.purge") == 0) { if (args[1]) { struct ist arg = ist(args[1]); - do { - struct ist token = istsplit(&arg, ','); + /* First check exclusive values "all" and "none". */ + if (isteq(arg, ist("all"))) { + global.tune.options |= GTUNE_PURGE_DEFAULTS|GTUNE_PURGE_DEF_SRV; + } + else if (isteq(arg, ist("none"))) { + global.tune.options &= ~(GTUNE_PURGE_DEFAULTS|GTUNE_PURGE_DEF_SRV); + } + else { + /* Treat argument value as a comma separated list. */ + do { + struct ist token = istsplit(&arg, ','); - if (isteq(token, ist("proxies"))) { - global.tune.options |= GTUNE_PURGE_DEFAULTS; - } - else if (isteq(token, ist("servers"))) { - global.tune.options |= GTUNE_PURGE_DEF_SRV; - } - else { - memprintf(err, "'%s' unknown directive '%s'.", args[0], ist0(token)); - return -1; - } - } while (istlen(arg)); + if (isteq(token, ist("proxies"))) { + global.tune.options |= GTUNE_PURGE_DEFAULTS; + } + else if (isteq(token, ist("servers"))) { + global.tune.options |= GTUNE_PURGE_DEF_SRV; + } + else if (isteq(token, ist("all")) || + isteq(token, ist("none"))) { + memprintf(err, "'%s' value '%s' is exclusive.", args[0], ist0(token)); + return -1; + } + else { + memprintf(err, "'%s' unknown directive '%s'.", args[0], ist0(token)); + return -1; + } + } while (istlen(arg)); + } } else { /* default value if no argument : purge defaults proxies. */