[asterisk-commits] russell: branch 1.8 r317476 - /branches/1.8/pbx/pbx_lua.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu May 5 17:48:02 CDT 2011


Author: russell
Date: Thu May  5 17:47:57 2011
New Revision: 317476

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=317476
Log:
Add a datastore fixup to fix a pbx_lua crash.

(closes issue #19055)
Reported by: jamhed
Patches:
      lua_datastore_fixup1.diff uploaded by mnicholson (license 96)
Tested by: mnicholson, jamhed

Modified:
    branches/1.8/pbx/pbx_lua.c

Modified: branches/1.8/pbx/pbx_lua.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/pbx/pbx_lua.c?view=diff&rev=317476&r1=317475&r2=317476
==============================================================================
--- branches/1.8/pbx/pbx_lua.c (original)
+++ branches/1.8/pbx/pbx_lua.c Thu May  5 17:47:57 2011
@@ -85,6 +85,7 @@
 static void lua_create_hangup_function(lua_State *L);
 
 static void lua_state_destroy(void *data);
+static void lua_datastore_fixup(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan);
 static lua_State *lua_get_state(struct ast_channel *chan);
 
 static int exists(struct ast_channel *chan, const char *context, const char *exten, int priority, const char *callerid, const char *data);
@@ -102,6 +103,7 @@
 static const struct ast_datastore_info lua_datastore = {
 	.type = "lua",
 	.destroy = lua_state_destroy,
+	.chan_fixup = lua_datastore_fixup,
 };
 
 
@@ -112,6 +114,21 @@
 {
 	if (data)
 		lua_close(data);
+}
+
+/*!
+ * \brief The fixup function for the lua_datastore.
+ * \param data the datastore data, in this case it will be a lua_State
+ * \param old_chan the channel we are moving from
+ * \param new_chan the channel we are moving to
+ *
+ * This function updates our internal channel pointer.
+ */
+static void lua_datastore_fixup(void *data, struct ast_channel *old_chan, struct ast_channel *new_chan)
+{
+	lua_State *L = data;
+	lua_pushlightuserdata(L, new_chan);
+	lua_setfield(L, LUA_REGISTRYINDEX, "channel");
 }
 
 /*!




More information about the asterisk-commits mailing list