From: Mukund Sivaraman Date: Mon, 15 Oct 2012 04:08:39 +0000 (+0530) Subject: [2198] Check pthread_mutex_trylock()'s return value X-Git-Tag: trac2402_base~28^2~4 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e6ac5ef47d9885e20e247697c8c3d1fe55fd2500;p=thirdparty%2Fkea.git [2198] Check pthread_mutex_trylock()'s return value --- diff --git a/src/lib/util/threads/lock.cc b/src/lib/util/threads/lock.cc index ab6bd797df..acc73d6f69 100644 --- a/src/lib/util/threads/lock.cc +++ b/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);