From 53d8d28fdd6bde65513548bf2fcfebd398b32b68 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Wed, 15 Oct 2025 16:16:45 +0200 Subject: [PATCH] Revert "WIP/MEDIUM: peers: Stop to change the stksess ref_cnt when sending update messages" This reverts commit 871794586716396755dd7d77a6597be6cee97363. --- src/peers.c | 5 ++++- src/stick_table.c | 13 +++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/peers.c b/src/peers.c index a3f674265..ab230d43c 100644 --- a/src/peers.c +++ b/src/peers.c @@ -1591,8 +1591,11 @@ int peer_send_teachmsgs(struct appctx *appctx, struct peer *p, struct shared_tab applet_have_more_data(appctx); ret = -1; } - else + else { + HA_ATOMIC_INC(&ts->ref_cnt); ret = peer_send_updatemsg(st, appctx, ts, st->update_id, new_pushed, use_timed); + HA_ATOMIC_DEC(&ts->ref_cnt); + } if (ret <= 0) { /* Insert marker before to process it again diff --git a/src/stick_table.c b/src/stick_table.c index 7559eba84..8329b69b0 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -141,6 +141,10 @@ int __stksess_kill(struct stktable *t, struct stksess *ts) /* ... and that we didn't leave the update list for the tree */ if (MT_LIST_INLIST(&ts->upd)) { link = mt_list_lock_full(&ts->upd); + if (HA_ATOMIC_LOAD(&ts->ref_cnt)) { + mt_list_unlock_full(&ts->upd, link); + goto out; + } mt_list_unlock_link(link); mt_list_unlock_self(&ts->upd); } @@ -381,8 +385,13 @@ int stktable_trash_oldest(struct stktable *t) * Peers will lock the element. So to the same here to avoid any conflict */ MT_LIST_DELETE(&ts->pend_updts); + if (MT_LIST_INLIST(&ts->upd)) { link = mt_list_lock_full(&ts->upd); + if (HA_ATOMIC_LOAD(&ts->ref_cnt)) { + mt_list_unlock_full(&ts->upd, link); + goto requeue; + } mt_list_unlock_link(link); mt_list_unlock_self(&ts->upd); } @@ -1038,6 +1047,10 @@ struct task *process_tables_expire(struct task *task, void *context, unsigned in MT_LIST_DELETE(&ts->pend_updts); if (MT_LIST_INLIST(&ts->upd)) { link = mt_list_lock_full(&ts->upd); + if (HA_ATOMIC_LOAD(&ts->ref_cnt)) { + mt_list_unlock_full(&ts->upd, link); + goto requeue; + } mt_list_unlock_link(link); mt_list_unlock_self(&ts->upd); }