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
FtpGateway: Unexpected ABORTED suffixes in %Ss #267
Open
eduard-bagdasaryan
wants to merge
8
commits into
master
Choose a base branch
from
SQUID-1012-unexpected-aborted-suffixes-1
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 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2759372
FtpGateway: Unexpected ABORTED suffixes in %Ss
eduard-bagdasaryan 74cf59a
Take adaptation into account before completeForwarding()
eduard-bagdasaryan e322b47
Complete StoreEntry from FwdState::markStoredReplyAsWhole()
eduard-bagdasaryan 43fbb6d
Add missing markStoredReplyAsWhole() in FTP code
eduard-bagdasaryan 03e4d09
Undone an out-of-scope change
eduard-bagdasaryan 5ebd652
Made Ftp::DataChannel::payloadSeen unsigned
eduard-bagdasaryan 3b1c523
Undone Ftp::Gateway::completeForwarding() fix
eduard-bagdasaryan abe83b9
Adjusted a variable type and removed an always-true 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
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
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 |
---|---|---|
|
@@ -970,8 +970,10 @@ Ftp::Gateway::processReplyBody() | |
return; | ||
} | ||
|
||
const auto csize = data.readBuf->contentSize(); | ||
rousskov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/* Directory listings are special. They write ther own headers via the error objects */ | ||
if (!flags.http_header_sent && data.readBuf->contentSize() >= 0 && !flags.isdir) | ||
if (!flags.http_header_sent && csize >= 0 && !flags.isdir) | ||
rousskov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
appendSuccessHeader(); | ||
|
||
if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) { | ||
|
@@ -1000,14 +1002,17 @@ Ftp::Gateway::processReplyBody() | |
parseListing(); | ||
maybeReadVirginBody(); | ||
return; | ||
} else if (const auto csize = data.readBuf->contentSize()) { | ||
} else if (csize) { | ||
writeReplyBody(data.readBuf->content(), csize); | ||
debugs(9, 5, "consuming " << csize << " bytes of readBuf"); | ||
data.readBuf->consume(csize); | ||
} | ||
|
||
entry->flush(); | ||
|
||
if (csize && theSize >= 0 && data.payloadSeen >= theSize) | ||
markParsedVirginReplyAsWhole("whole virgin body"); | ||
|
||
maybeReadVirginBody(); | ||
} | ||
|
||
|
@@ -1151,6 +1156,7 @@ Ftp::Gateway::start() | |
SBuf realm(ftpRealm()); // local copy so SBuf will not disappear too early | ||
const auto reply = ftpAuthRequired(request.getRaw(), realm, fwd->al); | ||
entry->replaceHttpReply(reply); | ||
fwd->markStoredReplyAsWhole("checkAuth failed"); | ||
serverComplete(); | ||
return; | ||
} | ||
|
@@ -1257,6 +1263,7 @@ Ftp::Gateway::loginFailed() | |
|
||
// add it to the store entry for response.... | ||
entry->replaceHttpReply(newrep); | ||
fwd->markStoredReplyAsWhole("loginFailed"); | ||
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. This fixes the 'entry->completeTruncated()' problem and adding 'WITH_CLIENT' to err_detail. I fixed other cases in FtpGateway as well. |
||
serverComplete(); | ||
} | ||
|
||
|
@@ -2225,6 +2232,7 @@ Ftp::Gateway::completedListing() | |
ctrl.message = nullptr; | ||
entry->replaceHttpReply(ferr.BuildHttpReply()); | ||
entry->flush(); | ||
fwd->markStoredReplyAsWhole("completedListing"); | ||
entry->unlock("Ftp::Gateway"); | ||
} | ||
|
||
|
@@ -2239,8 +2247,9 @@ ftpReadTransferDone(Ftp::Gateway * ftpState) | |
if (ftpState->flags.listing) { | ||
ftpState->completedListing(); | ||
/* QUIT operation handles sending the reply to client */ | ||
} else { | ||
ftpState->markParsedVirginReplyAsWhole("ftpReadTransferDone code 226 or 250"); | ||
} | ||
ftpState->markParsedVirginReplyAsWhole("ftpReadTransferDone code 226 or 250"); | ||
ftpSendQuit(ftpState); | ||
} else { /* != 226 */ | ||
debugs(9, DBG_IMPORTANT, "Got code " << code << " after reading data"); | ||
|
@@ -2272,7 +2281,6 @@ ftpWriteTransferDone(Ftp::Gateway * ftpState) | |
} | ||
|
||
ftpState->entry->timestampsSet(); /* XXX Is this needed? */ | ||
ftpState->markParsedVirginReplyAsWhole("ftpWriteTransferDone code 226 or 250"); | ||
ftpSendReply(ftpState); | ||
} | ||
|
||
|
@@ -2401,6 +2409,7 @@ ftpFail(Ftp::Gateway *ftpState) | |
delete ftperr; | ||
|
||
ftpState->entry->replaceHttpReply(newrep); | ||
ftpState->fwd->markStoredReplyAsWhole("ftpFail"); | ||
ftpSendQuit(ftpState); | ||
} | ||
|
||
|
@@ -2480,6 +2489,8 @@ ftpSendReply(Ftp::Gateway * ftpState) | |
|
||
ftpState->entry->replaceHttpReply(err.BuildHttpReply()); | ||
|
||
ftpState->fwd->markStoredReplyAsWhole("ftpSendReply"); | ||
|
||
ftpSendQuit(ftpState); | ||
} | ||
|
||
|
@@ -2639,7 +2650,7 @@ Ftp::Gateway::completeForwarding() | |
{ | ||
if (fwd == nullptr || flags.completed_forwarding) { | ||
debugs(9, 3, "avoid double-complete on FD " << | ||
(ctrl.conn ? ctrl.conn->fd : -1) << ", Data FD " << data.conn->fd << | ||
(ctrl.conn ? ctrl.conn->fd : -1) << ", Data FD " << (data.conn ? data.conn->fd : -1) << | ||
rousskov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
", this " << this << ", fwd " << fwd); | ||
return; | ||
} | ||
|
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.
I checked that FwdState::completed() would hit the 'e->store_status == STORE_OK' assertion (added in e322b47) and removed that assertion. In that test (where server responds with an HTTP 502 reply) I adjusted the code so that reforward() would return 'true' when called the first time (so that markStoredReplyAsWhole() does not complete the entry). Also note that this scenario should never happen in FTP because reforward() always returns false (FTP code never sets ENTRY_FWD_HDR_WAIT).