simplify switch_core_service_session to protect against a race condition

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10136 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale committed 2008-10-23 23:48:11 +00:00
1 parent e520638b92
commit 42dd42ebb6
7 files changed
+42 -52

No files matched your search

+2 -3
View File
@@ -169,7 +169,6 @@ SWITCH_STANDARD_APP(rss_function)
char *timer_name = NULL;
switch_speech_handle_t sh;
switch_speech_flag_t flags = SWITCH_SPEECH_FLAG_NONE;
switch_core_thread_session_t thread_session;
switch_timer_t timer = { 0 }, *timerp = NULL;
uint32_t last;
char *mydata = NULL;
@@ -293,7 +292,7 @@ SWITCH_STANDARD_APP(rss_function)
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Setup timer success %u bytes per %d ms!\n", (rate / 50) * 2, interval);
/* start a thread to absorb incoming audio */
switch_core_service_session(session, &thread_session, 0);
switch_core_service_session(session);
timerp = &timer;
}
@@ -615,7 +614,7 @@ SWITCH_STANDARD_APP(rss_function)
if (timerp) {
/* End the audio absorbing thread */
switch_core_thread_session_end(&thread_session);
switch_core_thread_session_end(session);
switch_core_timer_destroy(&timer);
}
@@ -5441,22 +5441,18 @@ SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_session_launch_thread(void * jarg
SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_thread_session_end(void * jarg1) {
switch_core_thread_session_t *arg1 = (switch_core_thread_session_t *) 0 ;
switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
arg1 = (switch_core_thread_session_t *)jarg1;
arg1 = (switch_core_session_t *)jarg1;
switch_core_thread_session_end(arg1);
}
SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_service_session(void * jarg1, void * jarg2, int jarg3) {
SWIGEXPORT void SWIGSTDCALL CSharp_switch_core_service_session(void * jarg1) {
switch_core_session_t *arg1 = (switch_core_session_t *) 0 ;
switch_core_thread_session_t *arg2 = (switch_core_thread_session_t *) 0 ;
int arg3 ;
arg1 = (switch_core_session_t *)jarg1;
arg2 = (switch_core_thread_session_t *)jarg2;
arg3 = (int)jarg3;
switch_core_service_session(arg1,arg2,arg3);
switch_core_service_session(arg1);
}
@@ -1262,12 +1262,12 @@ public class freeswitch {
freeswitchPINVOKE.switch_core_session_launch_thread(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_f_p_switch_thread_t_p_void__p_void.getCPtr(func), SWIGTYPE_p_void.getCPtr(obj));
}
public static void switch_core_thread_session_end(switch_core_thread_session thread_session) {
freeswitchPINVOKE.switch_core_thread_session_end(switch_core_thread_session.getCPtr(thread_session));
public static void switch_core_thread_session_end(SWIGTYPE_p_switch_core_session session) {
freeswitchPINVOKE.switch_core_thread_session_end(SWIGTYPE_p_switch_core_session.getCPtr(session));
}
public static void switch_core_service_session(SWIGTYPE_p_switch_core_session session, switch_core_thread_session thread_session, int stream_id) {
freeswitchPINVOKE.switch_core_service_session(SWIGTYPE_p_switch_core_session.getCPtr(session), switch_core_thread_session.getCPtr(thread_session), stream_id);
public static void switch_core_service_session(SWIGTYPE_p_switch_core_session session) {
freeswitchPINVOKE.switch_core_service_session(SWIGTYPE_p_switch_core_session.getCPtr(session));
}
public static switch_call_cause_t switch_core_session_outgoing_channel(SWIGTYPE_p_switch_core_session session, switch_event var_event, string endpoint_name, switch_caller_profile caller_profile, SWIGTYPE_p_p_switch_core_session new_session, SWIGTYPE_p_p_apr_pool_t pool, uint flags) {
@@ -5449,7 +5449,7 @@ class freeswitchPINVOKE {
public static extern void switch_core_thread_session_end(HandleRef jarg1);
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_service_session")]
public static extern void switch_core_service_session(HandleRef jarg1, HandleRef jarg2, int jarg3);
public static extern void switch_core_service_session(HandleRef jarg1);
[DllImport("mod_managed", EntryPoint="CSharp_switch_core_session_outgoing_channel")]
public static extern int switch_core_session_outgoing_channel(HandleRef jarg1, HandleRef jarg2, string jarg3, HandleRef jarg4, HandleRef jarg5, HandleRef jarg6, uint jarg7);
@@ -209,7 +209,6 @@ static JSBool teletone_generate(JSContext * cx, JSObject * obj, uintN argc, jsva
switch_frame_t write_frame = { 0 };
unsigned char *fdata[1024];
switch_frame_t *read_frame;
switch_core_thread_session_t thread_session = { 0 };
switch_channel_t *channel;
if (argc > 1) {
@@ -237,7 +236,7 @@ static JSBool teletone_generate(JSContext * cx, JSObject * obj, uintN argc, jsva
channel = switch_core_session_get_channel(session);
if (tto->timer) {
switch_core_service_session(session, &thread_session, 0);
switch_core_service_session(session);
}
if (loops) {
@@ -291,7 +290,7 @@ static JSBool teletone_generate(JSContext * cx, JSObject * obj, uintN argc, jsva
}
if (tto->timer) {
switch_core_thread_session_end(&thread_session);
switch_core_thread_session_end(session);
}
return JS_TRUE;
}