FS-7567 #resolve #comment additional occurrences beyond the initial patch discovered

This commit is contained in:
Anthony Minessale 2015-05-21 09:50:49 -05:00
parent 38ab8a9b31
commit d413bcd7b3
7 changed files with 22 additions and 17 deletions

View File

@ -60,6 +60,7 @@ SWITCH_BEGIN_EXTERN_C struct switch_unicast_conninfo {
int type; int type;
int transport; int transport;
int stream_id; int stream_id;
switch_thread_t *thread;
}; };
typedef struct switch_unicast_conninfo switch_unicast_conninfo_t; typedef struct switch_unicast_conninfo switch_unicast_conninfo_t;

View File

@ -662,7 +662,6 @@ switch_memory_pool_t *switch_core_memory_init(void)
switch_queue_create(&memory_manager.pool_recycle_queue, 50000, memory_manager.memory_pool); switch_queue_create(&memory_manager.pool_recycle_queue, 50000, memory_manager.memory_pool);
switch_threadattr_create(&thd_attr, memory_manager.memory_pool); switch_threadattr_create(&thd_attr, memory_manager.memory_pool);
switch_threadattr_detach_set(thd_attr, 0);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
switch_thread_create(&pool_thread_p, thd_attr, pool_thread, NULL, memory_manager.memory_pool); switch_thread_create(&pool_thread_p, thd_attr, pool_thread, NULL, memory_manager.memory_pool);

View File

