]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: backend: use a single variable for removed in srv_cleanup_idle_conns()
authorWilly Tarreau <w@1wt.eu>
Fri, 12 Sep 2025 14:28:58 +0000 (16:28 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 16 Sep 2025 07:23:46 +0000 (09:23 +0200)
Probably due to older code, there's a boolean variable used to set
another one which is then checked. Also the first check is made under
the lock, which is unnecessary. Let's simplify this and use a single
variable. This only makes the code clearer, it doesn't change the output
code.

src/server.c

index dbd60cdbdf43d505c5942dadeee518a389ae8949..1f17e4a0403326fcf8045ed31d1c785ebda222b8 100644 (file)
@@ -7461,19 +7461,16 @@ struct task *srv_cleanup_idle_conns(struct task *task, void *context, unsigned i
                /* check all threads starting with ours */
                for (i = tid;;) {
                        int max_conn;
-                       int j;
-                       int did_remove = 0;
+                       int removed;
 
                        max_conn = (exceed_conns * srv->curr_idle_thr[i]) /
                                   curr_idle + 1;
 
                        HA_SPIN_LOCK(IDLE_CONNS_LOCK, &idle_conns[i].idle_conns_lock);
-                       j = srv_migrate_conns_to_remove(srv, i, max_conn);
-                       if (j > 0)
-                               did_remove = 1;
+                       removed = srv_migrate_conns_to_remove(srv, i, max_conn);
                        HA_SPIN_UNLOCK(IDLE_CONNS_LOCK, &idle_conns[i].idle_conns_lock);
 
-                       if (did_remove)
+                       if (removed)
                                task_wakeup(idle_conns[i].cleanup_task, TASK_WOKEN_OTHER);
 
                        if ((i = ((i + 1 == global.nbthread) ? 0 : i + 1)) == tid)