Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Unified Diff: libcurl_http_fetcher.cc

Issue 5260004: AU: Retry up to 3 times 30 seconds apart on HTTP response code 0. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git@master
Patch Set: address review comments Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « libcurl_http_fetcher.h ('k') | update_attempter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: libcurl_http_fetcher.cc
diff --git a/libcurl_http_fetcher.cc b/libcurl_http_fetcher.cc
index c6293b17972d63b30b44643b86de5b725bfc60f0..170abfa702e5892ada8dce93b39b6913d646a416 100644
--- a/libcurl_http_fetcher.cc
+++ b/libcurl_http_fetcher.cc
@@ -25,6 +25,7 @@ namespace chromeos_update_engine {
namespace {
const int kMaxRetriesCount = 20;
+const int kNoNetworkRetrySeconds = 30;
const char kCACertificatesPath[] = "/usr/share/chromeos-ca-certificates";
} // namespace {}
@@ -152,6 +153,7 @@ void LibcurlHttpFetcher::BeginTransfer(const std::string& url) {
transfer_size_ = -1;
resume_offset_ = 0;
retry_count_ = 0;
+ no_network_retry_count_ = 0;
http_response_code_ = 0;
ResolveProxiesForUrl(url);
ResumeTransfer(url);
@@ -192,6 +194,7 @@ void LibcurlHttpFetcher::CurlPerformOnce() {
GetHttpResponseCode();
if (http_response_code_) {
LOG(INFO) << "HTTP response code: " << http_response_code_;
+ no_network_retry_count_ = 0;
} else {
LOG(ERROR) << "Unable to get http response code.";
}
@@ -199,6 +202,21 @@ void LibcurlHttpFetcher::CurlPerformOnce() {
// we're done!
CleanUp();
+ // TODO(petkov): This temporary code tries to deal with the case where the
+ // update engine performs an update check while the network is not ready
+ // (e.g., right after resume). Longer term, we should check if the network
+ // is online/offline and return an appropriate error code.
+ if (!sent_byte_ &&
+ http_response_code_ == 0 &&
+ no_network_retry_count_ < no_network_max_retries_) {
+ no_network_retry_count_++;
+ g_timeout_add_seconds(kNoNetworkRetrySeconds,
+ &LibcurlHttpFetcher::StaticRetryTimeoutCallback,
+ this);
+ LOG(INFO) << "No HTTP response, retry " << no_network_retry_count_;
+ return;
+ }
+
if (!sent_byte_ &&
(http_response_code_ < 200 || http_response_code_ >= 300)) {
// The transfer completed w/ error and we didn't get any bytes.
« no previous file with comments | « libcurl_http_fetcher.h ('k') | update_attempter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698