Parcourir la source

[2198] Check pthread_mutex_trylock()'s return value

Mukund Sivaraman il y a 12 ans
Parent
commit
e6ac5ef47d
1 fichiers modifiés avec 3 ajouts et 1 suppressions
  1. 3 1
      src/lib/util/threads/lock.cc

+ 3 - 1
src/lib/util/threads/lock.cc

@@ -123,8 +123,10 @@ bool
 Mutex::tryLock() {
     assert(impl_ != NULL);
     const int result = pthread_mutex_trylock(&impl_->mutex);
-    if (result != 0) {
+    if (result == EBUSY) {
         return (false);
+    } else if (result != 0) {
+        isc_throw(isc::InvalidOperation, std::strerror(result));
     }
     ++impl_->locked_count; // Only in debug mode
     return (true);