]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
change default to use event dispatch
authorAnthony Minessale <anthm@freeswitch.org>
Tue, 1 Oct 2013 15:10:14 +0000 (20:10 +0500)
committerAnthony Minessale <anthm@freeswitch.org>
Tue, 1 Oct 2013 15:10:24 +0000 (20:10 +0500)
src/switch_core.c
src/switch_event.c

index 73c9d056ac5af09f5db52cee218614f260a5637c..7a8edfeec8faa9a8d559f9d476fc11d83dc7a2d0 100644 (file)
@@ -1659,6 +1659,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc
                runtime.console = stdout;
        }
 
+       SSL_library_init();
        switch_ssl_init_ssl_locks();
        switch_curl_init();
 
@@ -1792,11 +1793,6 @@ static void switch_load_core_config(const char *file)
        switch_core_hash_insert(runtime.ptimes, "isac", &d_30);
        switch_core_hash_insert(runtime.ptimes, "G723", &d_30);
 
-       if (runtime.cpu_count == 1) {
-               switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
-                                                 "Implicitly setting events-use-dispatch based on a single CPU\n");
-               runtime.events_use_dispatch = 1;
-       }
 
        if ((xml = switch_xml_open_cfg(file, &cfg, NULL))) {
                switch_xml_t settings, param;
@@ -1970,7 +1966,7 @@ static void switch_load_core_config(const char *file)
                                } else if (!strcasecmp(var, "tipping-point") && !zstr(val)) {
                                        runtime.tipping_point = atoi(val);
                                } else if (!strcasecmp(var, "events-use-dispatch") && !zstr(val)) {
-                                       runtime.events_use_dispatch = 1;
+                                       runtime.events_use_dispatch = switch_true(val);
                                } else if (!strcasecmp(var, "initial-event-threads") && !zstr(val)) {
                                        int tmp;
 
@@ -2092,6 +2088,7 @@ SWITCH_DECLARE(switch_status_t) switch_core_init_and_modload(switch_core_flag_t
        }
 
        runtime.runlevel++;
+       runtime.events_use_dispatch = 1;
 
        switch_core_set_signal_handlers();
        switch_load_network_lists(SWITCH_FALSE);
index 88863153c64e1d280e321438f1c2c394b20f7ef7..080a331dcd9f3cfab841b7b4f346063646b273f6 100644 (file)
@@ -571,6 +571,25 @@ SWITCH_DECLARE(switch_status_t) switch_event_shutdown(void)
        return SWITCH_STATUS_SUCCESS;
 }
 
+static void check_dispatch(void)
+{
+       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);
+       }            
+}
+
+
+
 SWITCH_DECLARE(void) switch_event_launch_dispatch_threads(uint32_t max)
 {
        switch_threadattr_t *thd_attr;
@@ -580,6 +599,8 @@ SWITCH_DECLARE(void) switch_event_launch_dispatch_threads(uint32_t max)
 
        switch_memory_pool_t *pool = RUNTIME_POOL;
 
+       check_dispatch();
+
        if (max > MAX_DISPATCH) {
                return;
        }
@@ -649,6 +670,8 @@ SWITCH_DECLARE(switch_status_t) switch_event_init(switch_memory_pool_t *pool)
        switch_queue_create(&EVENT_HEADER_RECYCLE_QUEUE, 250000, THRUNTIME_POOL);
 #endif
 
+       check_dispatch();
+
        switch_mutex_lock(EVENT_QUEUE_MUTEX);
        SYSTEM_RUNNING = 1;
        switch_mutex_unlock(EVENT_QUEUE_MUTEX);
@@ -1901,19 +1924,7 @@ 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);
-        }            
+               check_dispatch();
 
                if (switch_event_queue_dispatch_event(event) != SWITCH_STATUS_SUCCESS) {
                        switch_event_destroy(event);