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;
}
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);
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));
}
}
- 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;
}