[asterisk-commits] trunk r19396 - /trunk/include/asterisk/lock.h

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Apr 11 15:37:29 MST 2006


Author: rizzo
Date: Tue Apr 11 17:37:27 2006
New Revision: 19396

URL: http://svn.digium.com/view/asterisk?rev=19396&view=rev
Log:
fix various bugs in the DEBUG_THREADS code including:
- misspelled ast_mutex_logger() instead of __ast_mutex_logger()
- misplaced #define ast_mutex_init(pmutex)
- wrong arguments to __ast_mutex_logger() in one instance.

Clearly this code is too spaghetti!


Modified:
    trunk/include/asterisk/lock.h

Modified: trunk/include/asterisk/lock.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/lock.h?rev=19396&r1=19395&r2=19396&view=diff
==============================================================================
--- trunk/include/asterisk/lock.h (original)
+++ trunk/include/asterisk/lock.h Tue Apr 11 17:37:27 2006
@@ -102,7 +102,7 @@
 
 #ifdef DEBUG_THREADS
 
-#define __ast_mutex_logger(...) { if (canlog) ast_log(LOG_ERROR, __VA_ARGS__); else fprintf(stderr, __VA_ARGS__); }
+#define __ast_mutex_logger(...)  do { if (canlog) ast_log(LOG_ERROR, __VA_ARGS__); else fprintf(stderr, __VA_ARGS__); } while (0)
 
 #ifdef THREAD_CRASH
 #define DO_THREAD_CRASH do { *((int *)(0)) = 1; } while(0)
@@ -141,7 +141,7 @@
 		__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is already initialized.\n",
 				   filename, lineno, func, mutex_name);
 		__ast_mutex_logger("%s line %d (%s): Error: previously initialization of mutex '%s'.\n",
-				   t->file, t->lineno, t->func, mutex_name);
+				   t->file[0], t->lineno[0], t->func[0], mutex_name);
 #ifdef THREAD_CRASH
 		DO_THREAD_CRASH;
 #endif
@@ -168,6 +168,7 @@
 
 	return __ast_pthread_mutex_init_attr(filename, lineno, func, mutex_name, t, &attr);
 }
+#define ast_mutex_init(pmutex) __ast_pthread_mutex_init(__FILE__, __LINE__, __PRETTY_FUNCTION__, #pmutex, pmutex)
 
 static inline int __ast_pthread_mutex_destroy(const char *filename, int lineno, const char *func,
 						const char *mutex_name, ast_mutex_t *t)
@@ -251,7 +252,7 @@
 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) || defined(AST_MUTEX_INIT_ON_FIRST_USE)
 	if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
 #ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
-		ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
+		__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
 				 filename, lineno, func, mutex_name);
 #endif
 		ast_mutex_init(t);
@@ -525,7 +526,6 @@
 	return res;
 }
 
-#define ast_mutex_init(pmutex) __ast_pthread_mutex_init(__FILE__, __LINE__, __PRETTY_FUNCTION__, #pmutex, pmutex)
 #define ast_mutex_destroy(a) __ast_pthread_mutex_destroy(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a)
 #define ast_mutex_lock(a) __ast_pthread_mutex_lock(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a)
 #define ast_mutex_unlock(a) __ast_pthread_mutex_unlock(__FILE__, __LINE__, __PRETTY_FUNCTION__, #a, a)



More information about the asterisk-commits mailing list