forked from squid-cache/squid
-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix %err_code/%err_detail for some error:transaction-end-before-headers #270
Open
eduard-bagdasaryan
wants to merge
5
commits into
master
Choose a base branch
from
SQUID-977-no-err-code-for-transaction-end-before-headers-2
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7ac0676
Fix %err_code/%err_detail for some error:transaction-end-before-headers
eduard-bagdasaryan 42401fc
Unified ConnStateData::terminateAll() calls
eduard-bagdasaryan b246054
Refactored ConnStateData::terminateAll()
eduard-bagdasaryan 34fdf47
Check that everything was cleaned-up in a second terminateAll()
eduard-bagdasaryan 1ccbfd1
Missed an USE_OPENSSL preprocessor check
eduard-bagdasaryan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -594,8 +594,7 @@ ConnStateData::swanSong() | |
flags.readMore = false; | ||
clientdbEstablished(clientConnection->remote, -1); /* decrement */ | ||
|
||
terminateAll(ERR_NONE, LogTagsErrors()); | ||
checkLogging(); | ||
terminateAll(ERR_STREAM_FAILURE, LogTagsErrors()); | ||
|
||
// XXX: Closing pinned conn is too harsh: The Client may want to continue! | ||
unpinConnection(true); | ||
|
@@ -3904,63 +3903,59 @@ ConnStateData::unpinConnection(const bool andClose) | |
void | ||
ConnStateData::terminateAll(const Error &rawError, const LogTagsErrors <e) | ||
{ | ||
Assure(rawError); | ||
|
||
auto error = rawError; // (cheap) copy so that we can detail | ||
// We detail even ERR_NONE: There should be no transactions left, and | ||
// detailed ERR_NONE will be unused. Otherwise, this detail helps in triage. | ||
if (error.details.empty()) { | ||
static const auto d = MakeNamedErrorDetail("WITH_CLIENT"); | ||
error.details.push_back(d); | ||
} | ||
|
||
debugs(33, 3, pipeline.count() << '/' << pipeline.nrequests << " after " << error); | ||
|
||
if (pipeline.empty()) { | ||
bareError.update(error); // XXX: bareLogTagsErrors | ||
} else { | ||
// We terminate the current CONNECT/PUT/etc. context below, logging any | ||
// error details, but that context may leave unparsed bytes behind. | ||
// Consume them to stop checkLogging() from logging them again later. | ||
const auto intputToConsume = | ||
#if USE_OPENSSL | ||
parsingTlsHandshake ? "TLS handshake" : // more specific than CONNECT | ||
#endif | ||
bodyPipe ? "HTTP request body" : | ||
pipeline.back()->mayUseConnection() ? "HTTP CONNECT" : | ||
nullptr; | ||
|
||
while (const auto context = pipeline.front()) { | ||
context->noteIoError(error, lte); | ||
context->finished(); // cleanup and self-deregister | ||
assert(context != pipeline.front()); | ||
} | ||
const auto leftovers = handleLeftovers(); | ||
|
||
while (const auto context = pipeline.front()) { | ||
context->noteIoError(error, lte); | ||
context->finished(); // cleanup and self-deregister | ||
assert(context != pipeline.front()); | ||
} | ||
|
||
if (intputToConsume && !inBuf.isEmpty()) { | ||
debugs(83, 5, "forgetting client " << intputToConsume << " bytes: " << inBuf.length()); | ||
inBuf.clear(); | ||
if (!terminatedAll) { | ||
if (leftovers || !pipeline.nrequests) { | ||
/* Create a temporary ClientHttpRequest object. Its destructor will log. */ | ||
ClientHttpRequest http(this); | ||
http.req_sz = inBuf.length(); | ||
// XXX: Or we died while waiting for the pinned connection to become idle. | ||
http.setErrorUri("error:transaction-end-before-headers"); | ||
http.updateError(error); | ||
} | ||
} | ||
|
||
terminatedAll = true; | ||
|
||
clientConnection->close(); | ||
} | ||
|
||
/// log the last (attempt at) transaction if nobody else did | ||
void | ||
ConnStateData::checkLogging() | ||
/// whether we should ignore unparsed inBuf bytes | ||
/// during transaction termination | ||
bool | ||
ConnStateData::handleLeftovers() | ||
{ | ||
// to simplify our logic, we assume that terminateAll() has been called | ||
assert(pipeline.empty()); | ||
const auto intputToConsume = | ||
#if USE_OPENSSL | ||
parsingTlsHandshake ? "TLS handshake" : // more specific than CONNECT | ||
#endif | ||
bodyPipe ? "HTTP request body" : | ||
(!pipeline.empty() && pipeline.back()->mayUseConnection()) ? "HTTP CONNECT" : | ||
nullptr; | ||
|
||
// do not log connections that closed after a transaction (it is normal) | ||
// TODO: access_log needs ACLs to match received-no-bytes connections | ||
if (pipeline.nrequests && inBuf.isEmpty()) | ||
return; | ||
if (intputToConsume && !inBuf.isEmpty()) { | ||
debugs(83, 5, "forgetting client " << intputToConsume << " bytes: " << inBuf.length()); | ||
inBuf.clear(); | ||
} | ||
|
||
/* Create a temporary ClientHttpRequest object. Its destructor will log. */ | ||
ClientHttpRequest http(this); | ||
http.req_sz = inBuf.length(); | ||
// XXX: Or we died while waiting for the pinned connection to become idle. | ||
http.setErrorUri("error:transaction-end-before-headers"); | ||
http.updateError(bareError); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like bareError became used after removing checkLogging() - we can probably remove it too. |
||
return !inBuf.isEmpty(); | ||
} | ||
|
||
bool | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This flag prevents from logging twice a transaction with zero bytes (!pipeline.nrequests is true). The second terminateAll() call is from swanSong(). We could also reset inBuf below (so that leftovers would be false upon the second call).