]> git.kaiwu.me - haproxy.git/commitdiff
BUG/MINOR: stick-table: do not count the lookup itself in table_trackers()
authorWilly Tarreau <w@1wt.eu>
Wed, 30 Sep 2026 09:19:05 +0000 (11:19 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 30 Sep 2026 14:11:24 +0000 (16:11 +0200)
In 1.8 when adding multi-threading support with commit 819fc6f563
("MEDIUM: threads/stick-tables: handle multithreads on stick tables"),
the entry's ref_cnt was incremented by one on all trackers and accesses,
and smp_fetch_sc_trackers() learned to return one less than the visible
value so as not to count itself in it.

One of them was missed: table_trackers() returns the number of trackers
without subtracting one so it's always one above the real value. Let's
adjust it like other places do.

This can be backported to all versions.

src/stick_table.c

index ca44cb4303aa346d5aea86934112e7652e17823e..9c447bb99f73a960c2feecbf04158dd5a01e4452 100644 (file)
@@ -2710,7 +2710,7 @@ static int sample_conv_table_trackers(const struct arg *arg_p, struct sample *sm
        if (!ts)
                return 1;
 
-       smp->data.u.sint = HA_ATOMIC_LOAD(&ts->ref_cnt);
+       smp->data.u.sint = HA_ATOMIC_LOAD(&ts->ref_cnt) - 1; // don't count ourselves
 
        stktable_release(t, ts);
        return 1;