mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-28 23:15:59 +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;
|
struct ast_channel *chan;
|
||||||
int res;
|
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");
|
lua_getfield(L, LUA_REGISTRYINDEX, "channel");
|
||||||
chan = lua_touserdata(L, -1);
|
chan = lua_touserdata(L, -1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
@@ -687,6 +694,13 @@ static int lua_autoservice_stop(lua_State *L)
|
|||||||
struct ast_channel *chan;
|
struct ast_channel *chan;
|
||||||
int res;
|
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");
|
lua_getfield(L, LUA_REGISTRYINDEX, "channel");
|
||||||
chan = lua_touserdata(L, -1);
|
chan = lua_touserdata(L, -1);
|
||||||
lua_pop(L, 1);
|
lua_pop(L, 1);
|
||||||
@@ -1279,6 +1293,12 @@ static int exec(struct ast_channel *chan, const char *context, const char *exten
|
|||||||
return -1;
|
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_update_registry(L, context, exten, priority);
|
||||||
|
|
||||||
lua_pushstring(L, context);
|
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_pop(L, 1);
|
||||||
}
|
}
|
||||||
lua_remove(L, error_func);
|
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);
|
if (!chan) lua_close(L);
|
||||||
ast_module_user_remove(u);
|
ast_module_user_remove(u);
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
Reference in New Issue
Block a user