summaryrefslogtreecommitdiff
path: root/src/mutex.cc
diff options
context:
space:
mode:
author Elliott Hughes <enh@google.com> 2012-01-13 16:49:08 -0800
committer Elliott Hughes <enh@google.com> 2012-01-13 16:49:08 -0800
commit6b3557571e798b60df995f978fa01c0ca1980dfd (patch)
treece56e52d67d20bf3204074b48d2be1d15644ef54 /src/mutex.cc
parentf4222065170130a31513dc63e2c2808db80860f1 (diff)
Make pthread_mutex_t destruction safer during shutdown.
If we have suspended daemon threads, they might be holding some of the mutexes we need to destroy, so we can't assert that we successfully destroyed them. We still want to assert success where possible, though. Bug: 5869254 Change-Id: Id4f3af3d40b10045958e7d692b3c9eebafec566d
Diffstat (limited to 'src/mutex.cc')
-rw-r--r--src/mutex.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/mutex.cc b/src/mutex.cc
index 0dfab1163d..7507566729 100644
--- a/src/mutex.cc
+++ b/src/mutex.cc
@@ -21,6 +21,7 @@
#include "heap.h" // for VERIFY_OBJECT_ENABLED
#include "logging.h"
#include "utils.h"
+#include "runtime.h"
#define CHECK_MUTEX_CALL(call, args) CHECK_PTHREAD_CALL(call, args, name_)
@@ -36,7 +37,12 @@ Mutex::Mutex(const char* name) : name_(name) {
}
Mutex::~Mutex() {
- CHECK_MUTEX_CALL(pthread_mutex_destroy, (&mutex_));
+ int rc = pthread_mutex_destroy(&mutex_);
+ if (rc != 0) {
+ errno = rc;
+ bool shutting_down = Runtime::Current()->IsShuttingDown();
+ PLOG(shutting_down ? WARNING : FATAL) << "pthread_mutex_destroy failed for " << name_;
+ }
}
void Mutex::Lock() {