Stop daemon threads in runtime shutdown
Ensure that daemons are stopped and joins before bringing down the
runtime. This fixes bugs related to native code still running when
we shutdown the runtime.
Also changed the mutex destructor to allow contenders if we are
deleting a monitor lock level mutex.
Bug: 18577101
Change-Id: I6457b35fd69c6997b9003b5f15f39861749843a9
diff --git a/runtime/base/mutex.cc b/runtime/base/mutex.cc
index aa2aefc..da78082 100644
--- a/runtime/base/mutex.cc
+++ b/runtime/base/mutex.cc
@@ -327,8 +327,12 @@
LOG(shutting_down ? WARNING : FATAL) << "destroying mutex with owner: " << exclusive_owner_;
} else {
CHECK_EQ(exclusive_owner_, 0U) << "unexpectedly found an owner on unlocked mutex " << name_;
- CHECK_EQ(num_contenders_.LoadSequentiallyConsistent(), 0)
- << "unexpectedly found a contender on mutex " << name_;
+ if (level_ != kMonitorLock) {
+ // Only check the lock level for non monitor locks since we may still have java threads
+ // waiting on monitors.
+ CHECK_EQ(num_contenders_.LoadSequentiallyConsistent(), 0)
+ << "unexpectedly found a contender on mutex " << name_;
+ }
}
#else
// We can't use CHECK_MUTEX_CALL here because on shutdown a suspended daemon thread