add initial-event-threads to switch.conf.xml

This commit is contained in:
Anthony Minessale 2012-06-29 11:39:49 -05:00
parent dca6e2bb8e
commit 7ec8fb43d4
3 changed files with 28 additions and 7 deletions

View File

@ -403,6 +403,7 @@ SWITCH_DECLARE(void) switch_event_deliver(switch_event_t **event);
SWITCH_DECLARE(char *) switch_event_build_param_string(switch_event_t *event, const char *prefix, switch_hash_t *vars_map);
SWITCH_DECLARE(int) switch_event_check_permission_list(switch_event_t *list, const char *name);
SWITCH_DECLARE(void) switch_event_add_presence_data_cols(switch_channel_t *channel, switch_event_t *event, const char *prefix);
SWITCH_DECLARE(void) switch_event_launch_dispatch_threads(uint32_t max);
///\}

View File

@ -1813,6 +1813,23 @@ static void switch_load_core_config(const char *file)
switch_core_min_idle_cpu(atof(val));
} else if (!strcasecmp(var, "tipping-point") && !zstr(val)) {
runtime.tipping_point = atoi(val);
} else if (!strcasecmp(var, "initial-event-threads") && !zstr(val)) {
int tmp = atoi(val);
if (tmp > runtime.cpu_count / 2) {
tmp = runtime.cpu_count / 2;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "This value cannot be higher than %d so setting it to that value\n",
runtime.cpu_count / 2);
}
if (tmp < 1) {
tmp = 1;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "This value cannot be lower than 1 so setting it to that level\n");
}
switch_event_launch_dispatch_threads(tmp);
} else if (!strcasecmp(var, "1ms-timer") && switch_true(val)) {
runtime.microseconds_per_tick = 1000;
} else if (!strcasecmp(var, "timer-affinity") && !zstr(val)) {

View File

@ -34,6 +34,7 @@
#include <switch.h>
#include <switch_event.h>
//#define SWITCH_EVENT_RECYCLE
#define DISPATCH_QUEUE_LEN 100
//#define DEBUG_DISPATCH_QUEUES
@ -87,7 +88,6 @@ static uint64_t EVENT_SEQUENCE_NR = 0;
static switch_queue_t *EVENT_RECYCLE_QUEUE = NULL;
static switch_queue_t *EVENT_HEADER_RECYCLE_QUEUE = NULL;
#endif
static void launch_dispatch_threads(uint32_t max, switch_memory_pool_t *pool);
static char *my_dup(const char *s)
{
@ -305,7 +305,7 @@ static switch_status_t switch_event_queue_dispatch_event(switch_event_t **eventp
if (launch) {
if (SOFT_MAX_DISPATCH + 1 < MAX_DISPATCH) {
launch_dispatch_threads(SOFT_MAX_DISPATCH + 1, RUNTIME_POOL);
switch_event_launch_dispatch_threads(SOFT_MAX_DISPATCH + 1);
}
}
@ -515,13 +515,15 @@ SWITCH_DECLARE(switch_status_t) switch_event_shutdown(void)
return SWITCH_STATUS_SUCCESS;
}
static void launch_dispatch_threads(uint32_t max, switch_memory_pool_t *pool)
SWITCH_DECLARE(void) switch_event_launch_dispatch_threads(uint32_t max)
{
switch_threadattr_t *thd_attr;
uint32_t index = 0;
int launched = 0;
uint32_t sanity = 200;
switch_memory_pool_t *pool = RUNTIME_POOL;
if (max > MAX_DISPATCH) {
return;
}
@ -532,6 +534,7 @@ static void launch_dispatch_threads(uint32_t max, switch_memory_pool_t *pool)
for (index = SOFT_MAX_DISPATCH; index < max && index < MAX_DISPATCH; index++) {
if (EVENT_DISPATCH_QUEUE_THREADS[index]) {
printf("Index exists continue\n");
continue;
}
@ -540,13 +543,13 @@ static void launch_dispatch_threads(uint32_t max, switch_memory_pool_t *pool)
switch_threadattr_priority_increase(thd_attr);
switch_thread_create(&EVENT_DISPATCH_QUEUE_THREADS[index], thd_attr, switch_event_dispatch_thread, EVENT_DISPATCH_QUEUE, pool);
while(--sanity && !EVENT_DISPATCH_QUEUE_RUNNING[index]) switch_yield(10000);
if (index == 1) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Create event dispatch thread %d\n", index);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Create event dispatch thread %d\n", index);
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "Create additional event dispatch thread %d\n", index);
}
launched++;
break;
}
SOFT_MAX_DISPATCH = index;
@ -598,7 +601,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_init(switch_memory_pool_t *pool)
//switch_threadattr_priority_increase(thd_attr);
switch_queue_create(&EVENT_DISPATCH_QUEUE, DISPATCH_QUEUE_LEN * MAX_DISPATCH, pool);
launch_dispatch_threads(1, RUNTIME_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);