diff options
| -rw-r--r-- | src/base/mutex-inl.h | 28 | ||||
| -rw-r--r-- | src/base/mutex.cc | 28 |
2 files changed, 28 insertions, 28 deletions
diff --git a/src/base/mutex-inl.h b/src/base/mutex-inl.h index 03ec6f84b7..122fad507e 100644 --- a/src/base/mutex-inl.h +++ b/src/base/mutex-inl.h @@ -77,6 +77,34 @@ static inline void CheckUnattachedThread(LockLevel level) NO_THREAD_SAFETY_ANALY } } +inline void BaseMutex::RegisterAsLocked(Thread* self) { + if (UNLIKELY(self == NULL)) { + CheckUnattachedThread(level_); + return; + } + if (kDebugLocking) { + // Check if a bad Mutex of this level or lower is held. + bool bad_mutexes_held = false; + for (int i = level_; i >= 0; --i) { + BaseMutex* held_mutex = self->GetHeldMutex(static_cast<LockLevel>(i)); + if (UNLIKELY(held_mutex != NULL)) { + LOG(ERROR) << "Lock level violation: holding \"" << held_mutex->name_ << "\" (level " << i + << ") while locking \"" << name_ << "\" (level " << static_cast<int>(level_) << ")"; + if (i > kAbortLock) { + // Only abort in the check below if this is more than abort level lock. + bad_mutexes_held = true; + } + } + } + CHECK(!bad_mutexes_held); + } + // Don't record monitors as they are outside the scope of analysis. They may be inspected off of + // the monitor list. + if (level_ != kMonitorLock) { + self->SetHeldMutex(level_, this); + } +} + inline void BaseMutex::RegisterAsUnlocked(Thread* self) { if (UNLIKELY(self == NULL)) { CheckUnattachedThread(level_); diff --git a/src/base/mutex.cc b/src/base/mutex.cc index fa7a617cd6..393f2fc372 100644 --- a/src/base/mutex.cc +++ b/src/base/mutex.cc @@ -141,34 +141,6 @@ void BaseMutex::DumpAll(std::ostream& os) { #endif } -void BaseMutex::RegisterAsLocked(Thread* self) { - if (UNLIKELY(self == NULL)) { - CheckUnattachedThread(level_); - return; - } - if (kDebugLocking) { - // Check if a bad Mutex of this level or lower is held. - bool bad_mutexes_held = false; - for (int i = level_; i >= 0; --i) { - BaseMutex* held_mutex = self->GetHeldMutex(static_cast<LockLevel>(i)); - if (UNLIKELY(held_mutex != NULL)) { - LOG(ERROR) << "Lock level violation: holding \"" << held_mutex->name_ << "\" (level " << i - << ") while locking \"" << name_ << "\" (level " << static_cast<int>(level_) << ")"; - if (i > kAbortLock) { - // Only abort in the check below if this is more than abort level lock. - bad_mutexes_held = true; - } - } - } - CHECK(!bad_mutexes_held); - } - // Don't record monitors as they are outside the scope of analysis. They may be inspected off of - // the monitor list. - if (level_ != kMonitorLock) { - self->SetHeldMutex(level_, this); - } -} - void BaseMutex::CheckSafeToWait(Thread* self) { if (self == NULL) { CheckUnattachedThread(level_); |