BUG/MINOR: map/cli: make sure patterns don't vanish under "show map"'s init
authorWilly Tarreau <w@1wt.eu>
Tue, 3 May 2022 13:26:27 +0000 (15:26 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 6 May 2022 16:13:35 +0000 (18:13 +0200)
commit1ae0c43244254a3cf652300413625191d6a9dd4f
treee5b4621425b2aebac21fe865d179c203d3f66f4e
parent2edaace575fa1bdfa760ee41d7d7a87efb3586ae
BUG/MINOR: map/cli: make sure patterns don't vanish under "show map"'s init

When "show map" initializes itself, it first takes the reference to the
starting point under a lock, then releases it before switching to state
STATE_LIST, and takes the lock again. The problem is that it is possible
for another thread to remove the first element during this unlock/lock
sequence, and make the list run anywhere. This is of course extremely
unlikely but not impossible.

Let's initialize the pointer in the STATE_LIST part under the same lock,
which is simpler and more reliable.

This should be backported to all versions.
src/map.c