make shutdown safe for double calls.
- In new shutdown sequence, volume shutdown is requested in two places:
system_server and init.
- Make VolumeManager.shutdown safe for double calls.
It crashed before this change.
bug: 36004738
Test: reboot and check last_kmsg for crash / vdc timeout
Change-Id: I296913959b2647b65d66553073f2032545beba57
diff --git a/VolumeManager.cpp b/VolumeManager.cpp
index 4a649bb..927c660 100644
--- a/VolumeManager.cpp
+++ b/VolumeManager.cpp
@@ -633,8 +633,13 @@
return 0;
}
+// Can be called twice (sequentially) during shutdown. should be safe for that.
int VolumeManager::shutdown() {
+ if (mInternalEmulated == nullptr) {
+ return 0; // already shutdown
+ }
mInternalEmulated->destroy();
+ mInternalEmulated = nullptr;
for (const auto& disk : mDisks) {
disk->destroy();
}