]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mt_lists: Do nothing in MT_LIST_ADD/MT_LIST_ADDQ if already in list.
authorOlivier Houchard <ohouchard@haproxy.com>
Fri, 20 Sep 2019 12:44:22 +0000 (14:44 +0200)
committerOlivier Houchard <cognet@ci0.org>
Mon, 23 Sep 2019 16:16:08 +0000 (18:16 +0200)
Modify MT_LIST_ADD and MT_LIST_ADDQ to do nothing if the element is already
in a list.

include/common/mini-clist.h

index 642a7a36a5c89051af3e0dcfc67499d317f05ce3..3d519197e44e4e161e8a8cd2ced72d187f57d649 100644 (file)
@@ -221,6 +221,11 @@ struct cond_wordlist {
                                __ha_barrier_store();                      \
                                continue;                                  \
                        }                                                  \
+                       if ((el)->next != (el) || (el)->prev != (el)) {    \
+                               (n)->prev = p;                             \
+                               (lh)->next = n;                            \
+                               break;                                     \
+                       }                                                  \
                        (el)->next = n;                                    \
                        (el)->prev = p;                                    \
                        __ha_barrier_store();                              \
@@ -246,6 +251,11 @@ struct cond_wordlist {
                                __ha_barrier_store();                      \
                                continue;                                  \
                        }                                                  \
+                       if ((el)->next != (el) || (el)->prev != (el)) {    \
+                               p->next = n;                               \
+                               (lh)->prev = p;                            \
+                               break;                                     \
+                       }                                                  \
                        (el)->next = n;                                    \
                        (el)->prev = p;                                    \
                        __ha_barrier_store();                              \