]> git.ipfire.org Git - thirdparty/squid.git/commit - src/adaptation/icap/ModXact.cc
Preserve caller context across (and improve) deferred reads (#1025)
authorEduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Fri, 13 May 2022 03:10:32 +0000 (03:10 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Fri, 13 May 2022 08:46:59 +0000 (08:46 +0000)
commita928fdfda5ada32c76878b8ef3bde78c808a0bed
tree845e284c625a557a7f2c3e254edbaa224d08032b
parentad05b958fa522d73023eebf37dbfbf57829a9507
Preserve caller context across (and improve) deferred reads (#1025)

The transaction context was not saved/restored when dealing with
deferred reads initiated by events like the DelayPools::Update() event.
To fix this, we refactored MemObject::delayRead() and its descendants to
use an AsyncCall, which automatically stores/restores code context.

Using explicit async callbacks highlighted the danger of passing
Connection object via CommRead that does not maintain a closure
callback. There was also a related "stuck transaction" suspicion
documented in DeferredReadManager::kickARead(). Fortunately, all these
problems could now be solved by removing DeferredRead and CommRead
classes! The delayed readers already store the Connection object,
maintain closure callbacks, and have to check stored Connection validity
before reading anyway. The general/centralized delayed reading logic is
not really about reading and Connections (those parts are handled by
transaction-specific code) but about triggering reading attempts.
Asynchronous calls are perfect (and sufficient) for doing that.

Also fixed Delay Pools for Gopher: delayAwareRead() was initiated only
once from gopherSendComplete() and the subsequent read calls were
delay-unaware (i.e. immediate) reads.

Also fixed a Delay Pools problem with active transactions: A transaction
started with Delay Pools on becomes stuck if a reconfiguration turns
Delay Pools off.

Also refactored the existing AsyncCall FIFO intrusive storage, making
its reuse possible (and marked one candidate with a TODO).
43 files changed:
src/CommRead.h [deleted file]
src/CompositePoolNode.h
src/DelayId.cc
src/DelayId.h
src/DelayIdComposite.h
src/DelayPool.cc
src/DelayTagged.cc
src/DelayTagged.h
src/DelayVector.cc
src/DelayVector.h
src/DiskIO/DiskDaemon/DiskdIOStrategy.cc
src/DiskIO/DiskThreads/DiskThreadsDiskFile.cc
src/Makefile.am
src/MemObject.cc
src/MemObject.h
src/Store.h
src/adaptation/icap/ModXact.cc
src/base/AsyncCall.h
src/base/AsyncCallList.cc [new file with mode: 0644]
src/base/AsyncCallList.h [new file with mode: 0644]
src/base/AsyncCallQueue.cc
src/base/AsyncCallQueue.h
src/base/DelayedAsyncCalls.cc [new file with mode: 0644]
src/base/DelayedAsyncCalls.h [new file with mode: 0644]
src/base/Makefile.am
src/base/forward.h
src/clients/Client.cc
src/clients/Client.h
src/clients/FtpClient.cc
src/clients/FtpClient.h
src/comm.cc
src/delay_pools.cc
src/gopher.cc
src/http.cc
src/http.h
src/mgr/Forwarder.cc
src/mgr/StoreToCommWriter.cc
src/store.cc
src/tests/stub_DelayId.cc
src/tests/stub_MemObject.cc
src/tests/stub_comm.cc
src/tests/stub_store.cc
src/tunnel.cc