]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MEDIUM: peers: only read-lock peer_send_teachmsgs()
authorWilly Tarreau <w@1wt.eu>
Mon, 7 Aug 2023 17:39:27 +0000 (19:39 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 11 Aug 2023 17:03:35 +0000 (19:03 +0200)
commit29982ea769432f78666b19f3ae330b8a15ddeb08
tree536d977f7226518675a78e06f142c072a9f4f7ac
parentd4f8286e45618fa1017c79e32950487f1d1ad4d4
MEDIUM: peers: only read-lock peer_send_teachmsgs()

This function doesn't need to be write-locked. It performs a lookup
of the next update at its index, atomically updates the ref_cnt on
the stksess, updates some shared_table fields on the local thread,
and updates the table's commitupdate. Now that this update is atomic
we don't need to keep the write lock during that period. In addition
this function's callers do not rely on the write lock to be held
either since it was droped during peer_send_updatemsg() anyway.

Now, when the function is entered with a write lock, it's downgraded
to a read lock, otherwise a read lock is grabbed. Updates are looked
up under the read lock and the message is sent without the lock. The
commitupdate is still performed under the read lock (so as not to
break the code too much), and the write lock is re-acquired when
leaving if needed. This allows multiple peers to look up updates in
parallel and to avoid stalling stick-table lookups.
src/peers.c