mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-18 09:32:34 +00:00
FS-3841 --resolve ok return the string "die" or "exit" from hanguphook to cause an error or call s:destroy("any err message"); either should now halt the script
This commit is contained in:
parent
99b6479947
commit
09ad887948
@ -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();
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
|
@ -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;
|
||||
|
@ -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 ;
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user