]> git.ipfire.org Git - thirdparty/squid.git/commit - src/store_client.cc
Fix store_client caller memory leak on certain errors (#1347)
authorAlex Rousskov <rousskov@measurement-factory.com>
Tue, 27 Jun 2023 22:47:36 +0000 (22:47 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Wed, 28 Jun 2023 02:40:45 +0000 (02:40 +0000)
commit6ec49cda026b3597edcf56a6463048523c5d2d9b
tree1773a15e6466574f47fccb28a0660a3948553700
parent49cd4f7c53f2308fd0e68687f44fad196c4eba8c
Fix store_client caller memory leak on certain errors (#1347)

When a storeUnregister() code path destroys store_client before the
latter has a chance to deliver the answer, the cbdataReferenceDone()
call in store_client::finishCallback() is not reached, keeping the
callback data (e.g., clientReplyContext) alive forever. These
storeClientCopy() "cancellations" may happen, for example, when the
client-to-Squid connection is closed while store_client waits for Store.

Use CallbackData to guarantee cbdataReferenceDone() when store_client is
destructed before it can finishCallback(). These synchronous callbacks
will be replaced with AsyncCalls. For now, we use the "discouraged"
CallbackData API to accommodate the existing legacy callbacks.

Probably broken since 2002 commit fa80a8e.
src/StoreClient.h
src/store_client.cc