]> git.ipfire.org Git - thirdparty/squid.git/commit
Properly track (and mark) truncated store entries (#909)
authorEduard Bagdasaryan <eduard.bagdasaryan@measurement-factory.com>
Sat, 9 Oct 2021 21:31:53 +0000 (21:31 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Sun, 10 Oct 2021 00:21:15 +0000 (00:21 +0000)
commitba3fe8d9bc8d35c4b04cecf30cfc7288c57e685c
treed0d5200b12f6e23b78d9ef12d73c2672056be050
parenta2897a3a55455e926e6a4488221a581f814d42b9
Properly track (and mark) truncated store entries (#909)

## Responses with truncated bodies

Squid used an error-prone approach to identifying truncated responses:
The response is treated as whole[^1] unless somebody remembers to mark
it as truncated. This dangerous default naturally resulted in bugs where
truncated responses are treated as complete under various conditions.

This change reverses that approach: Responses not explicitly marked as
whole are treated as truncated. This change affects all Squid-server
FwsState-dispatched communications: HTTP, FTP, Gopher, and WHOIS. It
also affects responses received from the adaptation services.

Squid still tries to deliver responses with truncated bodies to clients
in most cases (no changes are expected/intended in that area).

[^1]: A better word to describe a "whole" response would be "complete",
    but several key Squid APIs use "complete" to mean "no more content
    is coming", misleading developers into thinking that a "completed"
    response has all the expected bytes and may be cached/shared/etc.

## Related access-logging improvements

Transactions that failed due to origin server or peer timeout (a common
source of truncation) are now logged with a _TIMEOUT %Ss suffix and
ERR_READ_TIMEOUT/WITH_SRV %err_code/%err_detail.

Transactions prematurely canceled by Squid during client-Squid
communication (usually due to various timeouts) now have WITH_CLT
default %err_detail. This detail helps distinguish otherwise
similarly-logged problems that may happen when talking to the client or
to the origin server/peer.

## Other

FwdState now (indirectly) complete()s truncated entries _after_
releasing/adjusting them so that invokeHandlers() and others do not get
a dangerous glimpse at a seemingly OK entry before its release().
14 files changed:
src/FwdState.cc
src/FwdState.h
src/Store.h
src/client_side.cc
src/client_side_request.cc
src/client_side_request.h
src/clients/Client.cc
src/clients/Client.h
src/clients/FtpGateway.cc
src/clients/FtpRelay.cc
src/gopher.cc
src/http.cc
src/store.cc
src/whois.cc