]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
move thread launch to be after config check for back-compat mode in event handler
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 24 Sep 2013 02:59:01 +0000 (21:59 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 24 Sep 2013 02:59:01 +0000 (21:59 -0500)
src/switch_event.c

index b87d1d4d4be51ebee73160605b78efc4529eefcd..88863153c64e1d280e321438f1c2c394b20f7ef7 100644 (file)
@@ -644,31 +644,11 @@ SWITCH_DECLARE(switch_status_t) switch_event_init(switch_memory_pool_t *pool)
        switch_find_local_ip(guess_ip_v6, sizeof(guess_ip_v6), NULL, AF_INET6);
 
 
-       //switch_queue_create(&EVENT_QUEUE[0], POOL_COUNT_MAX + 10, THRUNTIME_POOL);
-       //switch_queue_create(&EVENT_QUEUE[1], POOL_COUNT_MAX + 10, THRUNTIME_POOL);
-       //switch_queue_create(&EVENT_QUEUE[2], POOL_COUNT_MAX + 10, THRUNTIME_POOL);
 #ifdef SWITCH_EVENT_RECYCLE
        switch_queue_create(&EVENT_RECYCLE_QUEUE, 250000, THRUNTIME_POOL);
        switch_queue_create(&EVENT_HEADER_RECYCLE_QUEUE, 250000, THRUNTIME_POOL);
 #endif
 
-       //switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
-
-       if (runtime.events_use_dispatch) {
-               switch_queue_create(&EVENT_DISPATCH_QUEUE, DISPATCH_QUEUE_LEN * MAX_DISPATCH, pool);
-               switch_event_launch_dispatch_threads(1);
-       }
-
-       //switch_thread_create(&EVENT_QUEUE_THREADS[0], thd_attr, switch_event_thread, EVENT_QUEUE[0], RUNTIME_POOL);
-       //switch_thread_create(&EVENT_QUEUE_THREADS[1], thd_attr, switch_event_thread, EVENT_QUEUE[1], RUNTIME_POOL);
-       //switch_thread_create(&EVENT_QUEUE_THREADS[2], thd_attr, switch_event_thread, EVENT_QUEUE[2], RUNTIME_POOL);
-
-       if (runtime.events_use_dispatch) {
-               while (!THREAD_COUNT) {
-                       switch_cond_next();
-               }
-       }
-
        switch_mutex_lock(EVENT_QUEUE_MUTEX);
        SYSTEM_RUNNING = 1;
        switch_mutex_unlock(EVENT_QUEUE_MUTEX);
@@ -1921,6 +1901,20 @@ SWITCH_DECLARE(switch_status_t) switch_event_fire_detailed(const char *file, con
 
 
        if (runtime.events_use_dispatch) {
+        if (!EVENT_DISPATCH_QUEUE) {
+            switch_mutex_lock(BLOCK);
+
+            if (!EVENT_DISPATCH_QUEUE) {
+                               switch_queue_create(&EVENT_DISPATCH_QUEUE, DISPATCH_QUEUE_LEN * MAX_DISPATCH, THRUNTIME_POOL);
+                switch_event_launch_dispatch_threads(1);
+
+                while (!THREAD_COUNT) {
+                    switch_cond_next();
+                }
+            }
+            switch_mutex_unlock(BLOCK);
+        }            
+
                if (switch_event_queue_dispatch_event(event) != SWITCH_STATUS_SUCCESS) {
                        switch_event_destroy(event);
                        return SWITCH_STATUS_FALSE;