]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: proxy: rename default refcount to avoid confusion
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 27 Feb 2026 08:20:15 +0000 (09:20 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Mon, 2 Mar 2026 13:07:40 +0000 (14:07 +0100)
Rename proxy conf <refcount> to <def_ref>. This field only serves for
defaults proxy instances. The objective is to avoid confusion with the
newly introduced <refcount> field used for dynamic backends.

As an optimization, it could be possible to remove <def_ref> and only
use <refcount> also for defaults proxies usage. However for now the
simplest solution is implemented.

This patch does not bring any functional change.

include/haproxy/proxy-t.h
src/cfgparse-listen.c
src/haproxy.c
src/proxy.c

index c233d2909be2403c749d071ba3d27f16c1b885a5..b865ba2bd86ca393ef64e6cb5dbb7f146a486601 100644 (file)
@@ -479,7 +479,7 @@ struct proxy {
                struct log_steps log_steps;     /* bitfield of log origins where log should be generated during request handling */
                const char *file_prev;          /* file of the previous instance found with the same name, or NULL */
                int line_prev;                  /* line of the previous instance found with the same name, or 0 */
-               unsigned int refcount;          /* refcount on this proxy (only used for default proxy for now) */
+               unsigned int def_ref;           /* default proxy only refcount */
        } conf;                                 /* config information */
        struct http_ext *http_ext;              /* http ext options */
        struct ceb_root *used_server_addr;      /* list of server addresses in use */
index dbf923187d9e4eaa86ee6c14d37e2230dc036ea9..76d6b6f91bf2da8b4f8f17f151408233e0c3c52d 100644 (file)
@@ -393,7 +393,7 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
                         * freed unless it is still referenced by proxies.
                         */
                        if (last_defproxy && last_defproxy->id[0] == '\0' &&
-                           !last_defproxy->conf.refcount) {
+                           !last_defproxy->conf.def_ref) {
                                defaults_px_destroy(last_defproxy);
                        }
                        last_defproxy = NULL;
index 9b13bd2f39cfdce50ad1d9d04d8248feeb73d7ab..2ea61c83609b694fd06ce9638362eb919f03f574 100644 (file)
@@ -2166,7 +2166,7 @@ static void step_init_2(int argc, char** argv)
 
        /* Free last defaults if it is unnamed and unreferenced. */
        if (last_defproxy && last_defproxy->id[0] == '\0' &&
-           !last_defproxy->conf.refcount) {
+           !last_defproxy->conf.def_ref) {
                defaults_px_destroy(last_defproxy);
        }
        last_defproxy = NULL; /* This variable is not used after parsing. */
@@ -2821,11 +2821,11 @@ void deinit(void)
         * they are respectively cleaned up in sink_deinit() and deinit_log_forward()
         */
 
-       /* If named defaults were preserved, ensure refcount is resetted. */
+       /* If named defaults were preserved, ensure <def_ref> count is resetted. */
        if (!(global.tune.options & GTUNE_PURGE_DEFAULTS))
                defaults_px_unref_all();
        /* All proxies are removed now, so every defaults should also be freed
-        * when their refcount reached zero.
+        * when their <def_ref> count reached zero.
         */
        BUG_ON(!LIST_ISEMPTY(&defaults_list));
 
index 04982b7055d383dafb52d161a3d99eef2cd9680f..adbbd63f1076f33531e836ba92d63c50ee4bf01a 100644 (file)
@@ -2973,7 +2973,7 @@ static void defaults_px_free(struct proxy *defproxy)
 void defaults_px_destroy(struct proxy *px)
 {
        BUG_ON(!(px->cap & PR_CAP_DEF));
-       BUG_ON(px->conf.refcount != 0);
+       BUG_ON(px->conf.def_ref != 0);
 
        cebis_item_delete(&defproxy_by_name, conf.name_node, id, px);
        LIST_DELETE(&px->el);
@@ -2983,7 +2983,7 @@ void defaults_px_destroy(struct proxy *px)
 }
 
 /* delete all unreferenced default proxies. A default proxy is unreferenced if
- * its refcount is equal to zero.
+ * its <def_ref> count is equal to zero.
  */
 void defaults_px_destroy_all_unref(void)
 {
@@ -2992,7 +2992,7 @@ void defaults_px_destroy_all_unref(void)
        for (px = cebis_item_first(&defproxy_by_name, conf.name_node, id, struct proxy); px; px = nx) {
                BUG_ON(!(px->cap & PR_CAP_DEF));
                nx = cebis_item_next(&defproxy_by_name, conf.name_node, id, px);
-               if (!px->conf.refcount)
+               if (!px->conf.def_ref)
                        defaults_px_destroy(px);
        }
 }
@@ -3005,7 +3005,7 @@ void defaults_px_detach(struct proxy *px)
 {
        BUG_ON(!(px->cap & PR_CAP_DEF));
        cebis_item_delete(&defproxy_by_name, conf.name_node, id, px);
-       if (!px->conf.refcount)
+       if (!px->conf.def_ref)
                defaults_px_destroy(px);
        /* If not destroyed, <px> can still be accessed in <defaults_list>. */
 }
@@ -3017,7 +3017,7 @@ void defaults_px_ref_all(void)
        for (px = cebis_item_first(&defproxy_by_name, conf.name_node, id, struct proxy);
             px;
             px = cebis_item_next(&defproxy_by_name, conf.name_node, id, px)) {
-               ++px->conf.refcount;
+               ++px->conf.def_ref;
        }
 }
 
