Index: include/asterisk/lock.h
===================================================================
--- include/asterisk/lock.h	(revision 86697)
+++ include/asterisk/lock.h	(working copy)
@@ -103,10 +103,11 @@
 #include <stdio.h>
 #include <unistd.h>
 
-#define AST_MUTEX_INIT_VALUE { PTHREAD_MUTEX_INIT_VALUE, 1, { NULL }, { 0 }, 0, { NULL }, { 0 } }
+#define AST_MUTEX_INIT_VALUE { PTHREAD_MUTEX_INIT_VALUE, 1, { NULL }, { 0 }, 0, { NULL }, { 0 }, PTHREAD_MUTEX_INIT_VALUE }
 #define AST_MUTEX_INIT_VALUE_NOTRACKING \
-                             { PTHREAD_MUTEX_INIT_VALUE, 0, { NULL }, { 0 }, 0, { NULL }, { 0 } }
+                             { PTHREAD_MUTEX_INIT_VALUE, 0, { NULL }, { 0 }, 0, { NULL }, { 0 }, PTHREAD_MUTEX_INIT_VALUE }
 
+
 #define AST_MAX_REENTRANCY 10
 
 struct ast_mutex_info {
@@ -206,17 +207,23 @@
 						const char *mutex_name, ast_mutex_t *t,
 						pthread_mutexattr_t *attr) 
 {
+
 #ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
-	int canlog = strcmp(filename, "logger.c");
+	int canlog = strcmp(filename, "logger.c") && track;
 
 	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",
 					   filename, lineno, func, mutex_name);
-			__ast_mutex_logger("%s line %d (%s): Error: previously initialization of mutex '%s'.\n",
+			/* Don't print track info about nontracked mutex */
+			if(track)
+				__ast_mutex_logger("%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;
+
 		}
 	}
 #endif
@@ -248,9 +255,11 @@
 	int canlog = strcmp(filename, "logger.c");
 
 #ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+	canlog &= t->track;
 	if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
 		__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
 				   filename, lineno, func, mutex_name);
+		return 0; /* mutex is uninitialized */
 	}
 #endif
 
@@ -302,10 +311,13 @@
 		ast_store_lock_info(AST_MUTEX, filename, lineno, func, mutex_name, &t->mutex);
 
 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS)
+	canlog &= t->track;
+
 	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("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
 				 filename, lineno, func, mutex_name);
-		ast_mutex_init(t);
+		__ast_pthread_mutex_init(t->track, filename, lineno, func, mutex_name, t);
+			
 	}
 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
 
@@ -379,10 +391,13 @@
 	int canlog = strcmp(filename, "logger.c");
 
 #if defined(AST_MUTEX_INIT_W_CONSTRUCTORS)
+	canlog &= t->track;
+	
 	if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
 		__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
 				   filename, lineno, func, mutex_name);
-		ast_mutex_init(t);
+		__ast_pthread_mutex_init(t->track, filename, lineno, func, mutex_name, t);
+
 	}
 #endif /* AST_MUTEX_INIT_W_CONSTRUCTORS */
 
@@ -418,6 +433,8 @@
 	int canlog = strcmp(filename, "logger.c");
 
 #ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+	canlog &= t->track;
+	
 	if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
 		__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
 				   filename, lineno, func, mutex_name);
@@ -491,6 +508,7 @@
 	int canlog = strcmp(filename, "logger.c");
 
 #ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+	canlog &= t->track;
 	if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
 		__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
 				   filename, lineno, func, mutex_name);
@@ -556,6 +574,7 @@
 	int canlog = strcmp(filename, "logger.c");
 
 #ifdef AST_MUTEX_INIT_W_CONSTRUCTORS
+	canlog &= t->track;
 	if ((t->mutex) == ((pthread_mutex_t) PTHREAD_MUTEX_INITIALIZER)) {
 		__ast_mutex_logger("%s line %d (%s): Error: mutex '%s' is uninitialized.\n",
 				   filename, lineno, func, mutex_name);
