[asterisk-commits] mnicholson: branch 1.6.2 r317666 - /branches/1.6.2/pbx/pbx_lua.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Fri May 6 10:18:53 CDT 2011
Author: mnicholson
Date: Fri May 6 10:18:46 2011
New Revision: 317666
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=317666
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.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=317666&r1=317665&r2=317666
==============================================================================
--- branches/1.6.2/pbx/pbx_lua.c (original)
+++ branches/1.6.2/pbx/pbx_lua.c Fri May 6 10:18:46 2011
@@ -85,6 +85,7 @@
static void lua_create_hangup_function(lua_State *L);
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