Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/ngx_http_lua_accessby.c
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,10 @@ ngx_http_lua_access_handler_inline(ngx_http_request_t *r)

L = ngx_http_lua_get_lua_vm(r, NULL);

if (!llcf->enable_code_cache) {
llcf->access_src_ref = LUA_REFNIL;
}

/* load Lua inline script (w/ cache) sp = 1 */
rc = ngx_http_lua_cache_loadbuffer(r->connection->log, L,
llcf->access_src.value.data,
Expand Down Expand Up @@ -214,6 +218,10 @@ ngx_http_lua_access_handler_file(ngx_http_request_t *r)

L = ngx_http_lua_get_lua_vm(r, NULL);

if (!llcf->enable_code_cache) {
llcf->access_src_ref = LUA_REFNIL;
}

/* load Lua script file (w/ cache) sp = 1 */
rc = ngx_http_lua_cache_loadfile(r->connection->log, L, script_path,
&llcf->access_src_ref,
Expand Down
8 changes: 8 additions & 0 deletions src/ngx_http_lua_bodyfilterby.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ ngx_http_lua_body_filter_inline(ngx_http_request_t *r, ngx_chain_t *in)

L = ngx_http_lua_get_lua_vm(r, NULL);

if (!llcf->enable_code_cache) {
llcf->body_filter_src_ref = LUA_REFNIL;
}

/* load Lua inline script (w/ cache) sp = 1 */
rc = ngx_http_lua_cache_loadbuffer(r->connection->log, L,
llcf->body_filter_src.value.data,
Expand Down Expand Up @@ -206,6 +210,10 @@ ngx_http_lua_body_filter_file(ngx_http_request_t *r, ngx_chain_t *in)

L = ngx_http_lua_get_lua_vm(r, NULL);

if (!llcf->enable_code_cache) {
llcf->body_filter_src_ref = LUA_REFNIL;
}

/* load Lua script file (w/ cache) sp = 1 */
rc = ngx_http_lua_cache_loadfile(r->connection->log, L, script_path,
&llcf->body_filter_src_ref,
Expand Down
8 changes: 8 additions & 0 deletions src/ngx_http_lua_contentby.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ ngx_http_lua_content_handler_file(ngx_http_request_t *r)

L = ngx_http_lua_get_lua_vm(r, NULL);

if (!llcf->enable_code_cache) {
llcf->content_src_ref = LUA_REFNIL;
}

/* load Lua script file (w/ cache) sp = 1 */
rc = ngx_http_lua_cache_loadfile(r->connection->log, L, script_path,
&llcf->content_src_ref,
Expand Down Expand Up @@ -297,6 +301,10 @@ ngx_http_lua_content_handler_inline(ngx_http_request_t *r)

L = ngx_http_lua_get_lua_vm(r, NULL);

if (!llcf->enable_code_cache) {
llcf->content_src_ref = LUA_REFNIL;
}

/* load Lua inline script (w/ cache) sp = 1 */
rc = ngx_http_lua_cache_loadbuffer(r->connection->log, L,
llcf->content_src.value.data,
Expand Down
8 changes: 8 additions & 0 deletions src/ngx_http_lua_headerfilterby.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ ngx_http_lua_header_filter_inline(ngx_http_request_t *r)

L = ngx_http_lua_get_lua_vm(r, NULL);

if (!llcf->enable_code_cache) {
llcf->header_filter_src_ref = LUA_REFNIL;
}

/* load Lua inline script (w/ cache) sp = 1 */
rc = ngx_http_lua_cache_loadbuffer(r->connection->log, L,
llcf->header_filter_src.value.data,
Expand Down Expand Up @@ -210,6 +214,10 @@ ngx_http_lua_header_filter_file(ngx_http_request_t *r)

L = ngx_http_lua_get_lua_vm(r, NULL);

if (!llcf->enable_code_cache) {
llcf->header_filter_src_ref = LUA_REFNIL;
}

/* load Lua script file (w/ cache) sp = 1 */
rc = ngx_http_lua_cache_loadfile(r->connection->log, L, script_path,
&llcf->header_filter_src_ref,
Expand Down
8 changes: 8 additions & 0 deletions src/ngx_http_lua_logby.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ ngx_http_lua_log_handler_inline(ngx_http_request_t *r)

L = ngx_http_lua_get_lua_vm(r, NULL);

if (!llcf->enable_code_cache) {
llcf->log_src_ref = LUA_REFNIL;
}

/* load Lua inline script (w/ cache) sp = 1 */
rc = ngx_http_lua_cache_loadbuffer(r->connection->log, L,
llcf->log_src.value.data,
Expand Down Expand Up @@ -188,6 +192,10 @@ ngx_http_lua_log_handler_file(ngx_http_request_t *r)

L = ngx_http_lua_get_lua_vm(r, NULL);

if (!llcf->enable_code_cache) {
llcf->log_src_ref = LUA_REFNIL;
}

/* load Lua script file (w/ cache) sp = 1 */
rc = ngx_http_lua_cache_loadfile(r->connection->log, L, script_path,
&llcf->log_src_ref,
Expand Down
8 changes: 8 additions & 0 deletions src/ngx_http_lua_rewriteby.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,10 @@ ngx_http_lua_rewrite_handler_inline(ngx_http_request_t *r)
llcf = ngx_http_get_module_loc_conf(r, ngx_http_lua_module);
L = ngx_http_lua_get_lua_vm(r, NULL);

if (!llcf->enable_code_cache) {
llcf->rewrite_src_ref = LUA_REFNIL;
}

/* load Lua inline script (w/ cache) sp = 1 */
rc = ngx_http_lua_cache_loadbuffer(r->connection->log, L,
llcf->rewrite_src.value.data,
Expand Down Expand Up @@ -217,6 +221,10 @@ ngx_http_lua_rewrite_handler_file(ngx_http_request_t *r)

L = ngx_http_lua_get_lua_vm(r, NULL);

if (!llcf->enable_code_cache) {
llcf->rewrite_src_ref = LUA_REFNIL;
}

/* load Lua script file (w/ cache) sp = 1 */
rc = ngx_http_lua_cache_loadfile(r->connection->log, L, script_path,
&llcf->rewrite_src_ref,
Expand Down
60 changes: 59 additions & 1 deletion t/014-bugs.t
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ log_level('debug');
repeat_each(3);

# NB: the shutdown_error_log block is independent from repeat times
plan tests => repeat_each() * (blocks() * 2 + 33);
plan tests => repeat_each() * (blocks() * 2 + 41);

our $HtmlDir = html_dir;
#warn $html_dir;
Expand Down Expand Up @@ -1397,3 +1397,61 @@ If-Match: 1
--- error_code: 200
--- response_body eval
qr/\Ahello\z/



=== TEST 51: subrequest cycle problem in rewrite_by_lua_file
--- http_config
lua_code_cache off;
--- config
set $main "foo";
set $sub "bar";
location = /main {
rewrite_by_lua_file html/main.lua;
echo $main;
}

location = /sub {
rewrite_by_lua_file html/sub.lua;
echo $sub;
}
--- user_files
>>> main.lua
local res = ngx.location.capture("/sub")
ngx.var.main = "main " .. res.body
>>> sub.lua
ngx.var.sub = "sub"

--- pipelined_requests eval
["GET /sub", "GET /main"]
--- response_body eval
["sub\n", "main sub\n\n"]
--- no_error_log
[error]



=== TEST 52: subrequest cycle problem in content_by_lua_file
--- http_config
lua_code_cache off;
--- config
location = /main {
content_by_lua_file html/main.lua;
}

location = /sub {
content_by_lua_file html/sub.lua;
}
--- user_files
>>> main.lua
local res = ngx.location.capture("/sub")
ngx.print("main " .. res.body)
>>> sub.lua
ngx.print("sub")

--- pipelined_requests eval
["GET /sub", "GET /main"]
--- response_body eval
["sub", "main sub"]
--- no_error_log
[error]