-
Notifications
You must be signed in to change notification settings - Fork 1
/
mod_lua.patch
71 lines (65 loc) · 2.78 KB
/
mod_lua.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
modules/lua/mod_lua.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/modules/lua/mod_lua.c b/modules/lua/mod_lua.c
index b73d9cbd03..e2effd9f80 100644
--- a/modules/lua/mod_lua.c
+++ b/modules/lua/mod_lua.c
@@ -41,11 +41,6 @@
#include <unistd.h>
#endif
-/* getpid for Windows */
-#if APR_HAVE_PROCESS_H
-#include <process.h>
-#endif
-
APR_IMPLEMENT_OPTIONAL_HOOK_RUN_ALL(ap_lua, AP_LUA, int, lua_open,
(lua_State *L, apr_pool_t *p),
(L, p), OK, DECLINED)
@@ -120,11 +115,11 @@ static void lua_open_callback(lua_State *L, apr_pool_t *p, void *ctx)
ap_lua_load_apache2_lmodule(L);
ap_lua_load_request_lmodule(L, p);
ap_lua_load_config_lmodule(L);
+ ap_lua_run_lua_open(L, p);
}
static int lua_open_hook(lua_State *L, apr_pool_t *p)
{
- lua_open_callback(L, p, NULL);
return OK;
}
@@ -361,7 +356,9 @@ static apr_status_t lua_setup_filter_ctx(ap_filter_t* f, request_rec* r, lua_fil
if (hook_spec == NULL) {
continue;
}
- if (!strcasecmp(hook_spec->filter_name, f->frec->name)) {
+ if (!strcasecmp(hook_spec->filter_name, f->frec->name) ||
+ (!strncmp(f->frec->name, "BYTYPE:", 7) &&
+ !strcasecmp(hook_spec->filter_name, f->frec->name + 7))) {
spec = create_vm_spec(&pool, r, cfg, server_cfg,
hook_spec->file_name,
NULL,
@@ -489,7 +486,8 @@ static apr_status_t lua_output_filter_handle(ap_filter_t *f, apr_bucket_brigade
lua_setglobal(L, "bucket");
/* If Lua yielded, it means we have something to pass on */
- if (lua_resume(L, 0) == LUA_YIELD) {
+ lua_pushlstring(L, data, len);
+ if (lua_resume(L, 1) == LUA_YIELD) {
size_t olen;
const char* output = lua_tolstring(L, 1, &olen);
if (olen > 0) {
@@ -618,7 +616,8 @@ static apr_status_t lua_input_filter_handle(ap_filter_t *f,
lua_setglobal(L, "bucket");
/* If Lua yielded, it means we have something to pass on */
- if (lua_resume(L, 0) == LUA_YIELD) {
+ lua_pushlstring(L, data, len);
+ if (lua_resume(L, 1) == LUA_YIELD) {
size_t olen;
const char* output = lua_tolstring(L, 1, &olen);
pbktOut = apr_bucket_heap_create(output, olen, 0, c->bucket_alloc);
@@ -649,6 +648,7 @@ static apr_status_t lua_input_filter_handle(ap_filter_t *f,
}
APR_BRIGADE_INSERT_TAIL(pbbOut,pbktEOS);
ap_lua_release_state(L, ctx->spec, r);
+ ap_remove_input_filter(f);
}
}
return APR_SUCCESS;