[asterisk-commits] russell: branch russell/debug_threads r77849 - in /team/russell/debug_threads...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jul 31 16:55:08 CDT 2007


Author: russell
Date: Tue Jul 31 16:55:08 2007
New Revision: 77849

URL: http://svn.digium.com/view/asterisk?view=rev&rev=77849
Log:
revert backport of rwlocks.  The one place i used them wasn't really a benefit.

Modified:
    team/russell/debug_threads/include/asterisk/lock.h
    team/russell/debug_threads/utils.c

Modified: team/russell/debug_threads/include/asterisk/lock.h
URL: http://svn.digium.com/view/asterisk/team/russell/debug_threads/include/asterisk/lock.h?view=diff&rev=77849&r1=77848&r2=77849
==============================================================================
--- team/russell/debug_threads/include/asterisk/lock.h (original)
+++ team/russell/debug_threads/include/asterisk/lock.h Tue Jul 31 16:55:08 2007
@@ -675,74 +675,6 @@
 #define pthread_create __use_ast_pthread_create_instead__
 #endif
 
-typedef pthread_rwlock_t ast_rwlock_t;
-
-static inline int ast_rwlock_init(ast_rwlock_t *prwlock)
-{
-	pthread_rwlockattr_t attr;
-
-	pthread_rwlockattr_init(&attr);
-
-/* XXX Can't detect this in 1.2 */
-#ifdef HAVE_PTHREAD_RWLOCK_PREFER_WRITER_NP
-	pthread_rwlockattr_setkind_np(&attr, PTHREAD_RWLOCK_PREFER_WRITER_NP);
-#endif
-	
-	return pthread_rwlock_init(prwlock, &attr);
-}
-
-static inline int ast_rwlock_destroy(ast_rwlock_t *prwlock)
-{
-	return pthread_rwlock_destroy(prwlock);
-}
-
-static inline int ast_rwlock_unlock(ast_rwlock_t *prwlock)
-{
-	return pthread_rwlock_unlock(prwlock);
-}
-
-static inline int ast_rwlock_rdlock(ast_rwlock_t *prwlock)
-{
-	return pthread_rwlock_rdlock(prwlock);
-}
-
-static inline int ast_rwlock_tryrdlock(ast_rwlock_t *prwlock)
-{
-	return pthread_rwlock_tryrdlock(prwlock);
-}
-
-static inline int ast_rwlock_wrlock(ast_rwlock_t *prwlock)
-{
-	return pthread_rwlock_wrlock(prwlock);
-}
-
-static inline int ast_rwlock_trywrlock(ast_rwlock_t *prwlock)
-{
-	return pthread_rwlock_trywrlock(prwlock);
-}
-
-/* Statically declared read/write locks */
-
-/* XXX Can't detect this in 1.2 */
-#ifndef HAVE_PTHREAD_RWLOCK_INITIALIZER
-#define __AST_RWLOCK_DEFINE(scope, rwlock) \
-        scope ast_rwlock_t rwlock; \
-static void  __attribute__ ((constructor)) init_##rwlock(void) \
-{ \
-        ast_rwlock_init(&rwlock); \
-} \
-static void  __attribute__ ((destructor)) fini_##rwlock(void) \
-{ \
-        ast_rwlock_destroy(&rwlock); \
-}
-#else
-#define AST_RWLOCK_INIT_VALUE PTHREAD_RWLOCK_INITIALIZER
-#define __AST_RWLOCK_DEFINE(scope, rwlock) \
-        scope ast_rwlock_t rwlock = AST_RWLOCK_INIT_VALUE
-#endif
-
-#define AST_RWLOCK_DEFINE_STATIC(rwlock) __AST_RWLOCK_DEFINE(static, rwlock)
-
 int ast_atomic_fetchadd_int_slow(volatile int *p, int v);
 
 #include "asterisk/inline_api.h"

Modified: team/russell/debug_threads/utils.c
URL: http://svn.digium.com/view/asterisk/team/russell/debug_threads/utils.c?view=diff&rev=77849&r1=77848&r2=77849
==============================================================================
--- team/russell/debug_threads/utils.c (original)
+++ team/russell/debug_threads/utils.c Tue Jul 31 16:55:08 2007
@@ -534,7 +534,7 @@
 /*! 
  * \brief Locked when accessing the lock_infos list 
  */
-AST_RWLOCK_DEFINE_STATIC(lock_infos_rwlock);
+AST_MUTEX_DEFINE_STATIC(lock_infos_lock);
 /*!
  * \brief A list of each thread's lock info 
  */
@@ -549,9 +549,9 @@
 {
 	struct thr_lock_info *lock_info = data;
 
-	pthread_rwlock_wrlock(&lock_infos_rwlock);
+	pthread_mutex_lock(&lock_infos_lock.mutex);
 	AST_LIST_REMOVE(&lock_infos, lock_info, entry);
-	pthread_rwlock_unlock(&lock_infos_rwlock);
+	pthread_mutex_unlock(&lock_infos_lock.mutex);
 
 	pthread_mutex_destroy(&lock_info->lock);
 	free((void *) lock_info->thread_name);
@@ -664,7 +664,7 @@
 				"=== <file> <line num> <function> <lock name> <lock addr> (times locked)\n"
 				"===\n");
 
-	pthread_rwlock_rdlock(&lock_infos_rwlock);
+	pthread_mutex_lock(&lock_infos_lock.mutex);
 	AST_LIST_TRAVERSE(&lock_infos, lock_info, entry) {
 		int i;
 		ast_cli(fd, "=== Thread ID: %d (%s)\n", (int) lock_info->thread_id,
@@ -681,7 +681,7 @@
 		ast_cli(fd, "=== -------------------------------------------------------------------\n"
 		            "===\n");
 	}
-	pthread_rwlock_unlock(&lock_infos_rwlock);
+	pthread_mutex_unlock(&lock_infos_lock.mutex);
 
 	ast_cli(fd, "=======================================================================\n"
 	            "\n");
@@ -731,9 +731,9 @@
 	lock_info->thread_name = strdup(a.name);
 	pthread_mutex_init(&lock_info->lock, NULL);
 
-	pthread_rwlock_wrlock(&lock_infos_rwlock); /* Intentionally not the wrapper */
+	pthread_mutex_lock(&lock_infos_lock.mutex); /* Intentionally not the wrapper */
 	AST_LIST_INSERT_TAIL(&lock_infos, lock_info, entry);
-	pthread_rwlock_unlock(&lock_infos_rwlock); /* Intentionally not the wrapper */
+	pthread_mutex_unlock(&lock_infos_lock.mutex); /* Intentionally not the wrapper */
 
 #endif /* DEBUG_THREADS */
 




More information about the asterisk-commits mailing list