]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: stick-tables: Stop if stktable_trash_oldest() fails.
authorOlivier Houchard <ohouchard@haproxy.com>
Tue, 14 Oct 2025 16:51:32 +0000 (18:51 +0200)
committerOlivier Houchard <cognet@ci0.org>
Mon, 20 Oct 2025 13:04:47 +0000 (15:04 +0200)
In stksess_new(), if the table is full, we call stktable_trash_oldest()
to remove a few entries so that we have some room for a new one.
It is unlikely, but possible, that stktable_trash_oldest() will fail. If
so, just give up and do not add the new entry, instead of adding it
anyway.
Give up if stktable_trash_oldest() fails to free any entry

src/stick_table.c

index e59e8b8fd9a00b5b735bb4b11519c6babff98981..2d889b48a0bb86bb16c3e45417fa3a0e44720794 100644 (file)
@@ -443,11 +443,13 @@ struct stksess *stksess_new(struct stktable *t, struct stktable_key *key)
                        HA_ATOMIC_DEC(&t->current);
                        return NULL;
                }
-               /* note that it may fail to find any releasable slot due to
-                * locking contention but it's not a problem in practice,
-                * these will be recovered later.
-                */
-               stktable_trash_oldest(t);
+               if (stktable_trash_oldest(t) < 1) {
+                       /*
+                        * If we did not manage to purge any entry, give up.
+                        */
+                       HA_ATOMIC_DEC(&t->current);
+                       return NULL;
+               }
        }
 
        ts = pool_alloc(t->pool);