Like Mutex, failure to destroy a ConditionVariable on shutdown is a special case.
Change-Id: Id9b710a4676169abab5eabb0603947e599012be3
diff --git a/src/jni_internal.cc b/src/jni_internal.cc
index 133cc1e..6ac36bd 100644
--- a/src/jni_internal.cc
+++ b/src/jni_internal.cc
@@ -555,7 +555,7 @@
handle_(handle),
class_loader_(class_loader),
jni_on_load_lock_("JNI_OnLoad lock"),
- jni_on_load_cond_("JNI_OnLoad"),
+ jni_on_load_cond_("JNI_OnLoad condition variable"),
jni_on_load_thread_id_(Thread::Current()->GetThinLockId()),
jni_on_load_result_(kPending) {
}
diff --git a/src/mutex.cc b/src/mutex.cc
index b0b82f3..f5c4435 100644
--- a/src/mutex.cc
+++ b/src/mutex.cc
@@ -74,6 +74,8 @@
}
Mutex::~Mutex() {
+ // We can't use CHECK_MUTEX_CALL here because on shutdown a suspended daemon thread
+ // may still be using locks.
int rc = pthread_mutex_destroy(&mutex_);
if (rc != 0) {
errno = rc;
@@ -164,7 +166,14 @@
}
ConditionVariable::~ConditionVariable() {
- CHECK_MUTEX_CALL(pthread_cond_destroy, (&cond_));
+ // We can't use CHECK_MUTEX_CALL here because on shutdown a suspended daemon thread
+ // may still be using condition variables.
+ int rc = pthread_cond_destroy(&cond_);
+ if (rc != 0) {
+ errno = rc;
+ bool shutting_down = Runtime::Current()->IsShuttingDown();
+ PLOG(shutting_down ? WARNING : FATAL) << "pthread_cond_destroy failed for " << name_;
+ }
}
void ConditionVariable::Broadcast() {
@@ -194,4 +203,4 @@
}
}
-} // namespace
+} // namespace art
diff --git a/src/thread.cc b/src/thread.cc
index 4177913..00b5188 100644
--- a/src/thread.cc
+++ b/src/thread.cc
@@ -775,8 +775,8 @@
peer_(NULL),
top_of_managed_stack_(),
top_of_managed_stack_pc_(0),
- wait_mutex_(new Mutex("Thread wait mutex")),
- wait_cond_(new ConditionVariable("Thread wait condition variable")),
+ wait_mutex_(new Mutex("a thread wait mutex")),
+ wait_cond_(new ConditionVariable("a thread wait condition variable")),
wait_monitor_(NULL),
interrupted_(false),
wait_next_(NULL),
diff --git a/src/thread_list.cc b/src/thread_list.cc
index 6c0a592..2526fc2 100644
--- a/src/thread_list.cc
+++ b/src/thread_list.cc
@@ -27,10 +27,10 @@
ThreadList::ThreadList()
: allocated_ids_lock_("allocated thread ids lock"),
thread_list_lock_("thread list lock", kThreadListLock),
- thread_start_cond_("thread_start_cond_"),
- thread_exit_cond_("thread_exit_cond_"),
+ thread_start_cond_("thread start condition variable"),
+ thread_exit_cond_("thread exit condition variable"),
thread_suspend_count_lock_("thread suspend count lock", kThreadSuspendCountLock),
- thread_suspend_count_cond_("thread_suspend_count_cond_") {
+ thread_suspend_count_cond_("thread suspend count condition variable") {
VLOG(threads) << "Default stack size: " << PrettySize(Runtime::Current()->GetDefaultStackSize());
}