[svn-commits] russell: branch 1.4 r84206 - /branches/1.4/include/asterisk/lock.h

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Oct 1 14:34:13 CDT 2007


Author: russell
Date: Mon Oct  1 14:34:12 2007
New Revision: 84206

URL: http://svn.digium.com/view/asterisk?view=rev&rev=84206
Log:
Show rwlocks in the "core show locks" output.  Before, it only showed mutexes.

Modified:
    branches/1.4/include/asterisk/lock.h

Modified: branches/1.4/include/asterisk/lock.h
URL: http://svn.digium.com/view/asterisk/branches/1.4/include/asterisk/lock.h?view=diff&rev=84206&r1=84205&r2=84206
==============================================================================
--- branches/1.4/include/asterisk/lock.h (original)
+++ branches/1.4/include/asterisk/lock.h Mon Oct  1 14:34:12 2007
@@ -702,6 +702,84 @@
 	return pthread_rwlock_destroy(prwlock);
 }
 
+#ifdef DEBUG_THREADS
+#define ast_rwlock_unlock(a) \
+	_ast_rwlock_unlock(a, # a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
+static inline int _ast_rwlock_unlock(ast_rwlock_t *lock, const char *name,
+	const char *file, int line, const char *func)
+{
+	int res;
+	res = pthread_rwlock_unlock(lock);
+	ast_remove_lock_info(lock);
+	return res;
+}
+
+#define ast_rwlock_rdlock(a) \
+	_ast_rwlock_rdlock(a, # a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
+static inline int _ast_rwlock_rdlock(ast_rwlock_t *lock, const char *name,
+	const char *file, int line, const char *func)
+{
+	int res;
+	ast_store_lock_info(file, line, func, name, lock);
+	res = pthread_rwlock_rdlock(lock);
+	if (!res)
+		ast_mark_lock_acquired();
+	else
+		ast_remove_lock_info(lock);
+	return res;
+}
+
+#define ast_rwlock_wrlock(a) \
+	_ast_rwlock_wrlock(a, # a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
+static inline int _ast_rwlock_wrlock(ast_rwlock_t *lock, const char *name,
+	const char *file, int line, const char *func)
+{
+	int res;
+	ast_store_lock_info(file, line, func, name, lock);
+	res = pthread_rwlock_wrlock(lock);
+	if (!res)
+		ast_mark_lock_acquired();
+	else
+		ast_remove_lock_info(lock);
+	return res;
+}
+
+#define ast_rwlock_tryrdlock(a) \
+	_ast_rwlock_tryrdlock(a, # a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
+static inline int _ast_rwlock_tryrdlock(ast_rwlock_t *lock, const char *name,
+	const char *file, int line, const char *func)
+{
+	int res;
+	ast_store_lock_info(file, line, func, name, lock);
+	res = pthread_rwlock_tryrdlock(lock);
+	if (!res)
+		ast_mark_lock_acquired();
+	else
+		ast_remove_lock_info(lock);
+	return res;
+}
+
+#define ast_rwlock_trywrlock(a) \
+	_ast_rwlock_trywrlock(a, # a, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
+static inline int _ast_rwlock_trywrlock(ast_rwlock_t *lock, const char *name,
+	const char *file, int line, const char *func)
+{
+	int res;
+	ast_store_lock_info(file, line, func, name, lock);
+	res = pthread_rwlock_trywrlock(lock);
+	if (!res)
+		ast_mark_lock_acquired();
+	else
+		ast_remove_lock_info(lock);
+	return res;
+}
+
+#else
 static inline int ast_rwlock_unlock(ast_rwlock_t *prwlock)
 {
 	return pthread_rwlock_unlock(prwlock);
@@ -726,6 +804,7 @@
 {
 	return pthread_rwlock_trywrlock(prwlock);
 }
+#endif /* DEBUG_THREADS */
 
 /* Statically declared read/write locks */
 




More information about the svn-commits mailing list