mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2026-01-29 22:11:18 +01:00
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.