@@ -3028,15 +3028,15 @@ void defaults_px_unref_all(void)
        for (px = cebis_item_first(&defproxy_by_name, conf.name_node, id, struct proxy); px; px = nx) {
                nx = cebis_item_next(&defproxy_by_name, conf.name_node, id, px);
 
-               BUG_ON(!px->conf.refcount);
-               if (!--px->conf.refcount)
+               BUG_ON(!px->conf.def_ref);
+               if (!--px->conf.def_ref)
                        defaults_px_destroy(px);
        }
 }
 
 /* Add a reference on the default proxy <defpx> for the proxy <px> Nothing is
  * done if <px> already references <defpx>. Otherwise, the default proxy
- * refcount is incremented by one.
+ * <def_ref> count is incremented by one.
  *
  * This operation is not thread safe. It must only be performed during init
  * stage or under thread isolation.
@@ -3049,11 +3049,11 @@ static inline void defaults_px_ref(struct proxy *defpx, struct proxy *px)
        BUG_ON(px->defpx);
 
        px->defpx = defpx;
-       defpx->conf.refcount++;
+       defpx->conf.def_ref++;
 }
 
 /* Check that <px> can inherits from <defpx> default proxy. If some settings
- * cannot be copied, refcount of the defaults instance is incremented.
+ * cannot be copied, <def_ref> count of the defaults instance is incremented.
  * Inheritance may be impossible due to incompatibility issues. In this case,
  * <errmsg> will be allocated to point to a textual description of the error.
  *
@@ -3086,7 +3086,7 @@ int proxy_ref_defaults(struct proxy *px, struct proxy *defpx, char **errmsg)
         * - It cannot define 'tcp-response content' rules if it
         *   is used to init frontend sections.
         *
-        * If no error is found, refcount of the default proxy is incremented.
+        * If no error is found, <def_ref> count of the default proxy is incremented.
         */
        if ((!LIST_ISEMPTY(&defpx->http_req_rules)        ||
             !LIST_ISEMPTY(&defpx->http_res_rules)        ||
@@ -3149,7 +3149,7 @@ int proxy_ref_defaults(struct proxy *px, struct proxy *defpx, char **errmsg)
 }
 
 /* proxy <px> removes its reference on its default proxy. The default proxy
- * refcount is decremented by one. If it was the last reference, the
+ * <def_ref> count is decremented by one. If it was the last reference, the
  * corresponding default proxy is destroyed. For now this operation is not
  * thread safe and is performed during deinit staged only.
 */
@@ -3157,7 +3157,7 @@ void proxy_unref_defaults(struct proxy *px)
 {
        if (px->defpx == NULL)
                return;
-       if (!--px->defpx->conf.refcount)
+       if (!--px->defpx->conf.def_ref)
                defaults_px_destroy(px->defpx);
        px->defpx = NULL;
 }