[Asterisk-code-review] lock: Replace ast mutex logger with ast mutex logger. (asterisk[master])

Corey Farrell asteriskteam at digium.com
Fri Oct 19 05:55:09 CDT 2018


Corey Farrell has uploaded this change for review. ( https://gerrit.asterisk.org/10519


Change subject: lock: Replace __ast_mutex_logger with ast_mutex_logger.
......................................................................

lock: Replace __ast_mutex_logger with ast_mutex_logger.

__ast_mutex_logger used the variable `canlog` without accepting it as a
argument.  Replace this macro with ast_mutex_logger which correctly
takes canlog as the first argument.  This will prevent confusion when
working with lock.h code, many of the function declare are canlog
variable and in some cases it appeared to be unused.

Change-Id: I83b372cb0654c5c18eadc512f65a57fa6c2e9853
---
M include/asterisk/lock.h
M main/lock.c
M utils/extconf.c
3 files changed, 63 insertions(+), 63 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/19/10519/1

diff --git a/include/asterisk/lock.h b/include/asterisk/lock.h
index b409a27..ef2fa11 100644
--- a/include/asterisk/lock.h
+++ b/include/asterisk/lock.h
@@ -241,7 +241,7 @@
 
 #ifdef DEBUG_THREADS
 
-#define __ast_mutex_logger(...)  do { if (canlog) ast_log(LOG_ERROR, __VA_ARGS__); else fprintf(stderr, __VA_ARGS__); } while (0)
+#define ast_mutex_logger(canlog, ...)  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)
diff --git a/main/lock.c b/main/lock.c
index 5ad9e13..b260b19 100644
--- a/main/lock.c
+++ b/main/lock.c
@@ -62,7 +62,7 @@
 	strings = backtrace_symbols(bt->addresses, bt->num_frames);
 
 	for (i = 0; i < bt->num_frames; i++) {
-		__ast_mutex_logger("%s\n", strings[i]);
+		ast_mutex_logger(canlog, "%s\n", strings[i]);
 	}
 
 	ast_std_free(strings);
@@ -141,7 +141,7 @@
 	if ((t->mutex) != ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
 		int canlog = tracking && strcmp(filename, "logger.c");
 
-		__ast_mutex_logger("%s line %d (%s): NOTICE: mutex '%s' is already initialized.\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): NOTICE: mutex '%s' is already initialized.\n",
 				   filename, lineno, func, mutex_name);
 		DO_THREAD_CRASH;
 		return EBUSY;
@@ -178,7 +178,7 @@
 		 * linked with libpthread.
 		 * This is not an error condition if the mutex is created on the fly.
 		 */
-		__ast_mutex_logger("%s line %d (%s): NOTICE: mutex '%s' is uninitialized.\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): NOTICE: mutex '%s' is uninitialized.\n",
 				   filename, lineno, func, mutex_name);
 		DO_THREAD_CRASH;
 		res = EINVAL;
@@ -192,15 +192,15 @@
 		pthread_mutex_unlock(&t->mutex);
 		break;
 	case EINVAL:
-		__ast_mutex_logger("%s line %d (%s): Error: attempt to destroy invalid mutex '%s'.\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Error: attempt to destroy invalid mutex '%s'.\n",
 				  filename, lineno, func, mutex_name);
 		break;
 	case EBUSY:
-		__ast_mutex_logger("%s line %d (%s): Error: attempt to destroy locked mutex '%s'.\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Error: attempt to destroy locked mutex '%s'.\n",
 				   filename, lineno, func, mutex_name);
 		if (lt) {
 			ast_reentrancy_lock(lt);
-			__ast_mutex_logger("%s line %d (%s): Error: '%s' was locked here.\n",
+			ast_mutex_logger(canlog, "%s line %d (%s): Error: '%s' was locked here.\n",
 				    lt->file[ROFFSET], lt->lineno[ROFFSET], lt->func[ROFFSET], mutex_name);
 #ifdef HAVE_BKTR
 			__dump_backtrace(&lt->backtrace[ROFFSET], canlog);
@@ -215,7 +215,7 @@
 
 #ifdef DEBUG_THREADS
 	if (res) {
-		__ast_mutex_logger("%s line %d (%s): Error destroying mutex %s: %s\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Error destroying mutex %s: %s\n",
 				   filename, lineno, func, mutex_name, strerror(res));
 	}
 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
@@ -284,14 +284,14 @@
 			if (res == EBUSY) {
 				wait_time = time(NULL) - seconds;
 				if (wait_time > reported_wait && (wait_time % 5) == 0) {
-					__ast_mutex_logger("%s line %d (%s): Deadlock? waited %d sec for mutex '%s'?\n",
+					ast_mutex_logger(canlog, "%s line %d (%s): Deadlock? waited %d sec for mutex '%s'?\n",
 							   filename, lineno, func, (int) wait_time, mutex_name);
 					if (lt) {
 						ast_reentrancy_lock(lt);
 #ifdef HAVE_BKTR
 						__dump_backtrace(&lt->backtrace[lt->reentrancy], canlog);
 #endif
-						__ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n",
+						ast_mutex_logger(canlog, "%s line %d (%s): '%s' was locked here.\n",
 								   lt->file[ROFFSET], lt->lineno[ROFFSET],
 								   lt->func[ROFFSET], mutex_name);
 #ifdef HAVE_BKTR
@@ -325,7 +325,7 @@
 			lt->thread_id[lt->reentrancy] = pthread_self();
 			lt->reentrancy++;
 		} else {
-			__ast_mutex_logger("%s line %d (%s): '%s' really deep reentrancy!\n",
+			ast_mutex_logger(canlog, "%s line %d (%s): '%s' really deep reentrancy!\n",
 							   filename, lineno, func, mutex_name);
 		}
 		ast_reentrancy_unlock(lt);
@@ -343,7 +343,7 @@
 		ast_remove_lock_info(t, bt);
 	}
 	if (res) {
-		__ast_mutex_logger("%s line %d (%s): Error obtaining mutex: %s\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Error obtaining mutex: %s\n",
 				   filename, lineno, func, strerror(res));
 		DO_THREAD_CRASH;
 	}
@@ -394,7 +394,7 @@
 			lt->thread_id[lt->reentrancy] = pthread_self();
 			lt->reentrancy++;
 		} else {
-			__ast_mutex_logger("%s line %d (%s): '%s' really deep reentrancy!\n",
+			ast_mutex_logger(canlog, "%s line %d (%s): '%s' really deep reentrancy!\n",
 					   filename, lineno, func, mutex_name);
 		}
 		ast_reentrancy_unlock(lt);
@@ -419,7 +419,7 @@
 
 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
 	if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
-		__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
 				   filename, lineno, func, mutex_name);
 		DO_THREAD_CRASH;
 		return EINVAL;
@@ -430,9 +430,9 @@
 	if (lt) {
 		ast_reentrancy_lock(lt);
 		if (lt->reentrancy && (lt->thread_id[ROFFSET] != pthread_self())) {
-			__ast_mutex_logger("%s line %d (%s): attempted unlock mutex '%s' without owning it!\n",
+			ast_mutex_logger(canlog, "%s line %d (%s): attempted unlock mutex '%s' without owning it!\n",
 					   filename, lineno, func, mutex_name);
-			__ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n",
+			ast_mutex_logger(canlog, "%s line %d (%s): '%s' was locked here.\n",
 					   lt->file[ROFFSET], lt->lineno[ROFFSET], lt->func[ROFFSET], mutex_name);
 #ifdef HAVE_BKTR
 			__dump_backtrace(&lt->backtrace[ROFFSET], canlog);
@@ -441,7 +441,7 @@
 		}
 
 		if (--lt->reentrancy < 0) {
-			__ast_mutex_logger("%s line %d (%s): mutex '%s' freed more times than we've locked!\n",
+			ast_mutex_logger(canlog, "%s line %d (%s): mutex '%s' freed more times than we've locked!\n",
 					   filename, lineno, func, mutex_name);
 			lt->reentrancy = 0;
 		}
@@ -468,7 +468,7 @@
 
 #ifdef DEBUG_THREADS
 	if (res) {
-		__ast_mutex_logger("%s line %d (%s): Error releasing mutex: %s\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Error releasing mutex: %s\n",
 				   filename, lineno, func, strerror(res));
 		DO_THREAD_CRASH;
 	}
@@ -538,7 +538,7 @@
 
 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
 	if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
-		__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
 				   filename, lineno, func, mutex_name);
 		DO_THREAD_CRASH;
 		return EINVAL;
@@ -549,16 +549,16 @@
 	if (lt) {
 		ast_reentrancy_lock(lt);
 		if (lt->reentrancy && (lt->thread_id[ROFFSET] != pthread_self())) {
-			__ast_mutex_logger("%s line %d (%s): attempted wait using mutex '%s' without owning it!\n",
+			ast_mutex_logger(canlog, "%s line %d (%s): attempted wait using mutex '%s' without owning it!\n",
 					   filename, lineno, func, mutex_name);
-			__ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n",
+			ast_mutex_logger(canlog, "%s line %d (%s): '%s' was locked here.\n",
 					   lt->file[ROFFSET], lt->lineno[ROFFSET], lt->func[ROFFSET], mutex_name);
 #ifdef HAVE_BKTR
 			__dump_backtrace(&lt->backtrace[ROFFSET], canlog);
 #endif
 			DO_THREAD_CRASH;
 		} else if (lt->reentrancy <= 0) {
-			__ast_mutex_logger("%s line %d (%s): attempted wait using an unlocked mutex '%s'\n",
+			ast_mutex_logger(canlog, "%s line %d (%s): attempted wait using an unlocked mutex '%s'\n",
 					   filename, lineno, func, mutex_name);
 			DO_THREAD_CRASH;
 		}
@@ -578,7 +578,7 @@
 
 #ifdef DEBUG_THREADS
 	if (res) {
-		__ast_mutex_logger("%s line %d (%s): Error waiting on condition mutex '%s'\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Error waiting on condition mutex '%s'\n",
 				   filename, lineno, func, strerror(res));
 		DO_THREAD_CRASH;
 	} else if (lt) {
@@ -603,7 +603,7 @@
 
 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
 	if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
-		__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
 				   filename, lineno, func, mutex_name);
 		DO_THREAD_CRASH;
 		return EINVAL;
@@ -614,16 +614,16 @@
 	if (lt) {
 		ast_reentrancy_lock(lt);
 		if (lt->reentrancy && (lt->thread_id[ROFFSET] != pthread_self())) {
-			__ast_mutex_logger("%s line %d (%s): attempted wait using mutex '%s' without owning it!\n",
+			ast_mutex_logger(canlog, "%s line %d (%s): attempted wait using mutex '%s' without owning it!\n",
 					   filename, lineno, func, mutex_name);
-			__ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n",
+			ast_mutex_logger(canlog, "%s line %d (%s): '%s' was locked here.\n",
 					   lt->file[ROFFSET], lt->lineno[ROFFSET], lt->func[ROFFSET], mutex_name);
 #ifdef HAVE_BKTR
 			__dump_backtrace(&lt->backtrace[ROFFSET], canlog);
 #endif
 			DO_THREAD_CRASH;
 		} else if (lt->reentrancy <= 0) {
-			__ast_mutex_logger("%s line %d (%s): attempted wait using an unlocked mutex '%s'\n",
+			ast_mutex_logger(canlog, "%s line %d (%s): attempted wait using an unlocked mutex '%s'\n",
 					   filename, lineno, func, mutex_name);
 			DO_THREAD_CRASH;
 		}
@@ -643,7 +643,7 @@
 
 #ifdef DEBUG_THREADS
 	if (res && (res != ETIMEDOUT)) {
-		__ast_mutex_logger("%s line %d (%s): Error waiting on condition mutex '%s'\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Error waiting on condition mutex '%s'\n",
 				   filename, lineno, func, strerror(res));
 		DO_THREAD_CRASH;
 	} else if (lt) {
@@ -665,7 +665,7 @@
 	if (t->lock != ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) {
 		int canlog = tracking && strcmp(filename, "logger.c");
 
-		__ast_mutex_logger("%s line %d (%s): Warning: rwlock '%s' is already initialized.\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Warning: rwlock '%s' is already initialized.\n",
 				filename, lineno, func, rwlock_name);
 		DO_THREAD_CRASH;
 		return EBUSY;
@@ -697,7 +697,7 @@
 
 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
 	if (t->lock == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) {
-		__ast_mutex_logger("%s line %d (%s): Warning: rwlock '%s' is uninitialized.\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Warning: rwlock '%s' is uninitialized.\n",
 				   filename, lineno, func, rwlock_name);
 		DO_THREAD_CRASH;
 		res = EINVAL;
@@ -710,7 +710,7 @@
 
 #ifdef DEBUG_THREADS
 	if (res) {
-		__ast_mutex_logger("%s line %d (%s): Error destroying rwlock %s: %s\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Error destroying rwlock %s: %s\n",
 				filename, lineno, func, rwlock_name, strerror(res));
 	}
 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
@@ -746,7 +746,7 @@
 
 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS) && defined(CAN_COMPARE_MUTEX_TO_INIT_VALUE)
 	if ((t->lock) == ((pthread_rwlock_t) __AST_RWLOCK_INIT_VALUE)) {
-		__ast_mutex_logger("%s line %d (%s): Warning: rwlock '%s' is uninitialized.\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Warning: rwlock '%s' is uninitialized.\n",
 				   filename, line, func, name);
 		DO_THREAD_CRASH;
 		return EINVAL;
@@ -781,7 +781,7 @@
 		}
 
 		if (lock_found && --lt->reentrancy < 0) {
-			__ast_mutex_logger("%s line %d (%s): rwlock '%s' freed more times than we've locked!\n",
+			ast_mutex_logger(canlog, "%s line %d (%s): rwlock '%s' freed more times than we've locked!\n",
 					filename, line, func, name);
 			lt->reentrancy = 0;
 		}
@@ -796,7 +796,7 @@
 
 #ifdef DEBUG_THREADS
 	if (res) {
-		__ast_mutex_logger("%s line %d (%s): Error releasing rwlock: %s\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Error releasing rwlock: %s\n",
 				filename, line, func, strerror(res));
 		DO_THREAD_CRASH;
 	}
@@ -843,14 +843,14 @@
 			if (res == EBUSY) {
 				wait_time = time(NULL) - seconds;
 				if (wait_time > reported_wait && (wait_time % 5) == 0) {
-					__ast_mutex_logger("%s line %d (%s): Deadlock? waited %d sec for readlock '%s'?\n",
+					ast_mutex_logger(canlog, "%s line %d (%s): Deadlock? waited %d sec for readlock '%s'?\n",
 						filename, line, func, (int)wait_time, name);
 					if (lt) {
 						ast_reentrancy_lock(lt);
 #ifdef HAVE_BKTR
 						__dump_backtrace(&lt->backtrace[lt->reentrancy], canlog);
 #endif
-						__ast_mutex_logger("%s line %d (%s): '%s' was locked  here.\n",
+						ast_mutex_logger(canlog, "%s line %d (%s): '%s' was locked  here.\n",
 								lt->file[lt->reentrancy-1], lt->lineno[lt->reentrancy-1],
 								lt->func[lt->reentrancy-1], name);
 #ifdef HAVE_BKTR
@@ -894,7 +894,7 @@
 	}
 
 	if (res) {
-		__ast_mutex_logger("%s line %d (%s): Error obtaining read lock: %s\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Error obtaining read lock: %s\n",
 				filename, line, func, strerror(res));
 		DO_THREAD_CRASH;
 	}
@@ -941,14 +941,14 @@
 			if (res == EBUSY) {
 				wait_time = time(NULL) - seconds;
 				if (wait_time > reported_wait && (wait_time % 5) == 0) {
-					__ast_mutex_logger("%s line %d (%s): Deadlock? waited %d sec for writelock '%s'?\n",
+					ast_mutex_logger(canlog, "%s line %d (%s): Deadlock? waited %d sec for writelock '%s'?\n",
 						filename, line, func, (int)wait_time, name);
 					if (lt) {
 						ast_reentrancy_lock(lt);
 #ifdef HAVE_BKTR
 						__dump_backtrace(&lt->backtrace[lt->reentrancy], canlog);
 #endif
-						__ast_mutex_logger("%s line %d (%s): '%s' was locked  here.\n",
+						ast_mutex_logger(canlog, "%s line %d (%s): '%s' was locked  here.\n",
 								lt->file[lt->reentrancy-1], lt->lineno[lt->reentrancy-1],
 								lt->func[lt->reentrancy-1], name);
 #ifdef HAVE_BKTR
@@ -991,7 +991,7 @@
 		ast_remove_lock_info(t, bt);
 	}
 	if (res) {
-		__ast_mutex_logger("%s line %d (%s): Error obtaining write lock: %s\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Error obtaining write lock: %s\n",
 				filename, line, func, strerror(res));
 		DO_THREAD_CRASH;
 	}
@@ -1073,7 +1073,7 @@
 		ast_remove_lock_info(t, bt);
 	}
 	if (res) {
-		__ast_mutex_logger("%s line %d (%s): Error obtaining read lock: %s\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Error obtaining read lock: %s\n",
 				filename, line, func, strerror(res));
 		DO_THREAD_CRASH;
 	}
@@ -1155,7 +1155,7 @@
 		ast_remove_lock_info(t, bt);
 	}
 	if (res) {
-		__ast_mutex_logger("%s line %d (%s): Error obtaining read lock: %s\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Error obtaining read lock: %s\n",
 				filename, line, func, strerror(res));
 		DO_THREAD_CRASH;
 	}
diff --git a/utils/extconf.c b/utils/extconf.c
index 2beaef4..9e07073 100644
--- a/utils/extconf.c
+++ b/utils/extconf.c
@@ -196,7 +196,7 @@
 
 #ifdef DEBUG_THREADS
 
-#define __ast_mutex_logger(...)  do { if (canlog) ast_log(LOG_ERROR, __VA_ARGS__); else fprintf(stderr, __VA_ARGS__); } while (0)
+#define ast_mutex_logger(canlog, ...)  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)
@@ -239,9 +239,9 @@
 
 	if ((t->mutex) != ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
 		if ((t->mutex) != (empty_mutex)) {
-			__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is already initialized.\n",
+			ast_mutex_logger(canlog, "%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",
+			ast_mutex_logger(canlog, "%s line %d (%s): Error: previously initialization of mutex '%s'.\n",
 					   t->file[0], t->lineno[0], t->func[0], mutex_name);
 			DO_THREAD_CRASH;
 			return 0;
@@ -278,7 +278,7 @@
 
 #ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
 	if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
-		__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
 				   filename, lineno, func, mutex_name);
 	}
 #endif
@@ -289,19 +289,19 @@
 		pthread_mutex_unlock(&t->mutex);
 		break;
 	case EINVAL:
-		__ast_mutex_logger("%s line %d (%s): Error: attempt to destroy invalid mutex '%s'.\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Error: attempt to destroy invalid mutex '%s'.\n",
 				  filename, lineno, func, mutex_name);
 		break;
 	case EBUSY:
-		__ast_mutex_logger("%s line %d (%s): Error: attempt to destroy locked mutex '%s'.\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Error: attempt to destroy locked mutex '%s'.\n",
 				   filename, lineno, func, mutex_name);
-		__ast_mutex_logger("%s line %d (%s): Error: '%s' was locked here.\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Error: '%s' was locked here.\n",
 				   t->file[t->reentrancy-1], t->lineno[t->reentrancy-1], t->func[t->reentrancy-1], mutex_name);
 		break;
 	}
 
 	if ((res = pthread_mutex_destroy(&t->mutex)))
-		__ast_mutex_logger("%s line %d (%s): Error destroying mutex: %s\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Error destroying mutex: %s\n",
 				   filename, lineno, func, strerror(res));
 #ifndef PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
 	else
@@ -322,7 +322,7 @@
 
 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS)
 	if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
-		__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
 				 filename, lineno, func, mutex_name);
 		ast_mutex_init(t);
 	}
@@ -343,9 +343,9 @@
 			if (res == EBUSY) {
 				current = time(NULL);
 				if ((current - seconds) && (!((current - seconds) % 5))) {
-					__ast_mutex_logger("%s line %d (%s): Deadlock? waited %d sec for mutex '%s'?\n",
+					ast_mutex_logger(canlog, "%s line %d (%s): Deadlock? waited %d sec for mutex '%s'?\n",
 							   filename, lineno, func, (int)(current - seconds), mutex_name);
-					__ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n",
+					ast_mutex_logger(canlog, "%s line %d (%s): '%s' was locked here.\n",
 							   t->file[t->reentrancy-1], t->lineno[t->reentrancy-1],
 							   t->func[t->reentrancy-1], mutex_name);
 				}
@@ -371,11 +371,11 @@
 			t->thread[t->reentrancy] = pthread_self();
 			t->reentrancy++;
 		} else {
-			__ast_mutex_logger("%s line %d (%s): '%s' really deep reentrancy!\n",
+			ast_mutex_logger(canlog, "%s line %d (%s): '%s' really deep reentrancy!\n",
 							   filename, lineno, func, mutex_name);
 		}
 	} else {
-		__ast_mutex_logger("%s line %d (%s): Error obtaining mutex: %s\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Error obtaining mutex: %s\n",
 				   filename, lineno, func, strerror(errno));
 		DO_THREAD_CRASH;
 	}
@@ -391,7 +391,7 @@
 
 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS)
 	if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
-		__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
 				   filename, lineno, func, mutex_name);
 		ast_mutex_init(t);
 	}
@@ -405,11 +405,11 @@
 			t->thread[t->reentrancy] = pthread_self();
 			t->reentrancy++;
 		} else {
-			__ast_mutex_logger("%s line %d (%s): '%s' really deep reentrancy!\n",
+			ast_mutex_logger(canlog, "%s line %d (%s): '%s' really deep reentrancy!\n",
 					   filename, lineno, func, mutex_name);
 		}
 	} else {
-		__ast_mutex_logger("%s line %d (%s): Warning: '%s' was locked here.\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Warning: '%s' was locked here.\n",
                                    t->file[t->reentrancy-1], t->lineno[t->reentrancy-1], t->func[t->reentrancy-1], mutex_name);
 	}
 
@@ -424,21 +424,21 @@
 
 #ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
 	if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
-		__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
 				   filename, lineno, func, mutex_name);
 	}
 #endif
 
 	if (t->reentrancy && (t->thread[t->reentrancy-1] != pthread_self())) {
-		__ast_mutex_logger("%s line %d (%s): attempted unlock mutex '%s' without owning it!\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): attempted unlock mutex '%s' without owning it!\n",
 				   filename, lineno, func, mutex_name);
-		__ast_mutex_logger("%s line %d (%s): '%s' was locked here.\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): '%s' was locked here.\n",
 				   t->file[t->reentrancy-1], t->lineno[t->reentrancy-1], t->func[t->reentrancy-1], mutex_name);
 		DO_THREAD_CRASH;
 	}
 
 	if (--t->reentrancy < 0) {
-		__ast_mutex_logger("%s line %d (%s): mutex '%s' freed more times than we've locked!\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): mutex '%s' freed more times than we've locked!\n",
 				   filename, lineno, func, mutex_name);
 		t->reentrancy = 0;
 	}
@@ -451,7 +451,7 @@
 	}
 
 	if ((res = pthread_mutex_unlock(&t->mutex))) {
-		__ast_mutex_logger("%s line %d (%s): Error releasing mutex: %s\n",
+		ast_mutex_logger(canlog, "%s line %d (%s): Error releasing mutex: %s\n",
 				   filename, lineno, func, strerror(res));
 		DO_THREAD_CRASH;
 	}

-- 
To view, visit https://gerrit.asterisk.org/10519
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I83b372cb0654c5c18eadc512f65a57fa6c2e9853
Gerrit-Change-Number: 10519
Gerrit-PatchSet: 1
Gerrit-Owner: Corey Farrell <git at cfware.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20181019/b7af0978/attachment-0001.html>


More information about the asterisk-code-review mailing list