summaryrefslogtreecommitdiff
path: root/pbx/pbx_lua.c
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2011-05-05 22:49:36 +0000
committerRussell Bryant <russell@russellbryant.com>2011-05-05 22:49:36 +0000
commitea4d4dfabf604f7e6c721144c58b92173d763bdd (patch)
tree682fad39edf29eb79b0ca7ae20a1e7cf773cc164 /pbx/pbx_lua.c
parentf0f5e237bf96ed5531b164935bbe8dca1c7b70ed (diff)
Merged revisions 317476 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.8 ........ r317476 | russell | 2011-05-05 17:47:57 -0500 (Thu, 05 May 2011) | 8 lines 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 ........ git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@317477 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'pbx/pbx_lua.c')
-rw-r--r--pbx/pbx_lua.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/pbx/pbx_lua.c b/pbx/pbx_lua.c
index 24766bfc2..b181b3b78 100644
--- a/pbx/pbx_lua.c
+++ b/pbx/pbx_lua.c
@@ -86,6 +86,7 @@ static void lua_create_autoservice_functions(lua_State *L);
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);
@@ -103,6 +104,7 @@ static struct ast_hashtab *local_table = NULL;
static const struct ast_datastore_info lua_datastore = {
.type = "lua",
.destroy = lua_state_destroy,
+ .chan_fixup = lua_datastore_fixup,
};
@@ -116,6 +118,21 @@ static void lua_state_destroy(void *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");
+}
+
+/*!
* \brief [lua_CFunction] Find an app and return it in a lua table (for access from lua, don't
* call directly)
*