summaryrefslogtreecommitdiffstats
path: root/runtime/base
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2015-01-23 23:17:16 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2015-01-23 23:17:16 +0000
commitd7fa69ca6527abce692da848eb49f6262213c14d (patch)
tree66011cf3d4944ef45eaaf3f48729fb0c7fa993f1 /runtime/base
parent61e620d4771e09143471e38fe7531678a36ce3f8 (diff)
parent8f1fa100ee037131976c616ec72a6608dccb51e2 (diff)
downloadart-d7fa69ca6527abce692da848eb49f6262213c14d.zip
art-d7fa69ca6527abce692da848eb49f6262213c14d.tar.gz
art-d7fa69ca6527abce692da848eb49f6262213c14d.tar.bz2
Merge "ART: On shutdown, only warn on mutex contention"
Diffstat (limited to 'runtime/base')
-rw-r--r--runtime/base/mutex.cc23
1 files changed, 13 insertions, 10 deletions
diff --git a/runtime/base/mutex.cc b/runtime/base/mutex.cc
index 17b2ac9..9453741 100644
--- a/runtime/base/mutex.cc
+++ b/runtime/base/mutex.cc
@@ -319,19 +319,24 @@ Mutex::Mutex(const char* name, LockLevel level, bool recursive)
exclusive_owner_ = 0;
}
+// Helper to ignore the lock requirement.
+static bool IsShuttingDown() NO_THREAD_SAFETY_ANALYSIS {
+ Runtime* runtime = Runtime::Current();
+ return runtime == nullptr || runtime->IsShuttingDownLocked();
+}
+
Mutex::~Mutex() {
+ bool shutting_down = IsShuttingDown();
#if ART_USE_FUTEXES
if (state_.LoadRelaxed() != 0) {
- Runtime* runtime = Runtime::Current();
- bool shutting_down = runtime == nullptr || runtime->IsShuttingDown(Thread::Current());
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_;
- 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_;
+ if (exclusive_owner_ != 0) {
+ LOG(shutting_down ? WARNING : FATAL) << "unexpectedly found an owner on unlocked mutex "
+ << name_;
+ }
+ if (num_contenders_.LoadSequentiallyConsistent() != 0) {
+ LOG(shutting_down ? WARNING : FATAL) << "unexpectedly found a contender on mutex " << name_;
}
}
#else
@@ -342,8 +347,6 @@ Mutex::~Mutex() {
errno = rc;
// TODO: should we just not log at all if shutting down? this could be the logging mutex!
MutexLock mu(Thread::Current(), *Locks::runtime_shutdown_lock_);
- Runtime* runtime = Runtime::Current();
- bool shutting_down = (runtime == NULL) || runtime->IsShuttingDownLocked();
PLOG(shutting_down ? WARNING : FATAL) << "pthread_mutex_destroy failed for " << name_;
}
#endif