]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
fix hanguphook order of operations vs destroy method issue in c++ code
authorAnthony Minessale <anthony.minessale@gmail.com>
Tue, 24 Mar 2009 15:30:08 +0000 (15:30 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Tue, 24 Mar 2009 15:30:08 +0000 (15:30 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12730 d0543943-73ff-0310-b7d9-9358b9ac24b2

15 files changed:
src/include/switch_cpp.h
src/mod/languages/mod_lua/freeswitch_lua.cpp
src/mod/languages/mod_lua/freeswitch_lua.h
src/mod/languages/mod_lua/mod_lua_wrap.cpp
src/mod/languages/mod_managed/freeswitch_wrap.cxx
src/mod/languages/mod_managed/managed/swig.cs
src/mod/languages/mod_perl/freeswitch.pm
src/mod/languages/mod_perl/freeswitch_perl.cpp
src/mod/languages/mod_perl/freeswitch_perl.h
src/mod/languages/mod_perl/mod_perl_wrap.cpp
src/mod/languages/mod_python/freeswitch.py
src/mod/languages/mod_python/freeswitch_python.cpp
src/mod/languages/mod_python/freeswitch_python.h
src/mod/languages/mod_python/mod_python_wrap.cpp
src/switch_cpp.cpp

index 75385d643fa7cf8e22d224b9a072a3d9e6c33ccc..3f40272ddd8225b977795266cd7d9744041b45cc 100644 (file)
@@ -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
         * 
index 640cfda0b1425858a62b9fcd0b772749c084d44e..145ffdb151d1432932c4aa14cd018166d714a223 100644 (file)
@@ -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()
index b992bd62a8a2cbc2792c7aeeb189b3f32b6bf1bd..550e756c844398ae6914013253e8c7281adcd432 100644 (file)
@@ -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
index bcb343f2ae284c7320e697d9726d59a978b8a8e0..2913d554b3d255893768a344a683a25794172c11 100644 (file)
@@ -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}, 
index cc303b9d3a814436d827b051f9109ee139ed7ce0..7b65f400426b5e7bb5f8facaeb9de5e3662def65 100644 (file)
@@ -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;
index e25ea8a032b31ece5f1ad25596b39b4f74e8f08c..1e8958c4ff74865baa1dfe33f8cf591046078ca8 100644 (file)
@@ -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);
index c98854a9a58e2932d55883ea011152a2b7f1c236..2f527812eb60a73c229bc42134d1c1d2d088989d 100644 (file)
@@ -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;
index 7ec2e089d7f979951c1230a4555b97ae5373515f..84b206325f00ee05f7d5d2f84fb01f48f4da22c6 100644 (file)
@@ -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()
+
+void Session::destroy(void)
 {
-       switch_safe_free(cb_function);
-       switch_safe_free(cb_arg);
+       
+       if (!allocated) {
+               return;
+       }
 
-       if (session && hangup_func_str) {
+       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()
index 50f2fabfa54921b9c7ba5b4fd6c15d085de83517..fc3dddbc60a66d2dd521aac821719f7d04a30b00 100644 (file)
@@ -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();
index ca0cde95d8861e2bf1c65691ea5878bc1d1d12c3..302180141bb645fecbcf9022d40b3e4db872f60e 100644 (file)
@@ -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);
index 5017279876e4842b07079d3920b722a3e8f22da4..329ee8d7dd64f5065c382982cef8f0fd2ac54708 100644 (file)
@@ -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)
index f10872e4d7cb83eb9d1165ba0068812a9fd724c9..fa1b606724487a1199e2aabb44e5137b598b29a9 100644 (file)
@@ -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);
+       if (!allocated) {
+               return;
+       }
+
+       if (session) {
+               if (!channel) {
+                       channel = switch_core_session_get_channel(session);
                }
-               Py_DECREF(hangup_func);
-               hangup_func = NULL;
+               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()
index b7a5c9cf0eb11b393db062bd9e4846b36a2fc9e7..58c2393e5fee562cafde5cf3d5df12dc1fecec82 100644 (file)
@@ -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);
index b195aee461f22ed7ab4fb85a26f7bd02a888dd42..eef503bedc90b7258b5b1607286067620eb4b598 100644 (file)
@@ -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},
index cc5d8116ee8c934dc6fc01b657c293104bb503f6..406bcb0a267c886f26e369de05da25ba08752e63 100644 (file)
@@ -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();
        
 }