[Freeswitch-svn] [commit] r2298 - in freeswitch/trunk/src: . include

Freeswitch SVN anthm at freeswitch.org
Tue Aug 15 13:52:12 EDT 2006


Author: anthm
Date: Tue Aug 15 13:52:12 2006
New Revision: 2298

Modified:
   freeswitch/trunk/src/include/switch_types.h
   freeswitch/trunk/src/switch.c
   freeswitch/trunk/src/switch_core.c
   freeswitch/trunk/src/switch_log.c

Log:
performance tweaks

Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h	(original)
+++ freeswitch/trunk/src/include/switch_types.h	Tue Aug 15 13:52:12 2006
@@ -86,7 +86,7 @@
 typedef struct switch_directories switch_directories;
 SWITCH_DECLARE_DATA extern switch_directories SWITCH_GLOBAL_dirs;
 
-#define SWITCH_THREAD_STACKSIZE 512 * 1024
+#define SWITCH_THREAD_STACKSIZE 384 * 1024
 #define SWITCH_RECCOMMENDED_BUFFER_SIZE 2048
 #define SWITCH_MAX_CODECS 30
 #define SWITCH_MAX_STATE_HANDLERS 30

Modified: freeswitch/trunk/src/switch.c
==============================================================================
--- freeswitch/trunk/src/switch.c	(original)
+++ freeswitch/trunk/src/switch.c	Tue Aug 15 13:52:12 2006
@@ -225,5 +225,7 @@
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Tearing down environment.\n");
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Exiting Now.\n");
 	switch_core_destroy();
+
+
 	return 0;
 }

Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c	(original)
+++ freeswitch/trunk/src/switch_core.c	Tue Aug 15 13:52:12 2006
@@ -3118,8 +3118,8 @@
 
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Closing Event Engine.\n");
 	switch_event_shutdown();
-	switch_log_shutdown();
 
+
 	switch_queue_push(runtime.sql_queue, NULL);
 	switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Waiting for unfinished SQL transactions\n");
 	while (switch_queue_size(runtime.sql_queue) > 0) {
@@ -3128,7 +3128,8 @@
 	switch_core_db_close(runtime.db);
 	switch_core_db_close(runtime.event_db);
 	switch_xml_destroy();
-
+	switch_log_shutdown();
+	switch_yield(10000);
 	if (runtime.memory_pool) {
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Unallocating memory pool.\n");
 		apr_pool_destroy(runtime.memory_pool);

Modified: freeswitch/trunk/src/switch_log.c
==============================================================================
--- freeswitch/trunk/src/switch_log.c	(original)
+++ freeswitch/trunk/src/switch_log.c	Tue Aug 15 13:52:12 2006
@@ -118,7 +118,7 @@
 	assert(obj == NULL || obj != NULL);
 	THREAD_RUNNING = 1;
 
-	for(;;) {
+	while(LOG_QUEUE) {
 		void *pop = NULL;
 		switch_log_node_t *node = NULL;
 		switch_log_binding_t *binding;
@@ -128,6 +128,7 @@
 		}
 		
 		if (!pop) {
+			LOG_QUEUE = NULL;
 			break;
 		}
 		
@@ -222,23 +223,23 @@
 					switch_event_fire(&event);
 				}
 		} else {
-			if (level == SWITCH_LOG_CONSOLE || !THREAD_RUNNING) {
+			if (level == SWITCH_LOG_CONSOLE || !LOG_QUEUE || !THREAD_RUNNING) {
 				fprintf(handle, data);
-			} 
-
-			if (level <= MAX_LEVEL) {
-				switch_log_node_t *node = malloc(sizeof(*node));
-				node->data = data;
-				node->file = strdup(filep);
-				node->func = strdup(func);
-				node->line = line;
-				node->level = level;
-				node->content = content;
-				node->timestamp = now;
-				switch_queue_push(LOG_QUEUE, node);
-			} else {
 				free(data);
-			}
+			} else if (level <= MAX_LEVEL) {
+				switch_log_node_t *node;
+
+				if ((node = malloc(sizeof(*node)))) {
+					node->data = data;
+					node->file = strdup(filep);
+					node->func = strdup(func);
+					node->line = line;
+					node->level = level;
+					node->content = content;
+					node->timestamp = now;
+					switch_queue_push(LOG_QUEUE, node);
+				}
+			} 
 		}
 	}
 



More information about the Freeswitch-svn mailing list