int to = 60;
if (ann) {
- member->conference->special_announce = switch_core_strdup(member->conference->pool, ann);
+ member->conference->special_announce = switch_core_strdup(member->pool, ann);
}
switch_channel_set_private(channel, "_conference_autocall_list_", NULL);
if (!conference->sh) {
memset(&conference->lsh, 0, sizeof(conference->lsh));
if (switch_core_speech_open(&conference->lsh, conference->tts_engine, conference->tts_voice,
- conference->rate, conference->interval, &flags, conference->pool) != SWITCH_STATUS_SUCCESS) {
+ conference->rate, conference->interval, &flags, NULL) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid TTS module [%s]!\n", conference->tts_engine);
return SWITCH_STATUS_FALSE;
}
static switch_hash_t *CUSTOM_HASH = NULL;
static int THREAD_COUNT = 0;
static int SYSTEM_RUNNING = 0;
+#ifdef SWITCH_EVENT_RECYCLE
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, int len, switch_memory_pool_t *pool);
static char *my_dup(const char *s)
SWITCH_DECLARE(void) switch_core_memory_reclaim_events(void)
{
+#ifdef SWITCH_EVENT_RECYCLE
+
void *pop;
int size;
size = switch_queue_size(EVENT_RECYCLE_QUEUE);
while (switch_queue_trypop(EVENT_RECYCLE_QUEUE, &pop) == SWITCH_STATUS_SUCCESS && pop) {
free(pop);
}
+#else
+ return;
+#endif
+
}
SWITCH_DECLARE(switch_status_t) switch_event_shutdown(void)
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);
switch_threadattr_priority_increase(thd_attr);
SWITCH_DECLARE(switch_status_t) switch_event_create_subclass_detailed(const char *file, const char *func, int line,
switch_event_t **event, switch_event_types_t event_id, const char *subclass_name)
{
+#ifdef SWITCH_EVENT_RECYCLE
void *pop;
+#endif
*event = NULL;
return SWITCH_STATUS_GENERR;
}
+#ifdef SWITCH_EVENT_RECYCLE
if (switch_queue_trypop(EVENT_RECYCLE_QUEUE, &pop) == SWITCH_STATUS_SUCCESS && pop) {
*event = (switch_event_t *) pop;
} else {
+#endif
*event = ALLOC(sizeof(switch_event_t));
switch_assert(*event);
+#ifdef SWITCH_EVENT_RECYCLE
}
+#endif
memset(*event, 0, sizeof(switch_event_t));
FREE(hp->name);
FREE(hp->value);
memset(hp, 0, sizeof(*hp));
+#ifdef SWITCH_EVENT_RECYCLE
if (switch_queue_trypush(EVENT_HEADER_RECYCLE_QUEUE, hp) != SWITCH_STATUS_SUCCESS) {
FREE(hp);
}
+#else
+ FREE(hp);
+#endif
status = SWITCH_STATUS_SUCCESS;
} else {
lp = hp;
{
switch_event_header_t *header;
switch_ssize_t hlen = -1;
- void *pop;
+#ifdef SWITCH_EVENT_RECYCLE
+ void *pop;
if (switch_queue_trypop(EVENT_HEADER_RECYCLE_QUEUE, &pop) == SWITCH_STATUS_SUCCESS) {
header = (switch_event_header_t *) pop;
} else {
+#endif
header = ALLOC(sizeof(*header));
switch_assert(header);
+#ifdef SWITCH_EVENT_RECYCLE
}
+#endif
memset(header, 0, sizeof(*header));
hp = hp->next;
FREE(this->name);
FREE(this->value);
- memset(this, 0, sizeof(*this));
+#ifdef SWITCH_EVENT_RECYCLE
if (switch_queue_trypush(EVENT_HEADER_RECYCLE_QUEUE, this) != SWITCH_STATUS_SUCCESS) {
FREE(this);
}
+#else
+ FREE(this);
+#endif
+
+
}
FREE(ep->body);
FREE(ep->subclass_name);
- memset(ep, 0, sizeof(*ep));
+#ifdef SWITCH_EVENT_RECYCLE
if (switch_queue_trypush(EVENT_RECYCLE_QUEUE, ep) != SWITCH_STATUS_SUCCESS) {
FREE(ep);
}
+#else
+ FREE(ep);
+#endif
+
}
*event = NULL;
}
static switch_log_binding_t *BINDINGS = NULL;
static switch_mutex_t *BINDLOCK = NULL;
static switch_queue_t *LOG_QUEUE = NULL;
+#ifdef SWITCH_LOG_RECYCLE
static switch_queue_t *LOG_RECYCLE_QUEUE = NULL;
+#endif
static int8_t THREAD_RUNNING = 0;
static uint8_t MAX_LEVEL = 0;
static int mods_loaded = 0;
switch_mutex_unlock(BINDLOCK);
switch_safe_free(node->data);
+#ifdef SWITCH_LOG_RECYCLE
if (switch_queue_trypush(LOG_RECYCLE_QUEUE, node) != SWITCH_STATUS_SUCCESS) {
free(node);
}
+#else
+ free(node);
+#endif
+
}
THREAD_RUNNING = 0;
if (do_mods && level <= MAX_LEVEL) {
switch_log_node_t *node;
+#ifdef SWITCH_LOG_RECYCLE
void *pop = NULL;
if (switch_queue_trypop(LOG_RECYCLE_QUEUE, &pop) == SWITCH_STATUS_SUCCESS) {
node = (switch_log_node_t *) pop;
} else {
+#endif
node = malloc(sizeof(*node));
switch_assert(node);
+#ifdef SWITCH_LOG_RECYCLE
}
+#endif
node->data = data;
data = NULL;
if (switch_queue_trypush(LOG_QUEUE, node) != SWITCH_STATUS_SUCCESS) {
free(node->data);
+#ifdef SWITCH_LOG_RECYCLE
if (switch_queue_trypush(LOG_RECYCLE_QUEUE, node) != SWITCH_STATUS_SUCCESS) {
free(node);
}
+#else
+ free(node);
+#endif
node = NULL;
}
}
switch_queue_create(&LOG_QUEUE, SWITCH_CORE_QUEUE_LEN, LOG_POOL);
+#ifdef SWITCH_LOG_RECYCLE
switch_queue_create(&LOG_RECYCLE_QUEUE, SWITCH_CORE_QUEUE_LEN, LOG_POOL);
+#endif
switch_mutex_init(&BINDLOCK, SWITCH_MUTEX_NESTED, LOG_POOL);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
switch_thread_create(&thread, thd_attr, log_thread, NULL, LOG_POOL);
SWITCH_DECLARE(void) switch_core_memory_reclaim_logger(void)
{
+#ifdef SWITCH_LOG_RECYCLE
void *pop;
int size = switch_queue_size(LOG_RECYCLE_QUEUE);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CONSOLE, "Returning %d recycled log node(s) %d bytes\n", size,
while (switch_queue_trypop(LOG_RECYCLE_QUEUE, &pop) == SWITCH_STATUS_SUCCESS) {
free(pop);
}
+#else
+ return;
+#endif
+
}
SWITCH_DECLARE(switch_status_t) switch_log_shutdown(void)