Browse Source

[2236] Use PTHREAD_MUTEX_NORMAL fast mutexes by default

Mukund Sivaraman 12 years ago
parent
commit
1d4d9e796c
1 changed files with 7 additions and 2 deletions
  1. 7 2
      src/lib/util/threads/sync.cc

+ 7 - 2
src/lib/util/threads/sync.cc

@@ -77,13 +77,18 @@ Mutex::Mutex() :
     }
     Deinitializer deinitializer(attributes);
 
+    // If debug mode is enabled in compilation, use the slower
+    // error-checking mutexes that detect deadlocks. Otherwise, use fast
+    // mutexes which don't. See the pthread_mutexattr_settype() POSIX
+    // documentation which describes these type attributes.
 #ifdef ENABLE_DEBUG
-    // TODO: Distinguish if debug mode is enabled in compilation.
     result = pthread_mutexattr_settype(&attributes, PTHREAD_MUTEX_ERRORCHECK);
+#else
+    result = pthread_mutexattr_settype(&attributes, PTHREAD_MUTEX_NORMAL);
+#endif // ENABLE_DEBUG
     if (result != 0) {
         isc_throw(isc::InvalidOperation, std::strerror(result));
     }
-#endif // ENABLE_DEBUG
 
     auto_ptr<Impl> impl(new Impl);
     result = pthread_mutex_init(&impl->mutex, &attributes);