From c0323e34a5475ccaa68eb1b5d24b2f91e6ad3016 Mon Sep 17 00:00:00 2001 From: Automatic Release Builder Date: Tue, 29 Sep 2020 17:43:18 +0100 Subject: [PATCH] TerraSync: tweak warnings around checksum failures Trying to reduce log spam when there is a server-side failure. --- simgear/io/HTTPRepository.cxx | 8 ++++---- simgear/io/HTTPRequest.cxx | 34 ++++++++++++++++++++++++---------- simgear/io/HTTPRequest.hxx | 3 ++- 3 files changed, 30 insertions(+), 15 deletions(-) diff --git a/simgear/io/HTTPRepository.cxx b/simgear/io/HTTPRepository.cxx index 388996f6..a4372161 100644 --- a/simgear/io/HTTPRepository.cxx +++ b/simgear/io/HTTPRepository.cxx @@ -418,7 +418,7 @@ public: SG_LOG(SG_TERRASYNC, SG_WARN, "updated file but not found in dir:" << _relativePath << " " << file); } else { 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 // middle of a server-side update, the downloaded file may actually become valid. _repository->failedToUpdateChild(_relativePath, HTTPRepository::REPO_ERROR_CHECKSUM); @@ -1210,15 +1210,15 @@ HTTPRepository::failure() const } else if (fileStatus == HTTPRepository::REPO_ERROR_CANCELLED) { // if we were cancelled, don't report or log return; + } else { + SG_LOG(SG_TERRASYNC, SG_WARN, "failed to update entry:" << relativePath << " status/code: " + << innerResultCodeAsString(fileStatus) << "/" << fileStatus); } Failure f; f.path = relativePath; f.error = fileStatus; failures.push_back(f); - - SG_LOG(SG_TERRASYNC, SG_WARN, "failed to update entry:" << relativePath << " status/code: " - << innerResultCodeAsString(fileStatus) << "/" << fileStatus); } } // of namespace simgear diff --git a/simgear/io/HTTPRequest.cxx b/simgear/io/HTTPRequest.cxx index c9a25a47..d96caf9d 100644 --- a/simgear/io/HTTPRequest.cxx +++ b/simgear/io/HTTPRequest.cxx @@ -193,13 +193,16 @@ void Request::onDone() //------------------------------------------------------------------------------ void Request::onFail() { - SG_LOG - ( - SG_IO, - SG_INFO, - "request failed:" << url() << " : " - << responseCode() << "/" << responseReason() - ); + // log if we FAIELD< but not if we CANCELLED + if (_ready_state == FAILED) { + SG_LOG + ( + SG_IO, + 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) { + // 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); + } + _responseStatus = code; _responseReason = reason; - if( !isComplete() ) - setReadyState(FAILED); + if( !isComplete() ) { + setReadyState(code < 0 ? CANCELLED : FAILED); + } } //------------------------------------------------------------------------------ @@ -373,6 +381,12 @@ void Request::setReadyState(ReadyState state) _cb_fail(this); } + else if (state == CANCELLED ) + { + onFail(); // do this for compatability + onAlways(); + _cb_fail(this); + } else return; @@ -402,7 +416,7 @@ bool Request::serverSupportsPipelining() const //------------------------------------------------------------------------------ bool Request::isComplete() const { - return _ready_state == DONE || _ready_state == FAILED; + return _ready_state == DONE || _ready_state == FAILED || _ready_state == CANCELLED; } //------------------------------------------------------------------------------ diff --git a/simgear/io/HTTPRequest.hxx b/simgear/io/HTTPRequest.hxx index a8f17341..716fe668 100644 --- a/simgear/io/HTTPRequest.hxx +++ b/simgear/io/HTTPRequest.hxx @@ -54,7 +54,8 @@ public: HEADERS_RECEIVED, LOADING, DONE, - FAILED + FAILED, + CANCELLED }; virtual ~Request();