]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: cfgparse: do not store unnamed defaults in name tree
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 21 Jan 2026 09:22:23 +0000 (10:22 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Thu, 22 Jan 2026 16:57:16 +0000 (17:57 +0100)
commit116983ad94c8c528ff46c59f78f4a6beb055aa18
treeee21f9b018114cacf35de53bddfac24d76aa9f7f
parent848e0cd0523cca96be0d872ee7f1a79ce5c73b1c
MEDIUM: cfgparse: do not store unnamed defaults in name tree

Defaults section are indexed by their name in defproxy_by_name tree. For
named sections, there is no duplicate : if two instances have the same
name, the older one is removed from the tree. However, this was not the
case for unnamed defaults which are all stored inconditionnally in
defproxy_by_name.

This commit introduces a new approach for unnamed defaults. Now, these
instances are never inserted in the defproxy_by_name tree. Indeed, this
is not needed as no tree lookup is performed with empty names. This may
optimize slightly config parsing with a huge number of named and unnamed
defaults sections, as the first ones won't fill up the tree needlessly.

However, defproxy_by_name tree is also used to purge unreferenced
defaults instances, both on postparsing and deinit. Thus, a new approach
is needed for unnamed sections cleanup. Now, each time a new defaults is
parsed, if the previous instance is unnamed, it is freed unless if
referenced by a proxy. When config parsing is ended, a similar operation
is performed to ensure the last unnamed defaults section won't stay in
memory. To implement this, last_defproxy static variable is now set to
global. Unnamed sections which cannot be removed due to proxies
referencing proxies will still be removed when such proxies are freed
themselves, at runtime or on deinit.
include/haproxy/cfgparse.h
src/cfgparse-listen.c
src/cfgparse.c
src/haproxy.c
src/proxy.c