From 53e22518eab64ffd178708a2c9abb37efe613954 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 30 Aug 2012 16:15:03 -0500 Subject: [PATCH] FS-4578 try this on dev branch HEAD --- src/mod/endpoints/mod_rtmp/mod_rtmp.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/mod/endpoints/mod_rtmp/mod_rtmp.c b/src/mod/endpoints/mod_rtmp/mod_rtmp.c index 0dd91cbecb..d43ae73d01 100644 --- a/src/mod/endpoints/mod_rtmp/mod_rtmp.c +++ b/src/mod/endpoints/mod_rtmp/mod_rtmp.c @@ -634,7 +634,7 @@ switch_call_cause_t rtmp_outgoing_channel(switch_core_session_t *session, switch switch_core_hash_insert_wrlock(rsession->session_hash, switch_core_session_get_uuid(*newsession), tech_pvt, rsession->session_rwlock); - if (switch_core_session_thread_launch(tech_pvt->session) != SWITCH_STATUS_SUCCESS) { + if (switch_core_session_thread_launch(tech_pvt->session) == SWITCH_STATUS_FALSE) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't spawn thread\n"); goto fail; } @@ -647,7 +647,9 @@ switch_call_cause_t rtmp_outgoing_channel(switch_core_session_t *session, switch fail: if (*newsession) { - switch_core_session_destroy(newsession); + if (!switch_core_session_running(*newsession) && !switch_core_session_started(*newsession)) { + switch_core_session_destroy(newsession); + } } if (rsession) { rtmp_session_rwunlock(rsession); @@ -847,6 +849,7 @@ switch_call_cause_t rtmp_session_create_call(rtmp_session_t *rsession, switch_co return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } + pool = switch_core_session_get_pool(*newsession); channel = switch_core_session_get_channel(*newsession); switch_channel_set_name(channel, switch_core_session_sprintf(*newsession, "rtmp/%s/%s", rsession->profile->name, number)); @@ -911,17 +914,21 @@ switch_call_cause_t rtmp_session_create_call(rtmp_session_t *rsession, switch_co } } - switch_core_hash_insert_wrlock(rsession->session_hash, switch_core_session_get_uuid(*newsession), tech_pvt, rsession->session_rwlock); - - if (switch_core_session_thread_launch(tech_pvt->session) != SWITCH_STATUS_SUCCESS) { + if (switch_core_session_thread_launch(tech_pvt->session) == SWITCH_STATUS_FALSE) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't spawn thread\n"); goto fail; } + switch_core_hash_insert_wrlock(rsession->session_hash, switch_core_session_get_uuid(*newsession), tech_pvt, rsession->session_rwlock); + return SWITCH_CAUSE_SUCCESS; fail: - switch_core_session_destroy(newsession); + + if (!switch_core_session_running(*newsession) && !switch_core_session_started(*newsession)) { + switch_core_session_destroy(newsession); + } + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; }