]> git.ipfire.org Git - thirdparty/squid.git/commit
Bug 5169: StoreMap.cc:517 "!s.reading()" assertion (#918)
authorAlex Rousskov <rousskov@measurement-factory.com>
Sun, 24 Oct 2021 10:16:17 +0000 (10:16 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Sun, 24 Oct 2021 17:43:00 +0000 (17:43 +0000)
commit5210df43850ec0e3bee322fc61efdad7c4804ee7
tree194d5497d21cb481067cc6512c8f125b9785b776
parent4647c8bda42dd52a1a7fd8d70dae4a06e75ba8de
Bug 5169: StoreMap.cc:517 "!s.reading()" assertion (#918)

unlockSharedAndSwitchToExclusive() was not properly failing when future
readers violated preconditions for obtaining an exclusive lock:

- `if (!readers)` means no old readers
+ `if (!readLevel)` means no old readers and nobody is becoming a reader

That missing "becoming a reader" condition covers a lockShared() caller
that had passed their writeLevel test before we incremented writeLevel
to lock other lockShared() callers out. That caller increments `readers`
while unlockSharedAndSwitchToExclusive() makes `writing` true.

Introduced in commit 1af789e due to poor code duplication. This change
also removes that code duplication by adding finalizeExclusive().
src/ipc/ReadWriteLock.cc
src/ipc/ReadWriteLock.h