Make pthread_mutex_t destruction safer during shutdown.
If we have suspended daemon threads, they might be holding some of the mutexes
we need to destroy, so we can't assert that we successfully destroyed them. We
still want to assert success where possible, though.
Bug: 5869254
Change-Id: Id4f3af3d40b10045958e7d692b3c9eebafec566d
diff --git a/src/runtime.cc b/src/runtime.cc
index e9d5677..c203ffd 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -43,6 +43,7 @@
java_vm_(NULL),
jni_stub_array_(NULL),
abstract_method_error_stub_array_(NULL),
+ shutting_down_(false),
started_(false),
vfprintf_(NULL),
exit_(NULL),
@@ -58,6 +59,8 @@
}
Runtime::~Runtime() {
+ shutting_down_ = true;
+
Dbg::StopJdwp();
// Make sure our internal threads are dead before we start tearing down things they're using.
@@ -525,6 +528,10 @@
VLOG(startup) << "Runtime::StartDaemonThreads exiting";
}
+bool Runtime::IsShuttingDown() const {
+ return shutting_down_;
+}
+
bool Runtime::IsStarted() const {
return started_;
}