MINOR: proxy: Be able to reference the defaults section used by a proxy
A proxy may now references the defaults section it is used. To do so, a
pointer on the default proxy was added in the proxy structure. And a
refcount must be used to track proxies using a default proxy. A default
proxy is destroyed iff its refcount is equal to zero and when it drops to
zero.
All this stuff must be performed during init/deinit staged for now. All
unreferenced default proxies are removed after the configuration parsing.
This patch is mandatory to support TCP/HTTP rules in defaults sections.
diff --git a/src/haproxy.c b/src/haproxy.c
index 3c41c86..e3ccea7 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -1990,8 +1990,9 @@
ha_warning("a master CLI socket was defined, but master-worker mode (-W) is not enabled.\n");
}
- /* defaults sections are not needed anymore */
- proxy_destroy_all_defaults();
+ /* destroy unreferenced defaults proxies */
+ proxy_destroy_all_unref_defaults();
+
err_code |= check_config_validity();
for (px = proxies_list; px; px = px->next) {
@@ -2483,6 +2484,9 @@
free_proxy(p0);
}/* end while(p) */
+ /* destroy all referenced defaults proxies */
+ proxy_destroy_all_unref_defaults();
+
while (ua) {
struct stat_scope *scope, *scopep;