]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: stick-tables: Optimize the expiration process a bit.
authorOlivier Houchard <ohouchard@haproxy.com>
Wed, 5 Nov 2025 18:18:21 +0000 (19:18 +0100)
committerOlivier Houchard <cognet@ci0.org>
Wed, 5 Nov 2025 18:22:11 +0000 (19:22 +0100)
In process_tables_expire(), if the table we're analyzing still has
entries, and thus should be put back into the tree, do not put it in the
mt_list, to have it put back into the tree the next time the task runs.
There is no problem with putting it in the tree right away, as either
the next expiration is in the future, or we handled the maximum number
of expirations per task call and we're about to stop, anyway.

This does not need to be backported.

src/stick_table.c

index 3f8eeb229723b862c5ec80bc491c0c150246b810..d8c5b4a55ff5f339d9b45900dc9bc328ab7929a7 100644 (file)
@@ -1128,14 +1128,13 @@ struct task *process_tables_expire(struct task *task, void *context, unsigned in
                                HA_ATOMIC_CAS(&t->shards[shard].next_exp, &old_exp, next_exp_table);
                        }
 
-                       eb32_delete(table_eb);
-                       table_eb->key = TICK_ETERNITY;
                        /*
-                        * If there's more entry, just put it back into the list,
-                        * it'll go back into the tree the next time the task runs.
+                        * Move the table to its next expiration date, if any.
                         */
+                       eb32_delete(table_eb);
+                       table_eb->key = next_exp_table;
                        if (next_exp_table != TICK_ETERNITY)
-                               MT_LIST_TRY_APPEND(&per_bucket[shard].toadd_tables, &t->shards[shard].in_bucket_toadd);
+                               eb32_insert(&ps->tables, table_eb);
                }
                table_eb = tmpnode;
        }