From 5190bd08491ff9c1e9b62230ddc9b9bbb54cb1e9 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Fri, 4 May 2012 08:25:48 -0500 Subject: [PATCH] FS-4186 --resolve --- src/mod/endpoints/mod_sofia/mod_sofia.h | 2 +- src/switch_core.c | 5 +++++ src/switch_event.c | 7 ++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/mod/endpoints/mod_sofia/mod_sofia.h b/src/mod/endpoints/mod_sofia/mod_sofia.h index 64dfc48c8c..5a51f68a2d 100644 --- a/src/mod/endpoints/mod_sofia/mod_sofia.h +++ b/src/mod/endpoints/mod_sofia/mod_sofia.h @@ -337,7 +337,7 @@ typedef enum { } TFLAGS; #define SOFIA_MAX_MSG_QUEUE 64 -#define SOFIA_MSG_QUEUE_SIZE 100 +#define SOFIA_MSG_QUEUE_SIZE 250 struct mod_sofia_globals { switch_memory_pool_t *pool; diff --git a/src/switch_core.c b/src/switch_core.c index 8b93c84301..f957a7ae5e 100644 --- a/src/switch_core.c +++ b/src/switch_core.c @@ -744,6 +744,8 @@ SWITCH_DECLARE(int32_t) set_auto_priority(void) runtime.cpu_count = sysinfo.dwNumberOfProcessors; #endif + if (!runtime.cpu_count) runtime.cpu_count = 1; + /* If we have more than 1 cpu, we should use realtime priority so we can have priority threads */ if (runtime.cpu_count > 1) { return set_realtime_priority(); @@ -1421,6 +1423,9 @@ SWITCH_DECLARE(switch_status_t) switch_core_init(switch_core_flag_t flags, switc } #endif + if (!runtime.cpu_count) runtime.cpu_count = 1; + + /* INIT APR and Create the pool context */ if (apr_initialize() != SWITCH_STATUS_SUCCESS) { *err = "FATAL ERROR! Could not initialize APR\n"; diff --git a/src/switch_event.c b/src/switch_event.c index c4d118e3d2..bce57b79ee 100644 --- a/src/switch_event.c +++ b/src/switch_event.c @@ -35,7 +35,7 @@ #include #include //#define SWITCH_EVENT_RECYCLE -#define DISPATCH_QUEUE_LEN 10000 +#define DISPATCH_QUEUE_LEN 1000 //#define DEBUG_DISPATCH_QUEUES /*! \brief A node to store binded events */ @@ -345,8 +345,9 @@ static void *SWITCH_THREAD_FUNC switch_event_thread(switch_thread_t *thread, voi launch_dispatch_threads(SOFT_MAX_DISPATCH + 1, DISPATCH_QUEUE_LEN, RUNTIME_POOL); switch_mutex_unlock(EVENT_QUEUE_MUTEX); } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Out of event dispatch threads! Resorting to a blocking push.... Look for laggy event consumers or event_socket connections!\n"); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Event Thread %d is blocking\n", my_id); switch_queue_push(EVENT_DISPATCH_QUEUE[0], event); + event = NULL; } } } @@ -623,7 +624,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_init(switch_memory_pool_t *pool) */ /* don't need any more dispatch threads than we have CPU's*/ - MAX_DISPATCH = switch_core_cpu_count(); + MAX_DISPATCH = switch_core_cpu_count() + 1; switch_assert(pool != NULL);