diff options
| -rw-r--r-- | src/jni_internal.cc | 2 | ||||
| -rw-r--r-- | src/mutex.cc | 13 | ||||
| -rw-r--r-- | src/thread.cc | 4 | ||||
| -rw-r--r-- | src/thread_list.cc | 6 |
4 files changed, 17 insertions, 8 deletions
diff --git a/src/jni_internal.cc b/src/jni_internal.cc index 133cc1ec47..6ac36bdada 100644 --- a/src/jni_internal.cc +++ b/src/jni_internal.cc @@ -555,7 +555,7 @@ class SharedLibrary { 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 b0b82f3059..f5c4435e1e 100644 --- a/src/mutex.cc +++ b/src/mutex.cc @@ -74,6 +74,8 @@ Mutex::Mutex(const char* name, MutexRank rank) : name_(name), rank_(rank) { } 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(const std::string& name) : name_(name) { } 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 @@ void ConditionVariable::TimedWait(Mutex& mutex, const timespec& ts) { } } -} // namespace +} // namespace art diff --git a/src/thread.cc b/src/thread.cc index 4177913068..00b5188da8 100644 --- a/src/thread.cc +++ b/src/thread.cc @@ -775,8 +775,8 @@ Thread::Thread() 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 6c0a5927a5..2526fc2ba0 100644 --- a/src/thread_list.cc +++ b/src/thread_list.cc @@ -27,10 +27,10 @@ namespace art { 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()); } |