]> git.kaiwu.me - haproxy.git/commitdiff
OPTIM/MINOR: proxy: do not init proxy management task if unused
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 2 Dec 2025 16:29:19 +0000 (17:29 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Tue, 23 Dec 2025 15:35:49 +0000 (16:35 +0100)
Each proxy has its owned task for internal purpose. Currently, it is
only used either by frontends or if a stick-table is present.

This commit rendres the task allocation optional to only the required
case. Thus, it is not allocated anymore for backend only proxies without
stick-table.

src/cfgparse.c

index 5a704084ee795cb5b0198e11d9420cc48e109de6..8b996f238006cb6f8c234d2898c900747005e310 100644 (file)
@@ -4357,16 +4357,21 @@ init_proxies_list_stage2:
                                bind_conf->xprt->destroy_bind_conf(bind_conf);
                }
 
-               /* create the task associated with the proxy */
-               curproxy->task = task_new_anywhere();
-               if (curproxy->task) {
-                       curproxy->task->context = curproxy;
-                       curproxy->task->process = manage_proxy;
-                       curproxy->flags |= PR_FL_READY;
-               } else {
-                       ha_alert("Proxy '%s': no more memory when trying to allocate the management task\n",
-                                curproxy->id);
-                       cfgerr++;
+               /* Create the task associated with the proxy. Only necessary
+                * for frontend or if a stick-table is defined.
+                */
+               if ((curproxy->cap & PR_CAP_FE) || (curproxy->table && curproxy->table->current)) {
+                       curproxy->task = task_new_anywhere();
+                       if (curproxy->task) {
+                               curproxy->task->context = curproxy;
+                               curproxy->task->process = manage_proxy;
+                               curproxy->flags |= PR_FL_READY;
+                       }
+                       else {
+                               ha_alert("Proxy '%s': no more memory when trying to allocate the management task\n",
+                                        curproxy->id);
+                               cfgerr++;
+                       }
                }
        }