diff --git a/src/switch_event.c b/src/switch_event.c index b87d1d4d4b..88863153c6 100644 --- a/src/switch_event.c +++ b/src/switch_event.c @@ -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;