From a93ac6b9c80f3d198df93df6493173a57f46a91a Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Tue, 3 Sep 2019 20:54:52 -0700 Subject: [PATCH] libsnapshot: Allow multiple calls to FinishedSnapshotWrites If update_engine crashes at certain point, it may call FinishedSnapshotWrites multiple times. Allow this to happen. Test: apply OTA Change-Id: Ib36cfe38328fd5d6ca408c97024c81569a4bd440 --- fs_mgr/libsnapshot/snapshot.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/fs_mgr/libsnapshot/snapshot.cpp b/fs_mgr/libsnapshot/snapshot.cpp index 7f37dc5ff..2da58aad7 100644 --- a/fs_mgr/libsnapshot/snapshot.cpp +++ b/fs_mgr/libsnapshot/snapshot.cpp @@ -152,7 +152,13 @@ bool SnapshotManager::FinishedSnapshotWrites() { auto lock = LockExclusive(); if (!lock) return false; - if (ReadUpdateState(lock.get()) != UpdateState::Initiated) { + auto update_state = ReadUpdateState(lock.get()); + if (update_state == UpdateState::Unverified) { + LOG(INFO) << "FinishedSnapshotWrites already called before. Ignored."; + return true; + } + + if (update_state != UpdateState::Initiated) { LOG(ERROR) << "Can only transition to the Unverified state from the Initiated state."; return false; }