summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
author Elliott Hughes <enh@google.com> 2012-01-30 11:07:49 -0800
committer Elliott Hughes <enh@google.com> 2012-01-30 11:07:49 -0800
commit9e921bc034450e35c2b5d45cc09a26920ad0d6e6 (patch)
treef473e0e54aa1d55c229360e717180cb369e932de /src
parentf3e6deb07657623716ec2742e89af03a76423560 (diff)
Remove Mutex::ClearOwner.
This was a bad idea (of mine) badly implemented (by me). I went a different and better route in Heap::Destroy, and that fix -- allowing us to destroy a locked mutex during shutdown -- makes this code obsolete. Change-Id: I79452a26b4cbf131b37bf9ca131e46500f1e5a5e
Diffstat (limited to 'src')
-rw-r--r--src/monitor.cc14
-rw-r--r--src/mutex.cc19
-rw-r--r--src/mutex.h3
3 files changed, 0 insertions, 36 deletions
diff --git a/src/monitor.cc b/src/monitor.cc
index 662e1990d2..a29f2a177f 100644
--- a/src/monitor.cc
+++ b/src/monitor.cc
@@ -817,20 +817,6 @@ MonitorList::MonitorList() : lock_("MonitorList lock") {
MonitorList::~MonitorList() {
MutexLock mu(lock_);
-
- // In case there is a daemon thread with the monitor locked, clear
- // the owner here so we can destroy the mutex, which will otherwise
- // fail in pthread_mutex_destroy.
- typedef std::list<Monitor*>::iterator It; // TODO: C++0x auto
- for (It it = list_.begin(); it != list_.end(); it++) {
- Monitor* monitor = *it;
- Mutex& lock = monitor->lock_;
- if (lock.GetOwner() != 0) {
- DCHECK_EQ(lock.GetOwner(), monitor->owner_->GetTid());
- lock.ClearOwner();
- }
- }
-
STLDeleteElements(&list_);
}
diff --git a/src/mutex.cc b/src/mutex.cc
index 8ff1207664..5d207f67d9 100644
--- a/src/mutex.cc
+++ b/src/mutex.cc
@@ -88,25 +88,6 @@ pid_t Mutex::GetOwner() {
#endif
}
-void Mutex::ClearOwner() {
-#if defined(__BIONIC__)
-#define __PTHREAD_RECURSIVE_MUTEX_INIT_VALUE 0x4000
- mutex_.value = __PTHREAD_RECURSIVE_MUTEX_INIT_VALUE;
-#elif defined(__GLIBC__)
- struct __attribute__((__may_alias__)) glibc_pthread_t {
- int lock;
- unsigned int count;
- int owner;
- // ...other stuff we don't care about.
- };
- reinterpret_cast<glibc_pthread_t*>(&mutex_)->owner = 0;
-#elif defined(__APPLE__)
- // We don't know a way to implement this for Mac OS.
-#else
- UNIMPLEMENTED(FATAL);
-#endif
-}
-
uint32_t Mutex::GetDepth() {
bool held = (GetOwner() == GetTid());
if (!held) {
diff --git a/src/mutex.h b/src/mutex.h
index 93f6c3eaa9..f4658fb420 100644
--- a/src/mutex.h
+++ b/src/mutex.h
@@ -68,15 +68,12 @@ class Mutex {
private:
static pid_t GetTid();
- void ClearOwner();
-
uint32_t GetDepth();
std::string name_;
pthread_mutex_t mutex_;
- friend class MonitorList; // for ClearOwner
DISALLOW_COPY_AND_ASSIGN(Mutex);
};