@ -348,14 +348,12 @@ static void *SWITCH_THREAD_FUNC unicast_thread_run(switch_thread_t *thread, void
static void unicast_thread_launch(switch_unicast_conninfo_t *conninfo) static void unicast_thread_launch(switch_unicast_conninfo_t *conninfo)
{ {
switch_thread_t *thread;
switch_threadattr_t *thd_attr = NULL; switch_threadattr_t *thd_attr = NULL;
switch_threadattr_create(&thd_attr, switch_core_session_get_pool(conninfo->session)); switch_threadattr_create(&thd_attr, switch_core_session_get_pool(conninfo->session));
switch_threadattr_detach_set(thd_attr, 1);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
switch_set_flag_locked(conninfo, SUF_THREAD_RUNNING); switch_set_flag_locked(conninfo, SUF_THREAD_RUNNING);
switch_thread_create(&thread, thd_attr, unicast_thread_run, conninfo, switch_core_session_get_pool(conninfo->session)); switch_thread_create(&conninfo->thread, thd_attr, unicast_thread_run, conninfo, switch_core_session_get_pool(conninfo->session));
} }
SWITCH_DECLARE(switch_status_t) switch_ivr_deactivate_unicast(switch_core_session_t *session) SWITCH_DECLARE(switch_status_t) switch_ivr_deactivate_unicast(switch_core_session_t *session)
@ -369,9 +367,13 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_deactivate_unicast(switch_core_sessio
} }
if ((conninfo = switch_channel_get_private(channel, "unicast"))) { if ((conninfo = switch_channel_get_private(channel, "unicast"))) {
switch_status_t st;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Shutting down unicast connection\n"); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "Shutting down unicast connection\n");
switch_clear_flag_locked(conninfo, SUF_READY); switch_clear_flag_locked(conninfo, SUF_READY);
switch_socket_shutdown(conninfo->socket, SWITCH_SHUTDOWN_READWRITE); switch_socket_shutdown(conninfo->socket, SWITCH_SHUTDOWN_READWRITE);
switch_thread_join(&st, conninfo->thread);
while (switch_test_flag(conninfo, SUF_THREAD_RUNNING)) { while (switch_test_flag(conninfo, SUF_THREAD_RUNNING)) {
switch_yield(10000); switch_yield(10000);
if (++sanity >= 10000) { if (++sanity >= 10000) {

View File

@ -4012,6 +4012,7 @@ struct speech_thread_handle {
switch_mutex_t *mutex; switch_mutex_t *mutex;
switch_thread_cond_t *cond; switch_thread_cond_t *cond;
switch_memory_pool_t *pool; switch_memory_pool_t *pool;
switch_thread_t *thread;
int ready; int ready;
}; };
@ -4175,23 +4176,29 @@ static switch_bool_t speech_callback(switch_media_bug_t *bug, void *user_data, s
frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE; frame.buflen = SWITCH_RECOMMENDED_BUFFER_SIZE;
switch (type) { switch (type) {
case SWITCH_ABC_TYPE_INIT:{ case SWITCH_ABC_TYPE_INIT:
switch_thread_t *thread; {
switch_threadattr_t *thd_attr = NULL; switch_threadattr_t *thd_attr = NULL;
switch_threadattr_create(&thd_attr, sth->pool); switch_threadattr_create(&thd_attr, sth->pool);
switch_threadattr_detach_set(thd_attr, 1);
switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
switch_thread_create(&thread, thd_attr, speech_thread, sth, sth->pool); switch_thread_create(&sth->thread, thd_attr, speech_thread, sth, sth->pool);
} }
break; break;
case SWITCH_ABC_TYPE_CLOSE:{ case SWITCH_ABC_TYPE_CLOSE:
{
switch_status_t st;
switch_core_asr_close(sth->ah, &flags); switch_core_asr_close(sth->ah, &flags);
if (sth->mutex && sth->cond && sth->ready) { if (sth->mutex && sth->cond && sth->ready) {
switch_mutex_lock(sth->mutex); if (switch_mutex_trylock(sth->mutex) == SWITCH_STATUS_SUCCESS) {
switch_thread_cond_signal(sth->cond); switch_thread_cond_signal(sth->cond);
switch_mutex_unlock(sth->mutex); switch_mutex_unlock(sth->mutex);
}
} }
switch_thread_join(&st, sth->thread);
} }
break; break;
case SWITCH_ABC_TYPE_READ: case SWITCH_ABC_TYPE_READ:

View File

@ -512,8 +512,6 @@ SWITCH_DECLARE(switch_status_t) switch_log_init(switch_memory_pool_t *pool, swit
LOG_POOL = pool; LOG_POOL = pool;
switch_threadattr_create(&thd_attr, LOG_POOL); switch_threadattr_create(&thd_attr, LOG_POOL);
switch_threadattr_detach_set(thd_attr, 1);
switch_queue_create(&LOG_QUEUE, SWITCH_CORE_QUEUE_LEN, LOG_POOL); switch_queue_create(&LOG_QUEUE, SWITCH_CORE_QUEUE_LEN, LOG_POOL);
#ifdef SWITCH_LOG_RECYCLE #ifdef SWITCH_LOG_RECYCLE

View File

@ -365,7 +365,6 @@ SWITCH_DECLARE(void) switch_nat_thread_start(void)
} }
switch_threadattr_create(&thd_attr, nat_globals_perm.pool); switch_threadattr_create(&thd_attr, nat_globals_perm.pool);
switch_threadattr_detach_set(thd_attr, 1);
switch_thread_create(&nat_thread_p, thd_attr, switch_nat_multicast_runtime, NULL, nat_globals_perm.pool); switch_thread_create(&nat_thread_p, thd_attr, switch_nat_multicast_runtime, NULL, nat_globals_perm.pool);
} }

View File

@ -335,7 +335,6 @@ SWITCH_DECLARE(void) switch_scheduler_task_thread_start(void)
switch_mutex_init(&globals.task_mutex, SWITCH_MUTEX_NESTED, globals.memory_pool); switch_mutex_init(&globals.task_mutex, SWITCH_MUTEX_NESTED, globals.memory_pool);
switch_queue_create(&globals.event_queue, 250000, globals.memory_pool); switch_queue_create(&globals.event_queue, 250000, globals.memory_pool);
switch_threadattr_detach_set(thd_attr, 1);
switch_thread_create(&task_thread_p, thd_attr, switch_scheduler_task_thread, NULL, globals.memory_pool); switch_thread_create(&task_thread_p, thd_attr, switch_scheduler_task_thread, NULL, globals.memory_pool);
} }