]> git.ipfire.org Git - thirdparty/kea.git/commitdiff
[2198] Check pthread_mutex_trylock()'s return value
authorMukund Sivaraman <muks@isc.org>
Mon, 15 Oct 2012 04:08:39 +0000 (09:38 +0530)
committerMukund Sivaraman <muks@isc.org>
Mon, 15 Oct 2012 04:08:39 +0000 (09:38 +0530)
src/lib/util/threads/lock.cc

index ab6bd797df7320b3b9c38ee31774f51aa6d924c4..acc73d6f69cecc101ea196da954d9be097a85e13 100644 (file)
@@ -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);