Skip to content

Commit c2390ab

Browse files
committed
Revert "bugfix: ensured 'init_worker_by_lua*' does not mutate another NGINX module's main_conf."
This reverts commit 09484e8.
1 parent e328645 commit c2390ab

File tree

5 files changed

+1
-235
lines changed

5 files changed

+1
-235
lines changed

src/ngx_http_lua_initworkerby.c

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ ngx_http_lua_init_worker(ngx_cycle_t *cycle)
8686
}
8787

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

9091
top_clcf = conf_ctx->loc_conf[ngx_http_core_module.ctx_index];
9192
top_llcf = conf_ctx->loc_conf[ngx_http_lua_module.ctx_index];
@@ -188,12 +189,6 @@ ngx_http_lua_init_worker(ngx_cycle_t *cycle)
188189
return NGX_ERROR;
189190
}
190191

191-
http_ctx.main_conf = ngx_pcalloc(conf.pool,
192-
sizeof(void *) * ngx_http_max_module);
193-
if (http_ctx.main_conf == NULL) {
194-
return NGX_ERROR;
195-
}
196-
197192
#if (nginx_version >= 1009011)
198193
modules = cycle->modules;
199194
#else
@@ -207,21 +202,6 @@ ngx_http_lua_init_worker(ngx_cycle_t *cycle)
207202

208203
module = modules[i]->ctx;
209204

210-
if (module->create_main_conf) {
211-
cur = module->create_main_conf(&conf);
212-
if (cur == NULL) {
213-
return NGX_ERROR;
214-
}
215-
216-
if (ngx_modules[i]->index == ngx_http_lua_module.index) {
217-
ngx_memcpy(cur,
218-
conf_ctx->main_conf[ngx_http_lua_module.ctx_index],
219-
sizeof(ngx_http_lua_main_conf_t));
220-
}
221-
222-
http_ctx.main_conf[modules[i]->ctx_index] = cur;
223-
}
224-
225205
if (module->create_srv_conf) {
226206
cur = module->create_srv_conf(&conf);
227207
if (cur == NULL) {

t/124-init-worker.t

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -967,25 +967,3 @@ qr/lua close the global Lua VM ([0-9A-F]+)$/,
967967
--- no_error_log
968968
[error]
969969
start privileged agent process
970-
971-
972-
973-
=== TEST 25: ensure it does not mutate another module's main_conf (github issue #1553)
974-
https://github.com/openresty/lua-nginx-module/issues/1553
975-
--- http_config
976-
init_worker_by_lua_block {
977-
return
978-
}
979-
--- config
980-
location /t {
981-
content_by_lua_block {
982-
ngx.say("fake_var = ", ngx.var.fake_var)
983-
}
984-
}
985-
--- request
986-
GET /t
987-
--- response_body
988-
fake_var = 1
989-
--- no_error_log
990-
[error]
991-
[alert]

t/data/fake-merge-module/config

Lines changed: 0 additions & 3 deletions
This file was deleted.

t/data/fake-merge-module/ngx_http_fake_merge_module.c

Lines changed: 0 additions & 187 deletions
This file was deleted.

util/build.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ force=$2
2323
#--with-http_spdy_module \
2424

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

2827
time ngx-build $force $version \
2928
--with-pcre-jit \
@@ -59,7 +58,6 @@ time ngx-build $force $version \
5958
--add-module=$root/../stream-lua-nginx-module \
6059
--add-module=$root/t/data/fake-module \
6160
$add_fake_shm_module \
62-
$add_fake_merge_module \
6361
--add-module=$root/t/data/fake-delayed-load-module \
6462
--with-http_gunzip_module \
6563
--with-http_dav_module \

0 commit comments

Comments
 (0)