[asterisk-commits] mnicholson: branch 1.6.2 r317859 - /branches/1.6.2/pbx/pbx_lua.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri May 6 14:34:04 CDT 2011


Author: mnicholson
Date: Fri May  6 14:34:00 2011
New Revision: 317859

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=317859
Log:
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.

Modified:
    branches/1.6.2/pbx/pbx_lua.c

Modified: branches/1.6.2/pbx/pbx_lua.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/pbx/pbx_lua.c?view=diff&rev=317859&r1=317858&r2=317859
==============================================================================
--- branches/1.6.2/pbx/pbx_lua.c (original)
+++ branches/1.6.2/pbx/pbx_lua.c Fri May  6 14:34:00 2011
@@ -656,6 +656,13 @@
 	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);
@@ -686,6 +693,13 @@
 {
 	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);
@@ -1278,7 +1292,13 @@
 		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 @@
 		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;




More information about the asterisk-commits mailing list