]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
Revert "WIP/MEDIUM: peers: Stop to change the stksess ref_cnt when sending update...
authorChristopher Faulet <cfaulet@haproxy.com>
Wed, 15 Oct 2025 14:16:45 +0000 (16:16 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 21 Oct 2025 13:18:06 +0000 (15:18 +0200)
This reverts commit 871794586716396755dd7d77a6597be6cee97363.

src/peers.c
src/stick_table.c

index a3f67426552aa7de368ea315b18a38208efdccbd..ab230d43cfb7d655ca9712b4032ecb46380c8ac0 100644 (file)
@@ -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 <last> marker before <ts> to process it again
index 7559eba8420ba0d56516bc315414b750390a8a90..8329b69b0c55465787b0384695278a0a0edb85e7 100644 (file)
@@ -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);
                        }