From fdc7cd03d7dff9dd9cb4ee0f5fd64c028437c592 Mon Sep 17 00:00:00 2001
From: Anthony Minessale <anthm@freeswitch.org>
Date: Fri, 6 Sep 2013 00:07:50 +0500
Subject: [PATCH] add define for thread pool debug

---
 src/switch_core_session.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/switch_core_session.c b/src/switch_core_session.c
index 389345fca6..97a81c39c1 100644
--- a/src/switch_core_session.c
+++ b/src/switch_core_session.c
@@ -1579,9 +1579,9 @@ static void *SWITCH_THREAD_FUNC switch_core_session_thread_pool_worker(switch_th
 	switch_mutex_lock(session_manager.mutex);
 	session_manager.running++;
 	switch_mutex_unlock(session_manager.mutex);
-
+#ifdef DEBUG_THREAD_POOL
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "Worker Thread %ld Started\n", (long) thread);
-
+#endif
 	while(session_manager.ready) {
 		switch_status_t check_status;
 
@@ -1609,9 +1609,9 @@ static void *SWITCH_THREAD_FUNC switch_core_session_thread_pool_worker(switch_th
 			switch_mutex_lock(session_manager.mutex);
 			session_manager.busy++;
 			switch_mutex_unlock(session_manager.mutex);
-			
+#ifdef DEBUG_THREAD_POOL			
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "Worker Thread %ld Processing\n", (long) thread);
-
+#endif
 
 			td->func(thread, td->obj);
 
@@ -1622,9 +1622,9 @@ static void *SWITCH_THREAD_FUNC switch_core_session_thread_pool_worker(switch_th
 			} else if (td->alloc) {
 				free(td);
 			}
-
+#ifdef DEBUG_THREAD_POOL
 			switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "Worker Thread %ld Done Processing\n", (long) thread);
-			
+#endif
 			switch_mutex_lock(session_manager.mutex);
 			session_manager.busy--;
 			switch_mutex_unlock(session_manager.mutex);
@@ -1636,9 +1636,9 @@ static void *SWITCH_THREAD_FUNC switch_core_session_thread_pool_worker(switch_th
 			check++;
 		}
 	}
-
+#ifdef DEBUG_THREAD_POOL
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, "Worker Thread %ld Ended\n", (long) thread);
-
+#endif
 	switch_mutex_lock(session_manager.mutex);
 	session_manager.running--;
 	switch_mutex_unlock(session_manager.mutex);
@@ -1722,9 +1722,10 @@ static void *SWITCH_THREAD_FUNC switch_core_session_thread_pool_manager(switch_t
 
 		if (++x == 300) {
 			if (session_manager.popping) {
+#ifdef DEBUG_THREAD_POOL
 				switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG10, 
 								  "Thread pool: running:%d busy:%d popping:%d\n", session_manager.running, session_manager.busy, session_manager.popping);
-
+#endif
 				switch_queue_interrupt_all(session_manager.thread_queue);
 
 				x--;