Skip to content

Commit

Permalink
Revert "bugfix: ensured 'init_worker_by_lua*' does not mutate another…
Browse files Browse the repository at this point in the history
… NGINX module's main_conf."

This reverts commit 09484e8.
  • Loading branch information
thibaultcha committed Jan 17, 2020
1 parent e328645 commit c2390ab
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 235 deletions.
22 changes: 1 addition & 21 deletions src/ngx_http_lua_initworkerby.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ ngx_http_lua_init_worker(ngx_cycle_t *cycle)
}

conf_ctx = (ngx_http_conf_ctx_t *) cycle->conf_ctx[ngx_http_module.index];
http_ctx.main_conf = conf_ctx->main_conf;

top_clcf = conf_ctx->loc_conf[ngx_http_core_module.ctx_index];
top_llcf = conf_ctx->loc_conf[ngx_http_lua_module.ctx_index];
Expand Down Expand Up @@ -188,12 +189,6 @@ ngx_http_lua_init_worker(ngx_cycle_t *cycle)
return NGX_ERROR;
}

http_ctx.main_conf = ngx_pcalloc(conf.pool,
sizeof(void *) * ngx_http_max_module);
if (http_ctx.main_conf == NULL) {
return NGX_ERROR;
}

#if (nginx_version >= 1009011)
modules = cycle->modules;
#else
Expand All @@ -207,21 +202,6 @@ ngx_http_lua_init_worker(ngx_cycle_t *cycle)

module = modules[i]->ctx;

if (module->create_main_conf) {
cur = module->create_main_conf(&conf);
if (cur == NULL) {
return NGX_ERROR;
}

if (ngx_modules[i]->index == ngx_http_lua_module.index) {
ngx_memcpy(cur,
conf_ctx->main_conf[ngx_http_lua_module.ctx_index],
sizeof(ngx_http_lua_main_conf_t));
}

http_ctx.main_conf[modules[i]->ctx_index] = cur;
}

if (module->create_srv_conf) {
cur = module->create_srv_conf(&conf);
if (cur == NULL) {
Expand Down
22 changes: 0 additions & 22 deletions t/124-init-worker.t
Original file line number Diff line number Diff line change
Expand Up @@ -967,25 +967,3 @@ qr/lua close the global Lua VM ([0-9A-F]+)$/,
--- no_error_log
[error]
start privileged agent process



=== TEST 25: ensure it does not mutate another module's main_conf (github issue #1553)
https://github.com/openresty/lua-nginx-module/issues/1553
--- http_config
init_worker_by_lua_block {
return
}
--- config
location /t {
content_by_lua_block {
ngx.say("fake_var = ", ngx.var.fake_var)
}
}
--- request
GET /t
--- response_body
fake_var = 1
--- no_error_log
[error]
[alert]
3 changes: 0 additions & 3 deletions t/data/fake-merge-module/config

This file was deleted.

187 changes: 0 additions & 187 deletions t/data/fake-merge-module/ngx_http_fake_merge_module.c

This file was deleted.

2 changes: 0 additions & 2 deletions util/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ force=$2
#--with-http_spdy_module \

add_fake_shm_module="--add-module=$root/t/data/fake-shm-module"
add_fake_merge_module="--add-module=$root/t/data/fake-merge-module"

time ngx-build $force $version \
--with-pcre-jit \
Expand Down Expand Up @@ -59,7 +58,6 @@ time ngx-build $force $version \
--add-module=$root/../stream-lua-nginx-module \
--add-module=$root/t/data/fake-module \
$add_fake_shm_module \
$add_fake_merge_module \
--add-module=$root/t/data/fake-delayed-load-module \
--with-http_gunzip_module \
--with-http_dav_module \
Expand Down

0 comments on commit c2390ab

Please sign in to comment.