]> granicus.if.org Git - apache/commitdiff
Use the right lua scope when used as a hook.
authorRainer Jung <rjung@apache.org>
Fri, 11 Nov 2011 20:51:32 +0000 (20:51 +0000)
committerRainer Jung <rjung@apache.org>
Fri, 11 Nov 2011 20:51:32 +0000 (20:51 +0000)
Backport of r1201042 from trunk.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/2.4.x@1201046 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/lua/mod_lua.c

diff --git a/CHANGES b/CHANGES
index c921965922862b8dbb3a4274e5a5dfc1d99f0bea..5d8467e68cd851282e0902dc919355b2feb3bc73 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
                                                          -*- coding: utf-8 -*-
 Changes with Apache 2.3.16
 
+  *) mod_lua: Use the right lua scope when used as a hook. [Rainer Jung]
+
   *) configure: Only load the really imporant modules (i.e. those enabled by
      the 'few' selection) by default. Don't handle modules enabled with
      --enable-foo specially. [Stefan Fritsch]
index b27006c377dd5da511588d29d0709872e8b5fd85..a248e95d7d8728be9d347cbe50ea17f3c7d2ef77 100644 (file)
@@ -168,6 +168,7 @@ static int lua_handler(request_rec *r)
 static int lua_request_rec_hook_harness(request_rec *r, const char *name, int apr_hook_when)
 {
     int rc;
+    apr_pool_t *pool;
     lua_State *L;
     ap_lua_vm_spec *spec;
     ap_lua_server_cfg *server_cfg = ap_get_module_config(r->server->module_config,
@@ -200,7 +201,31 @@ static int lua_request_rec_hook_harness(request_rec *r, const char *name, int ap
 
             apr_filepath_merge(&spec->file, server_cfg->root_path,
                                spec->file, APR_FILEPATH_NOTRELATIVE, r->pool);
-            L = ap_lua_get_lua_state(r->pool, spec);
+
+            ap_log_rerror(APLOG_MARK, APLOG_DEBUG, 0, r,
+                          "request details scope:%u, filename:%s, function:%s",
+                          spec->scope,
+                          spec->file,
+                          hook_spec->function_name ? hook_spec->function_name : "-");
+
+            switch (spec->scope) {
+            case AP_LUA_SCOPE_ONCE:
+             apr_pool_create(&pool, r->pool);
+              break;
+            case AP_LUA_SCOPE_REQUEST:
+              pool = r->pool;
+              break;
+            case AP_LUA_SCOPE_CONN:
+              pool = r->connection->pool;
+              break;
+            case AP_LUA_SCOPE_THREAD:
+              #if APR_HAS_THREADS
+              pool = apr_thread_pool_get(r->connection->current_thread);
+              break;
+              #endif
+            }
+
+            L = ap_lua_get_lua_state(pool, spec);
 
             if (!L) {
                 ap_log_rerror(APLOG_MARK, APLOG_CRIT, 0, r,