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

Unified Diff: delta_performer.cc

Issue 3575024: AU: Fall back to a new update after a certain number of failed resume attempts. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: Created 10 years, 2 months 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 | « no previous file | prefs.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: delta_performer.cc
diff --git a/delta_performer.cc b/delta_performer.cc
index 9bf3d34ad49bc9fd62d1830ec09c24bf683bd167..8fc479b7d3d98993f14c37dd2163acdcaee57e2e 100644
--- a/delta_performer.cc
+++ b/delta_performer.cc
@@ -40,6 +40,7 @@ const int kDeltaProtobufLengthLength = 8;
const char kUpdatePayloadPublicKeyPath[] =
"/usr/share/update_engine/update-payload-key.pub.pem";
const int kUpdateStateOperationInvalid = -1;
+const int kMaxResumedUpdateFailures = 10;
// Converts extents to a human-readable string, for use by DumpUpdateProto().
string ExtentsToString(const RepeatedPtrField<Extent>& extents) {
@@ -563,6 +564,11 @@ bool DeltaPerformer::CanResumeUpdate(PrefsInterface* prefs,
!interrupted_hash.empty() &&
interrupted_hash == update_check_response_hash);
+ int64_t resumed_update_failures;
+ TEST_AND_RETURN_FALSE(!prefs->GetInt64(kPrefsResumedUpdateFailures,
+ &resumed_update_failures) ||
+ resumed_update_failures <= kMaxResumedUpdateFailures);
+
// Sanity check the rest.
int64_t next_data_offset = -1;
TEST_AND_RETURN_FALSE(prefs->GetInt64(kPrefsUpdateStateNextDataOffset,
@@ -591,6 +597,7 @@ bool DeltaPerformer::ResetUpdateProgress(PrefsInterface* prefs, bool quick) {
prefs->SetString(kPrefsUpdateStateSHA256Context, "");
prefs->SetString(kPrefsUpdateStateSignedSHA256Context, "");
prefs->SetInt64(kPrefsManifestMetadataSize, -1);
+ prefs->SetInt64(kPrefsResumedUpdateFailures, 0);
}
return true;
}
@@ -648,6 +655,14 @@ bool DeltaPerformer::PrimeUpdateState() {
manifest_metadata_size > 0);
manifest_metadata_size_ = manifest_metadata_size;
+ // Speculatively count the resume as a failure.
+ int64_t resumed_update_failures;
+ if (prefs_->GetInt64(kPrefsResumedUpdateFailures, &resumed_update_failures)) {
+ resumed_update_failures++;
+ } else {
+ resumed_update_failures = 1;
+ }
+ prefs_->SetInt64(kPrefsResumedUpdateFailures, resumed_update_failures);
return true;
}
« no previous file with comments | « no previous file | prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698