]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2198] Check pthread_mutex_trylock()'s return value
authorMukund Sivaraman <muks@isc.org>
Sun, 21 Oct 2012 23:30:34 +0000 (05:00 +0530)
committerMukund Sivaraman <muks@isc.org>
Sun, 21 Oct 2012 23:44:37 +0000 (05:14 +0530)
src/lib/util/threads/sync.cc

index db3cc33fb4849205d61be2365908c1e332636f02..bcb391a79e2b1129955396d51ac7de43374fee0a 100644 (file)
@@ -132,8 +132,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));
     }
     postLockAction();           // Only in debug mode
     return (true);