MEDIUM: queue: get rid of the pendconn lock
authorWilly Tarreau <w@1wt.eu>
Thu, 26 Jul 2018 06:23:24 +0000 (08:23 +0200)
committerWilly Tarreau <w@1wt.eu>
Thu, 26 Jul 2018 15:32:51 +0000 (17:32 +0200)
commit3201e4e42821a019702a0c22deade2c90e13cd2a
treef5a315683c8cb76e52550e1859192f9c5397d270
parent7c6f8a2b0d798cf5fadd93325282446452494216
MEDIUM: queue: get rid of the pendconn lock

This lock was necessary to manipulate the pendconn element between
concurrent places, but was causing great difficulties in the list walk
by having to iterate over multiple entries instead of being able to
safely pick the first one (in fact the first element was always the
right one but the locking model was hard to prove).

Here since we know we can always rely on the queue's locks, we take
the queue's lock every time we need to modify the element. In practice
it was already the case everywhere except in pendconn_dequeue() which
only works on an element that was already detached. This function had
to be protected against the risk of meeting an incompletely detached
element (which could be unlinked but not yet assigned). By taking the
queue lock around the LIST_ISEMPTY test, it's enough to ensure that a
concurrent thread either didn't begin or had completed the operation.

The true benefit really is in pendconn_process_next_strm() where we
can again safely work with the first element of each queue. This will
significantly simplify next updates to this code.
include/common/hathreads.h
include/types/queue.h
src/queue.c