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
diff --git a/src/mutex.cc b/src/mutex.cc
index 0dfab11..7507566 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() {
-  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() {