BUG/MEDIUM: lists: Avoid an infinite loop in MT_LIST_TRY_ADDQ().
authorOlivier Houchard <cognet@ci0.org>
Thu, 18 Feb 2021 22:55:30 +0000 (23:55 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 5 Mar 2021 06:49:44 +0000 (07:49 +0100)
commit3c2e684aa77084c85d517328c011955864bed0d6
treecfbaf1eef71fbe42961c4ea314b3ae74b3d4ea0b
parentba90d530cf804d29f65d62e60242567031c9286d
BUG/MEDIUM: lists: Avoid an infinite loop in MT_LIST_TRY_ADDQ().

In MT_LIST_TRY_ADDQ(), deal with the "prev" field of the element before the
"next". If the element is the first in the list, then its next will
already have been locked when we locked list->prev->next, so locking it
again will fail, and we'll start over and over.

This should be backported to 2.3.

(cherry picked from commit 5567f41d0ab61dd6843535edc8081407d599024d)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit 6f682bea6ab08830d17ef3e973be6cc4d2474e69)
[wt: in 2.2 the macro is there, it's MT_LIST_ADDQ() which was later renamed]
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit cd721385380410d9432d7fba9fe257415bfb09f2)
[wt: also present in 2.1]
Signed-off-by: Willy Tarreau <w@1wt.eu>
include/common/mini-clist.h