summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTianjie Xu <xunchang@google.com>2019-05-23 18:12:23 -0700
committerandroid-build-merger <android-build-merger@google.com>2019-05-23 18:12:23 -0700
commit92f188b249cd0a99e50a04c6f70df207d66defc1 (patch)
tree238b8d5a27ea2db1eab3138367cf8c09c0dbfbc6
parentf6fd73661bebb7fec2a672da29379a7fe4e6c0eb (diff)
parent347e62aed01ccc8e5d2cd901eb150e29653a6d96 (diff)
downloadandroid_system_update_engine-92f188b249cd0a99e50a04c6f70df207d66defc1.tar.gz
android_system_update_engine-92f188b249cd0a99e50a04c6f70df207d66defc1.tar.bz2
android_system_update_engine-92f188b249cd0a99e50a04c6f70df207d66defc1.zip
Skip an async callback function when the UpdateBootFlagsAction object is destroyed
am: 347e62aed0 Change-Id: If196c470a4d6b8aae2e3bfcea71f538aaa2c4adf
-rw-r--r--update_boot_flags_action.cc17
-rw-r--r--update_boot_flags_action.h2
2 files changed, 18 insertions, 1 deletions
diff --git a/update_boot_flags_action.cc b/update_boot_flags_action.cc
index 97ef7f23..ee92ae0a 100644
--- a/update_boot_flags_action.cc
+++ b/update_boot_flags_action.cc
@@ -50,8 +50,11 @@ void UpdateBootFlagsAction::PerformAction() {
}
}
-void UpdateBootFlagsAction::CompleteUpdateBootFlags(bool successful) {
+void UpdateBootFlagsAction::TerminateProcessing() {
is_running_ = false;
+}
+
+void UpdateBootFlagsAction::CompleteUpdateBootFlags(bool successful) {
if (!successful) {
// We ignore the failure for now because if the updating boot flags is flaky
// or has a bug in a specific release, then blocking the update can cause
@@ -61,6 +64,18 @@ void UpdateBootFlagsAction::CompleteUpdateBootFlags(bool successful) {
// TODO(ahassani): Add new error code metric for kUpdateBootFlagsFailed.
LOG(ERROR) << "Updating boot flags failed, but ignoring its failure.";
}
+
+ // As the callback to MarkBootSuccessfulAsync, this function can still be
+ // called even after the current UpdateBootFlagsAction object get destroyed by
+ // the action processor. In this case, check the value of the static variable
+ // |is_running_| and skip executing the callback function.
+ if (!is_running_) {
+ LOG(INFO) << "UpdateBootFlagsAction is no longer running.";
+ return;
+ }
+
+ is_running_ = false;
+
updated_boot_flags_ = true;
processor_->ActionComplete(this, ErrorCode::kSuccess);
}
diff --git a/update_boot_flags_action.h b/update_boot_flags_action.h
index afa2c3f1..892aab7b 100644
--- a/update_boot_flags_action.h
+++ b/update_boot_flags_action.h
@@ -30,6 +30,8 @@ class UpdateBootFlagsAction : public AbstractAction {
void PerformAction() override;
+ void TerminateProcessing() override;
+
static std::string StaticType() { return "UpdateBootFlagsAction"; }
std::string Type() const override { return StaticType(); }