BIND 10 trac2202, updated. 52d245f139122e86c07a4336fbb2495bdb6499d9 [2202] Drop support for recursive mutexes

BIND 10 source code commits bind10-changes at lists.isc.org
Mon Oct 1 13:52:24 UTC 2012


The branch, trac2202 has been updated
       via  52d245f139122e86c07a4336fbb2495bdb6499d9 (commit)
      from  8bd4cd42e061d49d098cb1387b3614226a161f6d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 52d245f139122e86c07a4336fbb2495bdb6499d9
Author: Michal 'vorner' Vaner <michal.vaner at nic.cz>
Date:   Mon Oct 1 15:52:04 2012 +0200

    [2202] Drop support for recursive mutexes
    
    They are not needed currently.

-----------------------------------------------------------------------

Summary of changes:
 src/lib/util/threads/lock.cc                |    8 ++------
 src/lib/util/threads/lock.h                 |   14 ++++----------
 src/lib/util/threads/tests/lock_unittest.cc |   12 ------------
 3 files changed, 6 insertions(+), 28 deletions(-)

-----------------------------------------------------------------------
diff --git a/src/lib/util/threads/lock.cc b/src/lib/util/threads/lock.cc
index d5c32d4..a1434e1 100644
--- a/src/lib/util/threads/lock.cc
+++ b/src/lib/util/threads/lock.cc
@@ -56,7 +56,7 @@ struct Deinitializer {
 
 }
 
-Mutex::Mutex(bool recursive) :
+Mutex::Mutex() :
     impl_(NULL)
 {
     pthread_mutexattr_t attributes;
@@ -72,11 +72,7 @@ Mutex::Mutex(bool recursive) :
     Deinitializer deinitializer(attributes);
     // TODO: Distinguish if debug mode is enabled in compilation.
     // If so, it should be PTHREAD_MUTEX_NORMAL or NULL
-    int type = PTHREAD_MUTEX_ERRORCHECK;
-    if (recursive) {
-        type = PTHREAD_MUTEX_RECURSIVE;
-    }
-    result = pthread_mutexattr_settype(&attributes, type);
+    result = pthread_mutexattr_settype(&attributes, PTHREAD_MUTEX_ERRORCHECK);
     if (result != 0) {
         isc_throw(isc::InvalidOperation, strerror(result));
     }
diff --git a/src/lib/util/threads/lock.h b/src/lib/util/threads/lock.h
index 3a28f1a..75bff65 100644
--- a/src/lib/util/threads/lock.h
+++ b/src/lib/util/threads/lock.h
@@ -44,23 +44,18 @@ class Mutex : public boost::noncopyable {
 public:
     /// \brief Constructor.
     ///
-    /// Creates a mutex. Depending on the parameter, it is either recursive
-    /// (the same thread may lock it multiple times, others wait; it must be
-    /// unlocked as many times to become really unlocked) or normal (can be
-    /// locked just once, if the same threads tries to lock it again, Bad
-    /// Things Happen).
+    /// Creates a mutex. It is a non-recursive mutex (can be locked just once,
+    /// if the same threads tries to lock it again, Bad Things Happen).
     ///
     /// Depending on compilation parameters and OS, the mutex may or may not
     /// do some error and sanity checking. However, such checking is meant
     /// only to aid development, not rely on it as a feature.
     ///
-    /// \param recursive If the thread should be recursive (lockable multiple
-    ///     times from the same thread) or not.
     /// \throw std::bad_alloc In case allocation of something (memory, the
     ///     OS mutex) fails.
     /// \throw isc::InvalidOperation Other unspecified errors around the mutex.
     ///     This should be rare.
-    Mutex(bool recursive = false);
+    Mutex();
 
     /// \brief Destructor.
     ///
@@ -86,8 +81,7 @@ public:
         ///
         /// \throw isc::InvalidOperation when OS reports error. This usually
         ///     means an attempt to use the mutex in a wrong way (locking
-        ///     a non-recursive mutex a second time from the same thread,
-        ///     for example).
+        ///     a mutex second time from the same thread, for example).
         Locker(Mutex& mutex) :
             mutex_(NULL)
         {
diff --git a/src/lib/util/threads/tests/lock_unittest.cc b/src/lib/util/threads/tests/lock_unittest.cc
index e1edd70..cc959f5 100644
--- a/src/lib/util/threads/tests/lock_unittest.cc
+++ b/src/lib/util/threads/tests/lock_unittest.cc
@@ -25,18 +25,6 @@ using namespace isc::util::thread;
 
 namespace {
 
-// Test a recursive mutex can be locked multiple times
-TEST(MutexTest, recursiveLockMultiple) {
-    Mutex mutex(true);
-    EXPECT_FALSE(mutex.locked()); // Debug-only build
-    Mutex::Locker l1(mutex);
-    EXPECT_TRUE(mutex.locked()); // Debug-only build
-    Mutex::Locker l2(mutex);
-    Mutex::Locker l3(mutex);
-    Mutex::Locker l4(mutex);
-    Mutex::Locker l5(mutex);
-}
-
 // If we try to lock the debug mutex multiple times, it should throw.
 TEST(MutexTest, lockMultiple) {
     // TODO: Once we support non-debug mutexes, disable the test if we compile



More information about the bind10-changes mailing list