From: Willy Tarreau Date: Fri, 12 Sep 2025 14:28:58 +0000 (+0200) Subject: CLEANUP: backend: use a single variable for removed in srv_cleanup_idle_conns() X-Git-Tag: v3.3-dev9~89 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=efe519ab895042bd7efa1077bc36b3e0fec61520;p=thirdparty%2Fhaproxy.git CLEANUP: backend: use a single variable for removed in srv_cleanup_idle_conns() 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. --- diff --git a/src/server.c b/src/server.c index dbd60cdbd..1f17e4a04 100644 --- a/src/server.c +++ b/src/server.c @@ -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)