TerraSync: tweak warnings around checksum failures

Trying to reduce log spam when there is a server-side failure.
This commit is contained in:
Automatic Release Builder 2020-09-29 17:43:18 +01:00 committed by James Turner
parent 1ebb0787ad
commit c0323e34a5
3 changed files with 30 additions and 15 deletions

View File

@ -418,7 +418,7 @@ public:
SG_LOG(SG_TERRASYNC, SG_WARN, "updated file but not found in dir:" << _relativePath << " " << file); SG_LOG(SG_TERRASYNC, SG_WARN, "updated file but not found in dir:" << _relativePath << " " << file);
} else { } else {
if (it->hash != hash) { if (it->hash != hash) {
SG_LOG(SG_TERRASYNC, SG_INFO, "Checksum error for " << absolutePath() << "/" << file << " " << it->hash << " " << hash); SG_LOG(SG_TERRASYNC, SG_WARN, "Checksum error for " << absolutePath() << "/" << file << " " << it->hash << " " << hash);
// we don't erase the file on a hash mismatch, because if we're syncing during the // we don't erase the file on a hash mismatch, because if we're syncing during the
// middle of a server-side update, the downloaded file may actually become valid. // middle of a server-side update, the downloaded file may actually become valid.
_repository->failedToUpdateChild(_relativePath, HTTPRepository::REPO_ERROR_CHECKSUM); _repository->failedToUpdateChild(_relativePath, HTTPRepository::REPO_ERROR_CHECKSUM);
@ -1210,15 +1210,15 @@ HTTPRepository::failure() const
} else if (fileStatus == HTTPRepository::REPO_ERROR_CANCELLED) { } else if (fileStatus == HTTPRepository::REPO_ERROR_CANCELLED) {
// if we were cancelled, don't report or log // if we were cancelled, don't report or log
return; return;
} else {
SG_LOG(SG_TERRASYNC, SG_WARN, "failed to update entry:" << relativePath << " status/code: "
<< innerResultCodeAsString(fileStatus) << "/" << fileStatus);
} }
Failure f; Failure f;
f.path = relativePath; f.path = relativePath;
f.error = fileStatus; f.error = fileStatus;
failures.push_back(f); failures.push_back(f);
SG_LOG(SG_TERRASYNC, SG_WARN, "failed to update entry:" << relativePath << " status/code: "
<< innerResultCodeAsString(fileStatus) << "/" << fileStatus);
} }
} // of namespace simgear } // of namespace simgear

View File

@ -193,13 +193,16 @@ void Request::onDone()
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void Request::onFail() void Request::onFail()
{ {
SG_LOG // log if we FAIELD< but not if we CANCELLED
( if (_ready_state == FAILED) {
SG_IO, SG_LOG
SG_INFO, (
"request failed:" << url() << " : " SG_IO,
<< responseCode() << "/" << responseReason() SG_INFO,
); "request failed:" << url() << " : "
<< responseCode() << "/" << responseReason()
);
}
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -344,12 +347,17 @@ void Request::setSuccess(int code)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void Request::setFailure(int code, const std::string& reason) void Request::setFailure(int code, const std::string& reason)
{ {
// we use -1 for cancellation, don't be noisy in that case
if (code >= 0) {
SG_LOG(SG_IO, SG_WARN, "HTTP request: set failure:" << code << " reason " << reason); SG_LOG(SG_IO, SG_WARN, "HTTP request: set failure:" << code << " reason " << reason);
}
_responseStatus = code; _responseStatus = code;
_responseReason = reason; _responseReason = reason;
if( !isComplete() ) if( !isComplete() ) {
setReadyState(FAILED); setReadyState(code < 0 ? CANCELLED : FAILED);
}
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -373,6 +381,12 @@ void Request::setReadyState(ReadyState state)
_cb_fail(this); _cb_fail(this);
} }
else if (state == CANCELLED )
{
onFail(); // do this for compatability
onAlways();
_cb_fail(this);
}
else else
return; return;
@ -402,7 +416,7 @@ bool Request::serverSupportsPipelining() const
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
bool Request::isComplete() const bool Request::isComplete() const
{ {
return _ready_state == DONE || _ready_state == FAILED; return _ready_state == DONE || _ready_state == FAILED || _ready_state == CANCELLED;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------

View File

@ -54,7 +54,8 @@ public:
HEADERS_RECEIVED, HEADERS_RECEIVED,
LOADING, LOADING,
DONE, DONE,
FAILED FAILED,
CANCELLED
}; };
virtual ~Request(); virtual ~Request();