OPTIM: peers: avoid the locking dance around peer_send_teach_process_msgs()
authorWilly Tarreau <w@1wt.eu>
Tue, 2 Apr 2024 16:27:36 +0000 (18:27 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 3 Apr 2024 07:34:08 +0000 (09:34 +0200)
commit6a2f09de1ceaecb333b59058a16e4c5dcfe1c032
tree4a8ca9d4791be0b81f1cf81a8482bd6789879cb9
parent1ea18fa8a3ab961ea43610e22dda3c87e8f2a67a
OPTIM: peers: avoid the locking dance around peer_send_teach_process_msgs()

In peer_send_msg(), we take a lock before calling
peer_send_teach_process_msgs because of the check on the flags and update
indexes, and the function then drops it then takes it again just to resume
in the same situation, so that on return we can drop it again! Not only
this is absurd because it doubles the costs of taking the lock, it's also
totally inefficient because it takes a write lock while the only usage
that is done with it is to read the indexes! Let's drop the lock from
peer_send_teach_process_msgs() and move it explicitly in its only caller
around the condition, and turn it into a read lock only.
src/peers.c