MEDIUM: ring: protect the reader's positions against writers
authorWilly Tarreau <w@1wt.eu>
Wed, 28 Feb 2024 16:18:34 +0000 (17:18 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 25 Mar 2024 17:34:19 +0000 (17:34 +0000)
commit2192983ffd6ca0dbfae245ba1fdd90d768f1b89c
treedf194ee60eaa74b7c35d056dbc3b8b7ba8241607
parent73b2436fe65c1245440d685e92a6f1c5103a7704
MEDIUM: ring: protect the reader's positions against writers

The reader now needs to protect the positions it's reading. This is
already done via the readers counter at the beginning of messages,
but as long as the lock is present, this counter is decremented
before starting to parse messages, and incremented at the end.

We must now do that in reverse, first protect the end of the messages,
and only then remove ourselves from the already processed messages, so
that at no point could a writer pass over and possibly overwrite data
we're currently watching.
src/ring.c