mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-26 06:26:41 +00:00
pbx_lua autoservice fixes
Don't start an autoservice in pbx_lua if pbx_lua already started one and don't stop one if we didn't start one. Also start and stop the autoservice when transferring control from and to the pbx. git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@317858 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -656,6 +656,13 @@ static int lua_autoservice_start(lua_State *L)
|
||||
struct ast_channel *chan;
|
||||
int res;
|
||||
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, "autoservice");
|
||||
if (lua_toboolean(L, -1)) {
|
||||
/* autoservice already running */
|
||||
return 1;
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, "channel");
|
||||
chan = lua_touserdata(L, -1);
|
||||
lua_pop(L, 1);
|
||||
@@ -687,6 +694,13 @@ static int lua_autoservice_stop(lua_State *L)
|
||||
struct ast_channel *chan;
|
||||
int res;
|
||||
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, "autoservice");
|
||||
if (!lua_toboolean(L, -1)) {
|
||||
/* no autoservice running */
|
||||
return 1;
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, "channel");
|
||||
chan = lua_touserdata(L, -1);
|
||||
lua_pop(L, 1);
|
||||
@@ -1278,7 +1292,13 @@ static int exec(struct ast_channel *chan, const char *context, const char *exten
|
||||
ast_module_user_remove(u);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, "autoservice");
|
||||
if (lua_toboolean(L, -1)) {
|
||||
ast_autoservice_start(chan);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
lua_update_registry(L, context, exten, priority);
|
||||
|
||||
lua_pushstring(L, context);
|
||||
@@ -1304,6 +1324,13 @@ static int exec(struct ast_channel *chan, const char *context, const char *exten
|
||||
lua_pop(L, 1);
|
||||
}
|
||||
lua_remove(L, error_func);
|
||||
|
||||
lua_getfield(L, LUA_REGISTRYINDEX, "autoservice");
|
||||
if (lua_toboolean(L, -1)) {
|
||||
ast_autoservice_stop(chan);
|
||||
}
|
||||
lua_pop(L, 1);
|
||||
|
||||
if (!chan) lua_close(L);
|
||||
ast_module_user_remove(u);
|
||||
return res;
|
||||
|
||||
Reference in New Issue
Block a user