Browse Source

[2198] Check pthread_mutex_trylock()'s return value

Mukund Sivaraman 12 years ago
parent
commit
e6ac5ef47d
1 changed files with 3 additions and 1 deletions
  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);