]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: list: correct fix for LIST_POP_LOCKED's removal of last element
authorWilly Tarreau <w@1wt.eu>
Thu, 28 Feb 2019 15:51:28 +0000 (16:51 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 28 Feb 2019 15:51:28 +0000 (16:51 +0100)
As seen with Olivier, in the end the fix in commit 285192564 ("BUG/MEDIUM:
list: fix LIST_POP_LOCKED's removal of the last pointer") is wrong,
the code there was right but the bug was triggered by another bug in
LIST_ADDQ_LOCKED() which doesn't properly update the list's head by
inserting in the wrong order.

This will have to be backported if the commit above is backported.

include/common/mini-clist.h

index 3b1f599ca2a938a575ccfbd8be576833d403a406..5cf23df1ba7c8b32844014e3b512b7b8e27f9731 100644 (file)
@@ -216,9 +216,9 @@ struct cond_wordlist {
                        (el)->n = n;                                       \
                        (el)->p = p;                                       \
                        __ha_barrier_store();                              \
-                       n->p = (el);                                       \
+                       n->n = (el);                                       \
                        __ha_barrier_store();                              \
-                       p->n = (el);                                       \
+                       p->p = (el);                                       \
                        __ha_barrier_store();                              \
                        break;                                             \
                }                                                          \
@@ -299,7 +299,7 @@ struct cond_wordlist {
                                 __ha_barrier_store();                     \
                                 continue;                                 \
                         }                                                 \
-                        p2 = HA_ATOMIC_XCHG(&n->p, LLIST_BUSY);           \
+                        p2 = HA_ATOMIC_XCHG(&n2->p, LLIST_BUSY);          \
                         if (p2 == LLIST_BUSY) {                           \
                                 n->n = n2;                                \
                                 n->p = p;                                 \