[Freeswitch-svn] [commit] r12730 - in freeswitch/trunk/src: . include mod/languages/mod_lua mod/languages/mod_managed mod/languages/mod_managed/managed mod/languages/mod_perl mod/languages/mod_python

FreeSWITCH SVN anthm at freeswitch.org
Tue Mar 24 08:30:08 PDT 2009


Author: anthm
Date: Tue Mar 24 10:30:08 2009
New Revision: 12730

Log:
fix hanguphook order of operations vs destroy method issue in c++ code 

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

Modified: freeswitch/trunk/src/include/switch_cpp.h
==============================================================================
--- freeswitch/trunk/src/include/switch_cpp.h	(original)
+++ freeswitch/trunk/src/include/switch_cpp.h	Tue Mar 24 10:30:08 2009
@@ -264,7 +264,7 @@
 		 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
 	 * 

Modified: freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.cpp	Tue Mar 24 10:30:08 2009
@@ -21,8 +21,14 @@
 	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 @@
 		}
 		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 @@
 	switch_safe_free(cb_function);
 	switch_safe_free(cb_arg);
 
-	init_vars();
-	
+	CoreSession::destroy();
+}
+
+
+Session::~Session()
+{
+	destroy();
 }
 
 bool Session::begin_allow_threads()

Modified: freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/freeswitch_lua.h	Tue Mar 24 10:30:08 2009
@@ -23,6 +23,7 @@
     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 @@
 	char *hangup_func_str;
 	char *hangup_func_arg;
 	void setLUA(lua_State *state);
+
 };
 }
 #endif

Modified: freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp	(original)
+++ freeswitch/trunk/src/mod/languages/mod_lua/mod_lua_wrap.cpp	Tue Mar 24 10:30:08 2009
@@ -7388,6 +7388,30 @@
 }
 
 
+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 @@
 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}, 

Modified: freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_wrap.cxx
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_wrap.cxx	(original)
+++ freeswitch/trunk/src/mod/languages/mod_managed/freeswitch_wrap.cxx	Tue Mar 24 10:30:08 2009
@@ -1444,6 +1444,17 @@
 }
 
 
+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 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 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;

Modified: freeswitch/trunk/src/mod/languages/mod_managed/managed/swig.cs
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_managed/managed/swig.cs	(original)
+++ freeswitch/trunk/src/mod/languages/mod_managed/managed/swig.cs	Tue Mar 24 10:30:08 2009
@@ -249,7 +249,7 @@
     return ret;
   }
 
-  public void destroy() {
+  public virtual void destroy() {
     freeswitchPINVOKE.CoreSession_destroy(swigCPtr);
   }
 
@@ -3382,6 +3382,10 @@
     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 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 @@
   [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 @@
   [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 @@
   [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 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);

Modified: freeswitch/trunk/src/mod/languages/mod_perl/freeswitch.pm
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_perl/freeswitch.pm	(original)
+++ freeswitch/trunk/src/mod/languages/mod_perl/freeswitch.pm	Tue Mar 24 10:30:08 2009
@@ -478,6 +478,7 @@
     }
 }
 
+*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;

Modified: freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.cpp	(original)
+++ freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.cpp	Tue Mar 24 10:30:08 2009
@@ -44,18 +44,33 @@
 	}
 }
 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()

Modified: freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_perl/freeswitch_perl.h	Tue Mar 24 10:30:08 2009
@@ -31,7 +31,8 @@
     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();

Modified: freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp	(original)
+++ freeswitch/trunk/src/mod/languages/mod_perl/mod_perl_wrap.cpp	Tue Mar 24 10:30:08 2009
@@ -9942,6 +9942,33 @@
 }
 
 
+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 @@
 {"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 @@
   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);

Modified: freeswitch/trunk/src/mod/languages/mod_python/freeswitch.py
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_python/freeswitch.py	(original)
+++ freeswitch/trunk/src/mod/languages/mod_python/freeswitch.py	Tue Mar 24 10:30:08 2009
@@ -324,6 +324,7 @@
     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)

Modified: freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.cpp	(original)
+++ freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.cpp	Tue Mar 24 10:30:08 2009
@@ -21,16 +21,25 @@
 }
 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 @@
 
 	if (Self) {
 		Py_DECREF(Self);
-	}
+	}	
+
+	CoreSession::destroy();
+}
+
+Session::~Session()
+{
+	destroy();
 }
 
 bool Session::begin_allow_threads()

Modified: freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.h
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.h	(original)
+++ freeswitch/trunk/src/mod/languages/mod_python/freeswitch_python.h	Tue Mar 24 10:30:08 2009
@@ -27,6 +27,7 @@
 	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);

Modified: freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp
==============================================================================
--- freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp	(original)
+++ freeswitch/trunk/src/mod/languages/mod_python/mod_python_wrap.cpp	Tue Mar 24 10:30:08 2009
@@ -9442,6 +9442,27 @@
 }
 
 
+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 @@
 	 { (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},

Modified: freeswitch/trunk/src/switch_cpp.cpp
==============================================================================
--- freeswitch/trunk/src/switch_cpp.cpp	(original)
+++ freeswitch/trunk/src/switch_cpp.cpp	Tue Mar 24 10:30:08 2009
@@ -887,6 +887,10 @@
 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_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 @@
 		channel = NULL;
     }
 
-	allocated = 0;
+	init_vars();
 	
 }
 



More information about the Freeswitch-svn mailing list