Skip to content

Commit c632dae

Browse files
committed
synchronized with lua-nginx-module #09484e8 (do not mutate another module's main_conf).
Thanks wangfakang for the upstream patch.
1 parent b07b909 commit c632dae

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/subsys/ngx_subsys_lua_initworkerby.c.tt2

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,6 @@ ngx_[% subsys %]_lua_init_worker(ngx_cycle_t *cycle)
108108

109109
conf_ctx = (ngx_[% subsys %]_conf_ctx_t *)
110110
cycle->conf_ctx[ngx_[% subsys %]_module.index];
111-
[% subsys %]_ctx.main_conf = conf_ctx->main_conf;
112111

113112
[% IF http_subsys %]
114113
top_clcf = conf_ctx->loc_conf[ngx_http_core_module.ctx_index];
@@ -240,6 +239,12 @@ ngx_[% subsys %]_lua_init_worker(ngx_cycle_t *cycle)
240239
return NGX_ERROR;
241240
}
242241

242+
[% subsys %]_ctx.main_conf = ngx_pcalloc(conf.pool,
243+
sizeof(void *) * ngx_[% subsys %]_max_module);
244+
if ([% subsys %]_ctx.main_conf == NULL) {
245+
return NGX_ERROR;
246+
}
247+
243248
#if defined(nginx_version) && nginx_version >= 1009011
244249
modules = cycle->modules;
245250
#else
@@ -253,6 +258,21 @@ ngx_[% subsys %]_lua_init_worker(ngx_cycle_t *cycle)
253258

254259
module = modules[i]->ctx;
255260

261+
if (module->create_main_conf) {
262+
cur = module->create_main_conf(&conf);
263+
if (cur == NULL) {
264+
return NGX_ERROR;
265+
}
266+
267+
if (ngx_modules[i]->index == ngx_[% subsys %]_lua_module.index) {
268+
ngx_memcpy(cur,
269+
conf_ctx->main_conf[ngx_[% subsys %]_lua_module.ctx_index],
270+
sizeof(ngx_[% subsys %]_lua_main_conf_t));
271+
}
272+
273+
[% subsys %]_ctx.main_conf[modules[i]->ctx_index] = cur;
274+
}
275+
256276
if (module->create_srv_conf) {
257277
cur = module->create_srv_conf(&conf);
258278
if (cur == NULL) {

0 commit comments

Comments
 (0)