]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: stick-tables: Fix return value for __stksess_kill()
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 14 Nov 2025 10:48:02 +0000 (11:48 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 14 Nov 2025 10:56:14 +0000 (11:56 +0100)
The commit 9938fb9c7 ("BUG/MEDIUM: stick-tables: Fix race with peers when
killing a sticky session") introduced a regression.

__stksess_kill() must always return 0 if the session cannot be released. But
when the ref_cnt is tested under the update lock, a success is reported if
the session is still in-used. 0 must be returned in that case.

This bug is harmless because callers never use the return value of
__stksess_kill() or stksess_kill().

This bug must be backported as far as 3.0.

src/stick_table.c

index 240f10c75bee95cbd57626bb41480ff0973ad8a6..be5db167b7e1078873b891aaf89d081e0af27eec 100644 (file)
@@ -131,6 +131,7 @@ void stksess_free(struct stktable *t, struct stksess *ts)
 int __stksess_kill(struct stktable *t, struct stksess *ts)
 {
        int updt_locked = 0;
+       int removed = 0;
 
        if (HA_ATOMIC_LOAD(&ts->ref_cnt))
                return 0;
@@ -153,11 +154,12 @@ int __stksess_kill(struct stktable *t, struct stksess *ts)
        eb32_delete(&ts->upd);
        ebmb_delete(&ts->key);
        __stksess_free(t, ts);
+       removed = 1;
 
   out_unlock:
        if (updt_locked)
                HA_RWLOCK_WRUNLOCK(STK_TABLE_UPDT_LOCK, &t->updt_lock);
-       return 1;
+       return removed;
 }
 
 /*