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

Unified Diff: delta_performer.cc

Issue 3608015: AU: Catch terminate signals and block exit if necessary. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: typo 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 | « SConstruct ('k') | generate_delta_main.cc » ('j') | terminator.cc » ('J')
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 92d4733d02fbc2269f722e47fe206f42958f73a5..5a6c0c1ed7c18759f56493e53bd64a83094371e7 100644
--- a/delta_performer.cc
+++ b/delta_performer.cc
@@ -23,6 +23,7 @@
#include "update_engine/payload_signer.h"
#include "update_engine/prefs_interface.h"
#include "update_engine/subprocess.h"
+#include "update_engine/terminator.h"
using std::min;
using std::string;
@@ -210,6 +211,8 @@ ssize_t DeltaPerformer::Write(const void* bytes, size_t count) {
next_operation_num_ - manifest_.install_operations_size());
if (!CanPerformInstallOperation(op))
break;
+ ScopedTerminatorExitUnblocker exit_unblocker =
+ ScopedTerminatorExitUnblocker(); // Avoids a compiler unused var bug.
// Log every thousandth operation, and also the first and last ones
if ((next_operation_num_ % 1000 == 0) ||
(next_operation_num_ + 1 == total_operations)) {
@@ -222,6 +225,7 @@ ssize_t DeltaPerformer::Write(const void* bytes, size_t count) {
// that if the operation gets interrupted, we don't try to resume the
// update.
if (!IsIdempotentOperation(op)) {
+ Terminator::set_exit_blocked(true);
ResetUpdateProgress(prefs_);
}
if (op.type() == DeltaArchiveManifest_InstallOperation_Type_REPLACE ||
@@ -553,9 +557,10 @@ bool DeltaPerformer::ResetUpdateProgress(PrefsInterface* prefs) {
}
bool DeltaPerformer::CheckpointUpdateProgress() {
- // First reset the progress in case we die in the middle of the state update.
- ResetUpdateProgress(prefs_);
+ Terminator::set_exit_blocked(true);
if (last_updated_buffer_offset_ != buffer_offset_) {
+ // Resets the progress in case we die in the middle of the state update.
+ ResetUpdateProgress(prefs_);
TEST_AND_RETURN_FALSE(
prefs_->SetString(kPrefsUpdateStateSignedSHA256Context,
hash_calculator_.GetContext()));
« no previous file with comments | « SConstruct ('k') | generate_delta_main.cc » ('j') | terminator.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698