]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
performance tweaks
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 15 Aug 2006 17:52:12 +0000 (17:52 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 15 Aug 2006 17:52:12 +0000 (17:52 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@2298 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/include/switch_types.h
src/switch.c
src/switch_core.c
src/switch_log.c

index af6fdba253b891415be632f12ac2ab963d03426e..46d5fc61d39d575eface8bca20c94184e10f1014 100644 (file)
@@ -86,7 +86,7 @@ struct switch_directories {
 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
index 51cac5af3a045fec7db07f2c8c9dfa68dc99c33a..3c07f8722ed0404a7c32756fec2683cfee07d9b3 100644 (file)
@@ -225,5 +225,7 @@ int main(int argc, char *argv[])
        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;
 }
index 9391098beabed62f38e6cfe2a79ab9b60a2f72f8..744f3e3bb4225497b19ef5307ba5162a8af4b926 100644 (file)
@@ -3118,7 +3118,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_destroy(void)
 
        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");
@@ -3128,7 +3128,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_destroy(void)
        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);
index 0938ff8e8a2446046cb9a49211ad36ba41371102..9490e7d3981f447f70d633c6d1119621929a6e8d 100644 (file)
@@ -118,7 +118,7 @@ static void *SWITCH_THREAD_FUNC log_thread(switch_thread_t *thread, void *obj)
        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 @@ static void *SWITCH_THREAD_FUNC log_thread(switch_thread_t *thread, void *obj)
                }
                
                if (!pop) {
+                       LOG_QUEUE = NULL;
                        break;
                }
                
@@ -222,23 +223,23 @@ SWITCH_DECLARE(void) switch_log_printf(switch_text_channel_t channel, char *file
                                        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);
+                               }
+                       } 
                }
        }