summaryrefslogtreecommitdiffstats
path: root/modules/lua/lua_request.c
diff options
context:
space:
mode:
authorDaniel Gruno <humbedooh@apache.org>2013-09-27 15:56:53 +0200
committerDaniel Gruno <humbedooh@apache.org>2013-09-27 15:56:53 +0200
commit5a2ba0a3772d6b0e313746734e318a77fa60bf78 (patch)
tree086854805be30944273fbbff4b50aa3f44c5e15e /modules/lua/lua_request.c
parentWinNT MPM: Exit the child if the parent process crashes or is terminated. (diff)
downloadapache2-5a2ba0a3772d6b0e313746734e318a77fa60bf78.tar.xz
apache2-5a2ba0a3772d6b0e313746734e318a77fa60bf78.zip
mod_lua: Use a (new) global pool/mutex setup for IVM rather than a per-process pool.
git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1526906 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'modules/lua/lua_request.c')
-rw-r--r--modules/lua/lua_request.c27
1 files changed, 16 insertions, 11 deletions
diff --git a/modules/lua/lua_request.c b/modules/lua/lua_request.c
index d8e62937d5..74f264315a 100644
--- a/modules/lua/lua_request.c
+++ b/modules/lua/lua_request.c
@@ -30,7 +30,8 @@
#include "util_cookies.h"
#include "apr_want.h"
-extern apr_thread_mutex_t* lua_ivm_mutex;
+extern apr_global_mutex_t* lua_ivm_mutex;
+extern apr_shm_t *lua_ivm_shm;
APLOG_USE_MODULE(lua);
#define POST_MAX_VARS 500
@@ -1831,21 +1832,23 @@ static int req_debug(lua_State *L)
static int lua_ivm_get(lua_State *L)
{
const char *key, *raw_key;
+ apr_pool_t *pool;
lua_ivm_object *object = NULL;
request_rec *r = ap_lua_check_request_rec(L, 1);
key = luaL_checkstring(L, 2);
raw_key = apr_pstrcat(r->pool, "lua_ivm_", key, NULL);
- apr_thread_mutex_lock(lua_ivm_mutex);
- apr_pool_userdata_get((void **)&object, raw_key, r->server->process->pool);
+ apr_global_mutex_lock(lua_ivm_mutex);
+ pool = *((apr_pool_t**) apr_shm_baseaddr_get(lua_ivm_shm));
+ apr_pool_userdata_get((void **)&object, raw_key, pool);
if (object) {
if (object->type == LUA_TBOOLEAN) lua_pushboolean(L, (int) object->number);
else if (object->type == LUA_TNUMBER) lua_pushnumber(L, object->number);
else if (object->type == LUA_TSTRING) lua_pushlstring(L, object->vb.buf, object->size);
- apr_thread_mutex_unlock(lua_ivm_mutex);
+ apr_global_mutex_unlock(lua_ivm_mutex);
return 1;
}
else {
- apr_thread_mutex_unlock(lua_ivm_mutex);
+ apr_global_mutex_unlock(lua_ivm_mutex);
return 0;
}
}
@@ -1855,6 +1858,7 @@ static int lua_ivm_set(lua_State *L)
{
const char *key, *raw_key;
const char *value = NULL;
+ apr_pool_t *pool;
size_t str_len;
lua_ivm_object *object = NULL;
request_rec *r = ap_lua_check_request_rec(L, 1);
@@ -1862,11 +1866,12 @@ static int lua_ivm_set(lua_State *L)
luaL_checkany(L, 3);
raw_key = apr_pstrcat(r->pool, "lua_ivm_", key, NULL);
- apr_thread_mutex_lock(lua_ivm_mutex);
- apr_pool_userdata_get((void **)&object, raw_key, r->server->process->pool);
+ apr_global_mutex_lock(lua_ivm_mutex);
+ pool = *((apr_pool_t**) apr_shm_baseaddr_get(lua_ivm_shm));
+ apr_pool_userdata_get((void **)&object, raw_key, pool);
if (!object) {
- object = apr_pcalloc(r->server->process->pool, sizeof(lua_ivm_object));
- ap_varbuf_init(r->server->process->pool, &object->vb, 2);
+ object = apr_pcalloc(pool, sizeof(lua_ivm_object));
+ ap_varbuf_init(pool, &object->vb, 2);
object->size = 1;
object->vb_size = 1;
}
@@ -1884,8 +1889,8 @@ static int lua_ivm_set(lua_State *L)
memset(object->vb.buf, 0, str_len);
memcpy(object->vb.buf, value, str_len-1);
}
- apr_pool_userdata_set(object, raw_key, NULL, r->server->process->pool);
- apr_thread_mutex_unlock(lua_ivm_mutex);
+ apr_pool_userdata_set(object, raw_key, NULL, pool);
+ apr_global_mutex_unlock(lua_ivm_mutex);
return 0;
}