]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
FS-3841 --resolve ok return the string "die" or "exit" from hanguphook to cause an...
authorAnthony Minessale <anthm@freeswitch.org>
Sat, 28 Jan 2012 01:03:04 +0000 (19:03 -0600)
committerAnthony Minessale <anthm@freeswitch.org>
Sat, 28 Jan 2012 01:03:04 +0000 (19:03 -0600)
src/mod/languages/mod_lua/freeswitch.i
src/mod/languages/mod_lua/freeswitch_lua.cpp
src/mod/languages/mod_lua/freeswitch_lua.h
src/mod/languages/mod_lua/mod_lua.cpp
src/mod/languages/mod_lua/mod_lua_wrap.cpp
src/mod/languages/mod_perl/mod_perl_wrap.cpp

index ae2b468c772bad79f42532072e302f6a857ce9e3..a615fcd7420d3005cc459563eb1e47b2b8bb2ae1 100644 (file)
@@ -59,7 +59,7 @@ class Session : public CoreSession {
     Session(char *uuid, CoreSession *a_leg = NULL);
     Session(switch_core_session_t *session);
     ~Session();        
-       virtual void destroy(void);
+       virtual void destroy(const char *err = NULL);
        
        virtual bool begin_allow_threads();
        virtual bool end_allow_threads();
index 0b0a17a225c28f1f3b9ad9c22f4d0376035e89c7..5f21775f8483ca1fbe6c70d5c7d0c6f08a2bbb4c 100644 (file)
@@ -27,7 +27,7 @@ Session::Session(switch_core_session_t *new_session):CoreSession(new_session)
 static switch_status_t lua_hanguphook(switch_core_session_t *session_hungup);
 
 
-void Session::destroy(void)
+void Session::destroy(const char *err)
 {
        
        if (!allocated) {
@@ -48,6 +48,13 @@ void Session::destroy(void)
        switch_safe_free(cb_arg);
 
        CoreSession::destroy();
+
+
+       if (!zstr(err)) {
+               lua_pushstring(L, err);
+               lua_error(L);
+       }
+
 }
 
 
@@ -140,7 +147,23 @@ void Session::do_hangup_hook()
                        arg_count++;
                }
 
-               docall(L, arg_count, 1, 1);
+               docall(L, arg_count, 0, 1);
+
+               const char *err = lua_tostring(L, -1);
+               
+               switch_channel_set_variable(channel, "lua_hangup_hook_return_val", err);
+
+               if (!zstr(err)) {
+
+                       if (!strcasecmp(err, "exit") || !strcasecmp(err, "die")) {
+                               lua_error(L);
+                       } else {
+                               lua_pop(L, 1);
+                       }
+               } else {
+                       lua_pop(L, 1);
+               }
+
 
                if (channel) {
                        switch_channel_set_private(channel, "CoreSession", NULL);
index 6411d696977cfd5535767788ebf69b235b645896..36c0afae5c08cd39e389376078b0e368ed471e43 100644 (file)
@@ -31,7 +31,7 @@ namespace LUA {
                    Session(char *uuid, CoreSession * a_leg = NULL);
                     Session(switch_core_session_t *session);
                                     ~Session();
-                                     SWITCH_MOD_DECLARE(virtual void) destroy(void);
+                                     SWITCH_MOD_DECLARE(virtual void) destroy(const char *err = NULL);
 
                virtual bool begin_allow_threads();
                virtual bool end_allow_threads();
index 825f83c0be9b88b991f90b71ee1a836245081c2a..64f80115864a25035f12b0350033e86fbd4f4a1b 100644 (file)
@@ -101,7 +101,9 @@ int docall(lua_State * L, int narg, int clear, int perror)
                if (!zstr(err)) {
                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s\n", err);
                }
-               lua_pop(L, 1); /* pop error message from the stack */
+               //lua_pop(L, 1); /* pop error message from the stack */
+               // pass error up to top
+               lua_error(L);
        }
 
        return status;
index 5b1a0b65b386bf58056748a744d07955e83b4de8..3019c810833980be19af9feef12adffeb7d11d68 100644 (file)
@@ -6475,7 +6475,34 @@ fail:
 }
 
 
-static int _wrap_Session_destroy(lua_State* L) {
+static int _wrap_Session_destroy__SWIG_0(lua_State* L) {
+  int SWIG_arg = -1;
+  LUA::Session *arg1 = (LUA::Session *) 0 ;
+  char *arg2 = (char *) 0 ;
+  
+  SWIG_check_num_args("destroy",2,2)
+  if(!SWIG_isptrtype(L,1)) SWIG_fail_arg("destroy",1,"LUA::Session *");
+  if(!lua_isstring(L,2)) SWIG_fail_arg("destroy",2,"char const *");
+  
+  if (!SWIG_IsOK(SWIG_ConvertPtr(L,1,(void**)&arg1,SWIGTYPE_p_LUA__Session,0))){
+    SWIG_fail_ptr("Session_destroy",1,SWIGTYPE_p_LUA__Session);
+  }
+  
+  arg2 = (char *)lua_tostring(L, 2);
+  (arg1)->destroy((char const *)arg2);
+  SWIG_arg=0;
+  
+  return SWIG_arg;
+  
+  if(0) SWIG_fail;
+  
+fail:
+  lua_error(L);
+  return SWIG_arg;
+}
+
+
+static int _wrap_Session_destroy__SWIG_1(lua_State* L) {
   int SWIG_arg = -1;
   LUA::Session *arg1 = (LUA::Session *) 0 ;
   
@@ -6499,6 +6526,52 @@ fail:
 }
 
 
+static int _wrap_Session_destroy(lua_State* L) {
+  int argc;
+  int argv[3]={
+    1,2,3
+  };
+  
+  argc = lua_gettop(L);
+  if (argc == 1) {
+    int _v;
+    {
+      void *ptr;
+      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_LUA__Session, 0)) {
+        _v = 0;
+      } else {
+        _v = 1;
+      }
+    }
+    if (_v) {
+      return _wrap_Session_destroy__SWIG_1(L);
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    {
+      void *ptr;
+      if (SWIG_isptrtype(L,argv[0])==0 || SWIG_ConvertPtr(L,argv[0], (void **) &ptr, SWIGTYPE_p_LUA__Session, 0)) {
+        _v = 0;
+      } else {
+        _v = 1;
+      }
+    }
+    if (_v) {
+      {
+        _v = lua_isstring(L,argv[1]);
+      }
+      if (_v) {
+        return _wrap_Session_destroy__SWIG_0(L);
+      }
+    }
+  }
+  
+  lua_pushstring(L,"No matching function for overloaded 'Session_destroy'");
+  lua_error(L);return 0;
+}
+
+
 static int _wrap_Session_begin_allow_threads(lua_State* L) {
   int SWIG_arg = -1;
   LUA::Session *arg1 = (LUA::Session *) 0 ;
index 99c28c3a569920cae1d485921f0d6d1e3aee80cb..a3855445a4e4236ab12cf16af8530b796f517ccf 100644 (file)
@@ -10090,17 +10090,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);