diff --git a/src/include/switch_cpp.h b/src/include/switch_cpp.h index 75385d643f..3f40272ddd 100644 --- a/src/include/switch_cpp.h +++ b/src/include/switch_cpp.h @@ -264,7 +264,7 @@ SWITCH_DECLARE(void) consoleCleanLog(char *msg); SWITCH_DECLARE(int) originate(CoreSession * a_leg_session, char *dest, int timeout = 60); - SWITCH_DECLARE(void) destroy(void); + SWITCH_DECLARE(virtual void) destroy(void); /** \brief set a DTMF callback function * diff --git a/src/mod/languages/mod_lua/freeswitch_lua.cpp b/src/mod/languages/mod_lua/freeswitch_lua.cpp index 640cfda0b1..145ffdb151 100644 --- a/src/mod/languages/mod_lua/freeswitch_lua.cpp +++ b/src/mod/languages/mod_lua/freeswitch_lua.cpp @@ -21,8 +21,14 @@ Session::Session(switch_core_session_t *new_session):CoreSession(new_session) hh = mark = 0; } static switch_status_t lua_hanguphook(switch_core_session_t *session_hungup); -Session::~Session() + + +void Session::destroy(void) { + + if (!allocated) { + return; + } if (session) { if (!channel) { @@ -30,8 +36,6 @@ Session::~Session() } switch_channel_set_private(channel, "CoreSession", NULL); switch_core_event_hook_remove_state_change(session, lua_hanguphook); - session = NULL; - channel = NULL; } switch_safe_free(hangup_func_str); @@ -39,8 +43,13 @@ Session::~Session() switch_safe_free(cb_function); switch_safe_free(cb_arg); - init_vars(); - + CoreSession::destroy(); +} + + +Session::~Session() +{ + destroy(); } bool Session::begin_allow_threads() diff --git a/src/mod/languages/mod_lua/freeswitch_lua.h b/src/mod/languages/mod_lua/freeswitch_lua.h index b992bd62a8..550e756c84 100644 --- a/src/mod/languages/mod_lua/freeswitch_lua.h +++ b/src/mod/languages/mod_lua/freeswitch_lua.h @@ -23,6 +23,7 @@ class Session : public CoreSession { Session(char *uuid, CoreSession *a_leg = NULL); Session(switch_core_session_t *session); ~Session(); + virtual void destroy(void); virtual bool begin_allow_threads(); virtual bool end_allow_threads(); @@ -40,6 +41,7 @@ class Session : public CoreSession { char *hangup_func_str; char *hangup_func_arg; void setLUA(lua_State *state); + }; } #endif diff --git a/src/mod/languages/mod_lua/mod_lua_wrap.cpp b/src/mod/languages/mod_lua/mod_lua_wrap.cpp index bcb343f2ae..2913d554b3 100644 --- a/src/mod/languages/mod_lua/mod_lua_wrap.cpp +++ b/src/mod/languages/mod_lua/mod_lua_wrap.cpp @@ -7388,6 +7388,30 @@ fail: } +static int _wrap_Session_destroy(lua_State* L) { + int SWIG_arg = -1; + LUA::Session *arg1 = (LUA::Session *) 0 ; + + SWIG_check_num_args("destroy",1,1) + if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("destroy",1,"LUA::Session *"); + + if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Session,0))){ + SWIG_fail_ptr("Session_destroy",1,SWIGTYPE_p_LUA__Session); + } + + (arg1)->destroy(); + SWIG_arg=0; + + return SWIG_arg; + + if(0) SWIG_fail; + +fail: + lua_error(L); + return SWIG_arg; +} + + static int _wrap_Session_begin_allow_threads(lua_State* L) { int SWIG_arg = -1; LUA::Session *arg1 = (LUA::Session *) 0 ; @@ -8086,6 +8110,7 @@ LUA::Session *arg1 = (LUA::Session *) obj; delete arg1; } static swig_lua_method swig_LUA_Session_methods[] = { + {"destroy", _wrap_Session_destroy}, {"begin_allow_threads", _wrap_Session_begin_allow_threads}, {"end_allow_threads", _wrap_Session_end_allow_threads}, {"check_hangup_hook", _wrap_Session_check_hangup_hook}, diff --git a/src/mod/languages/mod_managed/freeswitch_wrap.cxx b/src/mod/languages/mod_managed/freeswitch_wrap.cxx index cc303b9d3a..7b65f40042 100644 --- a/src/mod/languages/mod_managed/freeswitch_wrap.cxx +++ b/src/mod/languages/mod_managed/freeswitch_wrap.cxx @@ -1444,6 +1444,17 @@ SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_PARK_AFTER_BRIDGE_VARIABLE_get() { } +SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE_get() { + char * jresult ; + char *result = 0 ; + + result = (char *) "transfer_after_bridge"; + + jresult = SWIG_csharp_string_callback((const char *)result); + return jresult; +} + + SWIGEXPORT char * SWIGSTDCALL CSharp_SWITCH_EXEC_AFTER_BRIDGE_APP_VARIABLE_get() { char * jresult ; char *result = 0 ; @@ -13113,6 +13124,64 @@ SWIGEXPORT unsigned long SWIGSTDCALL CSharp_switch_file_handle_offset_pos_get(vo } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_samples_in_set(void * jarg1, void * jarg2) { + switch_file_handle *arg1 = (switch_file_handle *) 0 ; + switch_size_t arg2 ; + switch_size_t *argp2 ; + + arg1 = (switch_file_handle *)jarg1; + argp2 = (switch_size_t *)jarg2; + if (!argp2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_size_t", 0); + return ; + } + arg2 = *argp2; + if (arg1) (arg1)->samples_in = arg2; + +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_file_handle_samples_in_get(void * jarg1) { + void * jresult ; + switch_file_handle *arg1 = (switch_file_handle *) 0 ; + switch_size_t result; + + arg1 = (switch_file_handle *)jarg1; + result = ((arg1)->samples_in); + jresult = new switch_size_t((switch_size_t &)result); + return jresult; +} + + +SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_samples_out_set(void * jarg1, void * jarg2) { + switch_file_handle *arg1 = (switch_file_handle *) 0 ; + switch_size_t arg2 ; + switch_size_t *argp2 ; + + arg1 = (switch_file_handle *)jarg1; + argp2 = (switch_size_t *)jarg2; + if (!argp2) { + SWIG_CSharpSetPendingExceptionArgument(SWIG_CSharpArgumentNullException, "Attempt to dereference null switch_size_t", 0); + return ; + } + arg2 = *argp2; + if (arg1) (arg1)->samples_out = arg2; + +} + + +SWIGEXPORT void * SWIGSTDCALL CSharp_switch_file_handle_samples_out_get(void * jarg1) { + void * jresult ; + switch_file_handle *arg1 = (switch_file_handle *) 0 ; + switch_size_t result; + + arg1 = (switch_file_handle *)jarg1; + result = ((arg1)->samples_out); + jresult = new switch_size_t((switch_size_t &)result); + return jresult; +} + + SWIGEXPORT void SWIGSTDCALL CSharp_switch_file_handle_vol_set(void * jarg1, int jarg2) { switch_file_handle *arg1 = (switch_file_handle *) 0 ; int32_t arg2 ; @@ -22245,6 +22314,18 @@ SWIGEXPORT int SWIGSTDCALL CSharp_switch_ivr_sound_test(void * jarg1) { } +SWIGEXPORT void SWIGSTDCALL CSharp_switch_process_import(void * jarg1, void * jarg2, char * jarg3) { + switch_core_session_t *arg1 = (switch_core_session_t *) 0 ; + switch_channel_t *arg2 = (switch_channel_t *) 0 ; + char *arg3 = (char *) 0 ; + + arg1 = (switch_core_session_t *)jarg1; + arg2 = (switch_channel_t *)jarg2; + arg3 = (char *)jarg3; + switch_process_import(arg1,arg2,(char const *)arg3); +} + + SWIGEXPORT int SWIGSTDCALL CSharp_SWITCH_RTP_MAX_BUF_LEN_get() { int jresult ; int result; diff --git a/src/mod/languages/mod_managed/managed/swig.cs b/src/mod/languages/mod_managed/managed/swig.cs index e25ea8a032..1e8958c4ff 100644 --- a/src/mod/languages/mod_managed/managed/swig.cs +++ b/src/mod/languages/mod_managed/managed/swig.cs @@ -249,7 +249,7 @@ public class CoreSession : IDisposable { return ret; } - public void destroy() { + public virtual void destroy() { freeswitchPINVOKE.CoreSession_destroy(swigCPtr); } @@ -3382,6 +3382,10 @@ public class freeswitch { return ret; } + public static void switch_process_import(SWIGTYPE_p_switch_core_session session, SWIGTYPE_p_switch_channel peer_channel, string varname) { + freeswitchPINVOKE.switch_process_import(SWIGTYPE_p_switch_core_session.getCPtr(session), SWIGTYPE_p_switch_channel.getCPtr(peer_channel), varname); + } + public static switch_status_t switch_rtp_add_crypto_key(SWIGTYPE_p_switch_rtp rtp_session, switch_rtp_crypto_direction_t direction, uint index, switch_rtp_crypto_key_type_t type, SWIGTYPE_p_unsigned_char key, SWIGTYPE_p_switch_size_t keylen) { switch_status_t ret = (switch_status_t)freeswitchPINVOKE.switch_rtp_add_crypto_key(SWIGTYPE_p_switch_rtp.getCPtr(rtp_session), (int)direction, index, (int)type, SWIGTYPE_p_unsigned_char.getCPtr(key), SWIGTYPE_p_switch_size_t.getCPtr(keylen)); if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); @@ -4181,6 +4185,7 @@ public class freeswitch { public static readonly string SWITCH_LOCAL_VIDEO_PORT_VARIABLE = freeswitchPINVOKE.SWITCH_LOCAL_VIDEO_PORT_VARIABLE_get(); public static readonly string SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE = freeswitchPINVOKE.SWITCH_HANGUP_AFTER_BRIDGE_VARIABLE_get(); public static readonly string SWITCH_PARK_AFTER_BRIDGE_VARIABLE = freeswitchPINVOKE.SWITCH_PARK_AFTER_BRIDGE_VARIABLE_get(); + public static readonly string SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE = freeswitchPINVOKE.SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE_get(); public static readonly string SWITCH_EXEC_AFTER_BRIDGE_APP_VARIABLE = freeswitchPINVOKE.SWITCH_EXEC_AFTER_BRIDGE_APP_VARIABLE_get(); public static readonly string SWITCH_EXEC_AFTER_BRIDGE_ARG_VARIABLE = freeswitchPINVOKE.SWITCH_EXEC_AFTER_BRIDGE_ARG_VARIABLE_get(); public static readonly string SWITCH_MAX_FORWARDS_VARIABLE = freeswitchPINVOKE.SWITCH_MAX_FORWARDS_VARIABLE_get(); @@ -4754,6 +4759,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_PARK_AFTER_BRIDGE_VARIABLE_get")] public static extern string SWITCH_PARK_AFTER_BRIDGE_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE_get")] + public static extern string SWITCH_TRANSFER_AFTER_BRIDGE_VARIABLE_get(); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_EXEC_AFTER_BRIDGE_APP_VARIABLE_get")] public static extern string SWITCH_EXEC_AFTER_BRIDGE_APP_VARIABLE_get(); @@ -7520,6 +7528,18 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_offset_pos_get")] public static extern uint switch_file_handle_offset_pos_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_samples_in_set")] + public static extern void switch_file_handle_samples_in_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_samples_in_get")] + public static extern IntPtr switch_file_handle_samples_in_get(HandleRef jarg1); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_samples_out_set")] + public static extern void switch_file_handle_samples_out_set(HandleRef jarg1, HandleRef jarg2); + + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_samples_out_get")] + public static extern IntPtr switch_file_handle_samples_out_get(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_file_handle_vol_set")] public static extern void switch_file_handle_vol_set(HandleRef jarg1, int jarg2); @@ -9632,6 +9652,9 @@ class freeswitchPINVOKE { [DllImport("mod_managed", EntryPoint="CSharp_switch_ivr_sound_test")] public static extern int switch_ivr_sound_test(HandleRef jarg1); + [DllImport("mod_managed", EntryPoint="CSharp_switch_process_import")] + public static extern void switch_process_import(HandleRef jarg1, HandleRef jarg2, string jarg3); + [DllImport("mod_managed", EntryPoint="CSharp_SWITCH_RTP_MAX_BUF_LEN_get")] public static extern int SWITCH_RTP_MAX_BUF_LEN_get(); @@ -20488,6 +20511,30 @@ public class switch_file_handle : IDisposable { } } + public SWIGTYPE_p_switch_size_t samples_in { + set { + freeswitchPINVOKE.switch_file_handle_samples_in_set(swigCPtr, SWIGTYPE_p_switch_size_t.getCPtr(value)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + } + get { + SWIGTYPE_p_switch_size_t ret = new SWIGTYPE_p_switch_size_t(freeswitchPINVOKE.switch_file_handle_samples_in_get(swigCPtr), true); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } + + public SWIGTYPE_p_switch_size_t samples_out { + set { + freeswitchPINVOKE.switch_file_handle_samples_out_set(swigCPtr, SWIGTYPE_p_switch_size_t.getCPtr(value)); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + } + get { + SWIGTYPE_p_switch_size_t ret = new SWIGTYPE_p_switch_size_t(freeswitchPINVOKE.switch_file_handle_samples_out_get(swigCPtr), true); + if (freeswitchPINVOKE.SWIGPendingException.Pending) throw freeswitchPINVOKE.SWIGPendingException.Retrieve(); + return ret; + } + } + public int vol { set { freeswitchPINVOKE.switch_file_handle_vol_set(swigCPtr, value); diff --git a/src/mod/languages/mod_perl/freeswitch.pm b/src/mod/languages/mod_perl/freeswitch.pm index c98854a9a5..2f527812eb 100644 --- a/src/mod/languages/mod_perl/freeswitch.pm +++ b/src/mod/languages/mod_perl/freeswitch.pm @@ -478,6 +478,7 @@ sub DESTROY { } } +*destroy = *freeswitchc::Session_destroy; *begin_allow_threads = *freeswitchc::Session_begin_allow_threads; *end_allow_threads = *freeswitchc::Session_end_allow_threads; *check_hangup_hook = *freeswitchc::Session_check_hangup_hook; diff --git a/src/mod/languages/mod_perl/freeswitch_perl.cpp b/src/mod/languages/mod_perl/freeswitch_perl.cpp index 7ec2e089d7..84b206325f 100644 --- a/src/mod/languages/mod_perl/freeswitch_perl.cpp +++ b/src/mod/languages/mod_perl/freeswitch_perl.cpp @@ -44,18 +44,33 @@ Session::Session(switch_core_session_t *new_session):CoreSession(new_session) } } static switch_status_t perl_hanguphook(switch_core_session_t *session_hungup); -Session::~Session() -{ - switch_safe_free(cb_function); - switch_safe_free(cb_arg); - if (session && hangup_func_str) { +void Session::destroy(void) +{ + + if (!allocated) { + return; + } + + if (session) { + if (!channel) { + channel = switch_core_session_get_channel(session); + } + switch_channel_set_private(channel, "CoreSession", NULL); switch_core_event_hook_remove_state_change(session, perl_hanguphook); } + switch_safe_free(cb_function); + switch_safe_free(cb_arg); switch_safe_free(hangup_func_str); - switch_safe_free(hangup_func_arg); + switch_safe_free(hangup_func_arg); + CoreSession::destroy(); +} + +Session::~Session() +{ + destroy(); } bool Session::begin_allow_threads() diff --git a/src/mod/languages/mod_perl/freeswitch_perl.h b/src/mod/languages/mod_perl/freeswitch_perl.h index 50f2fabfa5..fc3dddbc60 100644 --- a/src/mod/languages/mod_perl/freeswitch_perl.h +++ b/src/mod/languages/mod_perl/freeswitch_perl.h @@ -31,7 +31,8 @@ class Session : public CoreSession { Session(char *uuid, CoreSession *a_leg = NULL); Session(switch_core_session_t *session); ~Session(); - + + virtual void destroy(void); virtual bool begin_allow_threads(); virtual bool end_allow_threads(); virtual void check_hangup_hook(); diff --git a/src/mod/languages/mod_perl/mod_perl_wrap.cpp b/src/mod/languages/mod_perl/mod_perl_wrap.cpp index ca0cde95d8..302180141b 100644 --- a/src/mod/languages/mod_perl/mod_perl_wrap.cpp +++ b/src/mod/languages/mod_perl/mod_perl_wrap.cpp @@ -9942,6 +9942,33 @@ XS(_wrap_delete_Session) { } +XS(_wrap_Session_destroy) { + { + PERL::Session *arg1 = (PERL::Session *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + int argvi = 0; + dXSARGS; + + if ((items < 1) || (items > 1)) { + SWIG_croak("Usage: Session_destroy(self);"); + } + res1 = SWIG_ConvertPtr(ST(0), &argp1,SWIGTYPE_p_PERL__Session, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Session_destroy" "', argument " "1"" of type '" "PERL::Session *""'"); + } + arg1 = reinterpret_cast< PERL::Session * >(argp1); + (arg1)->destroy(); + + + XSRETURN(argvi); + fail: + + SWIG_croak_null(); + } +} + + XS(_wrap_Session_begin_allow_threads) { { PERL::Session *arg1 = (PERL::Session *) 0 ; @@ -11217,6 +11244,7 @@ static swig_command_info swig_commands[] = { {"freeswitchc::dtmf_callback", _wrap_dtmf_callback}, {"freeswitchc::new_Session", _wrap_new_Session}, {"freeswitchc::delete_Session", _wrap_delete_Session}, +{"freeswitchc::Session_destroy", _wrap_Session_destroy}, {"freeswitchc::Session_begin_allow_threads", _wrap_Session_begin_allow_threads}, {"freeswitchc::Session_end_allow_threads", _wrap_Session_end_allow_threads}, {"freeswitchc::Session_check_hangup_hook", _wrap_Session_check_hangup_hook}, @@ -11534,17 +11562,17 @@ XS(SWIG_init) { SWIG_TypeClientData(SWIGTYPE_p_IVRMenu, (void*) "freeswitch::IVRMenu"); SWIG_TypeClientData(SWIGTYPE_p_API, (void*) "freeswitch::API"); SWIG_TypeClientData(SWIGTYPE_p_input_callback_state, (void*) "freeswitch::input_callback_state_t"); - /*@SWIG:/usr/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do { + /*@SWIG:/usr/local/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do { SV *sv = get_sv((char*) SWIG_prefix "S_HUP", TRUE | 0x2 | GV_ADDMULTI); sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(S_HUP))); SvREADONLY_on(sv); } while(0) /*@SWIG@*/; - /*@SWIG:/usr/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do { + /*@SWIG:/usr/local/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do { SV *sv = get_sv((char*) SWIG_prefix "S_FREE", TRUE | 0x2 | GV_ADDMULTI); sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(S_FREE))); SvREADONLY_on(sv); } while(0) /*@SWIG@*/; - /*@SWIG:/usr/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do { + /*@SWIG:/usr/local/share/swig/1.3.35/perl5/perltypemaps.swg,64,%set_constant@*/ do { SV *sv = get_sv((char*) SWIG_prefix "S_RDLOCK", TRUE | 0x2 | GV_ADDMULTI); sv_setsv(sv, SWIG_From_int SWIG_PERL_CALL_ARGS_1(static_cast< int >(S_RDLOCK))); SvREADONLY_on(sv); diff --git a/src/mod/languages/mod_python/freeswitch.py b/src/mod/languages/mod_python/freeswitch.py index 5017279876..329ee8d7dd 100644 --- a/src/mod/languages/mod_python/freeswitch.py +++ b/src/mod/languages/mod_python/freeswitch.py @@ -324,6 +324,7 @@ class Session(CoreSession): def begin_allow_threads(*args): return _freeswitch.Session_begin_allow_threads(*args) def end_allow_threads(*args): return _freeswitch.Session_end_allow_threads(*args) def check_hangup_hook(*args): return _freeswitch.Session_check_hangup_hook(*args) + def destroy(*args): return _freeswitch.Session_destroy(*args) def run_dtmf_callback(*args): return _freeswitch.Session_run_dtmf_callback(*args) def setInputCallback(*args): return _freeswitch.Session_setInputCallback(*args) def unsetInputCallback(*args): return _freeswitch.Session_unsetInputCallback(*args) diff --git a/src/mod/languages/mod_python/freeswitch_python.cpp b/src/mod/languages/mod_python/freeswitch_python.cpp index f10872e4d7..fa1b606724 100644 --- a/src/mod/languages/mod_python/freeswitch_python.cpp +++ b/src/mod/languages/mod_python/freeswitch_python.cpp @@ -21,16 +21,25 @@ Session::Session(switch_core_session_t *new_session):CoreSession(new_session) } static switch_status_t python_hanguphook(switch_core_session_t *session_hungup); -Session::~Session() +void Session::destroy(void) { - if (hangup_func) { - if (session) { - switch_core_event_hook_remove_state_change(session, python_hanguphook); - } - Py_DECREF(hangup_func); - hangup_func = NULL; + if (!allocated) { + return; } + + if (session) { + if (!channel) { + channel = switch_core_session_get_channel(session); + } + switch_channel_set_private(channel, "CoreSession", NULL); + switch_core_event_hook_remove_state_change(session, python_hanguphook); + } + + if (hangup_func) { + Py_DECREF(hangup_func); + hangup_func = NULL; + } if (hangup_func_arg) { Py_DECREF(hangup_func_arg); @@ -49,7 +58,14 @@ Session::~Session() if (Self) { Py_DECREF(Self); - } + } + + CoreSession::destroy(); +} + +Session::~Session() +{ + destroy(); } bool Session::begin_allow_threads() diff --git a/src/mod/languages/mod_python/freeswitch_python.h b/src/mod/languages/mod_python/freeswitch_python.h index b7a5c9cf0e..58c2393e5f 100644 --- a/src/mod/languages/mod_python/freeswitch_python.h +++ b/src/mod/languages/mod_python/freeswitch_python.h @@ -27,6 +27,7 @@ class Session : public CoreSession { virtual bool begin_allow_threads(); virtual bool end_allow_threads(); virtual void check_hangup_hook(); + virtual void destroy(void); virtual switch_status_t run_dtmf_callback(void *input, switch_input_type_t itype); void setInputCallback(PyObject *cbfunc, PyObject *funcargs = NULL); diff --git a/src/mod/languages/mod_python/mod_python_wrap.cpp b/src/mod/languages/mod_python/mod_python_wrap.cpp index b195aee461..eef503bedc 100644 --- a/src/mod/languages/mod_python/mod_python_wrap.cpp +++ b/src/mod/languages/mod_python/mod_python_wrap.cpp @@ -9442,6 +9442,27 @@ fail: } +SWIGINTERN PyObject *_wrap_Session_destroy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { + PyObject *resultobj = 0; + PYTHON::Session *arg1 = (PYTHON::Session *) 0 ; + void *argp1 = 0 ; + int res1 = 0 ; + PyObject * obj0 = 0 ; + + if (!PyArg_ParseTuple(args,(char *)"O:Session_destroy",&obj0)) SWIG_fail; + res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_PYTHON__Session, 0 | 0 ); + if (!SWIG_IsOK(res1)) { + SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Session_destroy" "', argument " "1"" of type '" "PYTHON::Session *""'"); + } + arg1 = reinterpret_cast< PYTHON::Session * >(argp1); + (arg1)->destroy(); + resultobj = SWIG_Py_Void(); + return resultobj; +fail: + return NULL; +} + + SWIGINTERN PyObject *_wrap_Session_run_dtmf_callback(PyObject *SWIGUNUSEDPARM(self), PyObject *args) { PyObject *resultobj = 0; PYTHON::Session *arg1 = (PYTHON::Session *) 0 ; @@ -10114,6 +10135,7 @@ static PyMethodDef SwigMethods[] = { { (char *)"Session_begin_allow_threads", _wrap_Session_begin_allow_threads, METH_VARARGS, NULL}, { (char *)"Session_end_allow_threads", _wrap_Session_end_allow_threads, METH_VARARGS, NULL}, { (char *)"Session_check_hangup_hook", _wrap_Session_check_hangup_hook, METH_VARARGS, NULL}, + { (char *)"Session_destroy", _wrap_Session_destroy, METH_VARARGS, NULL}, { (char *)"Session_run_dtmf_callback", _wrap_Session_run_dtmf_callback, METH_VARARGS, NULL}, { (char *)"Session_setInputCallback", _wrap_Session_setInputCallback, METH_VARARGS, NULL}, { (char *)"Session_unsetInputCallback", _wrap_Session_unsetInputCallback, METH_VARARGS, NULL}, diff --git a/src/switch_cpp.cpp b/src/switch_cpp.cpp index cc5d8116ee..406bcb0a26 100644 --- a/src/switch_cpp.cpp +++ b/src/switch_cpp.cpp @@ -887,6 +887,10 @@ SWITCH_DECLARE(bool) CoreSession::answered() { SWITCH_DECLARE(void) CoreSession::destroy(void) { this_check_void(); + + if (!allocated) { + return; + } switch_safe_free(xml_cdr_text); switch_safe_free(uuid); @@ -903,7 +907,7 @@ SWITCH_DECLARE(void) CoreSession::destroy(void) } switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "destroy/unlink session from object\n"); - + if (switch_channel_up(channel) && switch_test_flag(this, S_HUP) && !switch_channel_test_flag(channel, CF_TRANSFER)) { switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); } @@ -912,7 +916,7 @@ SWITCH_DECLARE(void) CoreSession::destroy(void) channel = NULL; } - allocated = 0; + init_vars(); }