]> git.kaiwu.me - haproxy.git/commitdiff
OPTIM/MINOR: proxy: remove unnecessary lookup during purge
authorAmaury Denoyelle <adenoyelle@haproxy.com>
Fri, 9 Oct 2026 15:14:03 +0000 (17:14 +0200)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 14 Oct 2026 09:33:41 +0000 (11:33 +0200)
Simplifies backend background deletion in purge task. Call to
be_check_for_deletion() is removed, preventing an unnecessary lookup on
proxies global list.

Instead, only <beconn> member check is necessary. Backend configuration
which could block deletion were already tested via "purge backend".
Also, if backend has been reset to publish state, it is no longer
flagged PR_FL_TO_PURGE.

src/proxy.c

index ad61f804b88b94abef0fa5dbb50ae008f93ff834..c44999813f20fecd1d586a8a8bdca7f5d23c093b 100644 (file)
@@ -559,7 +559,6 @@ struct task *proxy_process_purge(struct task *t, void *context, unsigned int sta
        struct proxy *px = context;
        /* constant for max number of server delete before yield */
        const int max_srv_delete = 50;
-       int ret = 0;
 
        /* Must not dereference <px> before entering thread isolation and
         * checking task state, as proxy_drop() performed outside isolation
@@ -583,12 +582,10 @@ struct task *proxy_process_purge(struct task *t, void *context, unsigned int sta
        }
 
        if (LIST_ISEMPTY(&px->servers_purge) && (px->flags & PR_FL_TO_PURGE)) {
-               /* TODO unnecessary proxy lookup */
-               ret = be_check_for_deletion(px->id, PR_DEL_MODE_SYNC, NULL, NULL);
-               if (ret < 0) {
-                       proxy_cancel_purge(px);
-               }
-               else if (ret > 0) {
+               /* If backend is published again, purge must be cancelled. */
+               BUG_ON(!(px->flags & PR_FL_BE_UNPUBLISHED));
+
+               if (!px->beconn) {
                        ha_notice("Backend '%s' purged.\n", px->id);
                        be_unregister(px);
                        proxy_drop(px);