From 09b6b3e4181e826773bc9db1eefe949d86d57131 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Tue, 29 May 2007 20:57:17 +0000 Subject: [PATCH] update git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@5233 d0543943-73ff-0310-b7d9-9358b9ac24b2 --- src/mod/endpoints/mod_wanpipe/mod_wanpipe.c | 1 - src/switch_core_session.c | 12 ++++++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c b/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c index 34a0f49577..657507aaad 100644 --- a/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c +++ b/src/mod/endpoints/mod_wanpipe/mod_wanpipe.c @@ -1568,7 +1568,6 @@ static int on_ring(struct sangoma_pri *spri, sangoma_pri_event_t event_type, pri ret = 0; goto done; } - switch_core_session_thread_launch(session); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Create new Inbound Channel!\n"); } diff --git a/src/switch_core_session.c b/src/switch_core_session.c index 66e92fe699..7dec0c4280 100644 --- a/src/switch_core_session.c +++ b/src/switch_core_session.c @@ -681,6 +681,7 @@ SWITCH_DECLARE(void) switch_core_session_perform_destroy(switch_core_session_t * switch_core_media_bug_remove_all(*session); switch_buffer_destroy(&(*session)->raw_read_buffer); switch_buffer_destroy(&(*session)->raw_write_buffer); + switch_channel_uninit((*session)->channel); pool = (*session)->pool; @@ -721,19 +722,26 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_thread_launch(switch_core_se switch_threadattr_t *thd_attr;; switch_threadattr_create(&thd_attr, session->pool); switch_threadattr_detach_set(thd_attr, 1); + switch_status_t status = SWITCH_STATUS_FALSE; + switch_mutex_lock(session->mutex); + if (!session->thread_running) { + session->thread_running = 1; switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); if (switch_thread_create(&thread, thd_attr, switch_core_session_thread, session, session->pool) == SWITCH_STATUS_SUCCESS) { - return SWITCH_STATUS_SUCCESS; + status = SWITCH_STATUS_SUCCESS; } else { + session->thread_running = 0; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot create thread!\n"); } } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot double-launch thread!\n"); } - return SWITCH_STATUS_FALSE; + switch_mutex_unlock(session->mutex); + + return status; }