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

Unified Diff: delta_performer.cc

Issue 3603015: AU: block exit / reset update progress for non-idempotent ops as late as possible. (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 | no next file » | 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 8fc479b7d3d98993f14c37dd2163acdcaee57e2e..3c24d5b9c889c88214631ddbab9313eb3ef7c444 100644
--- a/delta_performer.cc
+++ b/delta_performer.cc
@@ -222,6 +222,7 @@ ssize_t DeltaPerformer::Write(const void* bytes, size_t count) {
next_operation_num_ - manifest_.install_operations_size());
if (!CanPerformInstallOperation(op))
break;
+ // Makes sure we unblock exit when this operation completes.
ScopedTerminatorExitUnblocker exit_unblocker =
ScopedTerminatorExitUnblocker(); // Avoids a compiler unused var bug.
// Log every thousandth operation, and also the first and last ones
@@ -232,13 +233,6 @@ ssize_t DeltaPerformer::Write(const void* bytes, size_t count) {
}
bool is_kernel_partition =
(next_operation_num_ >= manifest_.install_operations_size());
- // If about to start a non-idempotent operation, clear the update state so
- // that if the operation gets interrupted, we don't try to resume the
- // update.
- if (!IsIdempotentOperation(op)) {
- Terminator::set_exit_blocked(true);
- ResetUpdateProgress(prefs_, true);
- }
if (op.type() == DeltaArchiveManifest_InstallOperation_Type_REPLACE ||
op.type() == DeltaArchiveManifest_InstallOperation_Type_REPLACE_BZ) {
if (!PerformReplaceOperation(op, is_kernel_partition)) {
@@ -371,6 +365,14 @@ bool DeltaPerformer::PerformMoveOperation(
bytes_read += bytes_read_this_iteration;
}
+ // If this is a non-idempotent operation, request a delayed exit and clear the
+ // update state in case the operation gets interrupted. Do this as late as
+ // possible.
+ if (!IsIdempotentOperation(operation)) {
+ Terminator::set_exit_blocked(true);
+ ResetUpdateProgress(prefs_, true);
+ }
+
// Write bytes out.
ssize_t bytes_written = 0;
for (int i = 0; i < operation.dst_extents_size(); i++) {
@@ -446,6 +448,14 @@ bool DeltaPerformer::PerformBsdiffOperation(
int fd = is_kernel_partition ? kernel_fd_ : fd_;
const string& path = is_kernel_partition ? kernel_path_ : path_;
+ // If this is a non-idempotent operation, request a delayed exit and clear the
+ // update state in case the operation gets interrupted. Do this as late as
+ // possible.
+ if (!IsIdempotentOperation(operation)) {
+ Terminator::set_exit_blocked(true);
+ ResetUpdateProgress(prefs_, true);
+ }
+
vector<string> cmd;
cmd.push_back(kBspatchPath);
cmd.push_back(path);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698