Skip to content

Commit ad69f2a

Browse files
authored
feat: backport "some lua configurations were missing in the init_worker" (#24)
1 parent ce1405d commit ad69f2a

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
diff --git src/ngx_stream_lua_initworkerby.c src/ngx_stream_lua_initworkerby.c
2+
index 0c329a5..786ba34 100644
3+
--- src/ngx_stream_lua_initworkerby.c
4+
+++ src/ngx_stream_lua_initworkerby.c
5+
@@ -51,8 +51,8 @@ ngx_stream_lua_init_worker(ngx_cycle_t *cycle)
6+
ngx_conf_file_t *conf_file;
7+
ngx_stream_session_t *s;
8+
9+
- ngx_stream_core_srv_conf_t *clcf, *top_clcf;
10+
- ngx_stream_lua_srv_conf_t *llcf, *top_llcf;
11+
+ ngx_stream_core_srv_conf_t *cscf, *top_cscf;
12+
+ ngx_stream_lua_srv_conf_t *lscf, *top_lscf;
13+
14+
lmcf = ngx_stream_cycle_get_module_main_conf(cycle, ngx_stream_lua_module);
15+
16+
@@ -98,8 +98,8 @@ ngx_stream_lua_init_worker(ngx_cycle_t *cycle)
17+
cycle->conf_ctx[ngx_stream_module.index];
18+
stream_ctx.main_conf = conf_ctx->main_conf;
19+
20+
- top_clcf = conf_ctx->srv_conf[ngx_stream_core_module.ctx_index];
21+
- top_llcf = conf_ctx->srv_conf[ngx_stream_lua_module.ctx_index];
22+
+ top_cscf = conf_ctx->srv_conf[ngx_stream_core_module.ctx_index];
23+
+ top_lscf = conf_ctx->srv_conf[ngx_stream_lua_module.ctx_index];
24+
25+
ngx_memzero(&conf, sizeof(ngx_conf_t));
26+
27+
@@ -223,16 +223,24 @@ ngx_stream_lua_init_worker(ngx_cycle_t *cycle)
28+
stream_ctx.srv_conf[modules[i]->ctx_index] = cur;
29+
30+
if (modules[i]->ctx_index == ngx_stream_core_module.ctx_index) {
31+
- clcf = cur;
32+
+ cscf = cur;
33+
/* just to silence the error in
34+
* ngx_stream_core_merge_srv_conf */
35+
- clcf->handler = ngx_stream_lua_content_handler;
36+
+ cscf->handler = ngx_stream_lua_content_handler;
37+
}
38+
39+
if (module->merge_srv_conf) {
40+
- prev = module->create_srv_conf(&conf);
41+
- if (prev == NULL) {
42+
- return NGX_ERROR;
43+
+ if (modules[i] == &ngx_stream_lua_module) {
44+
+ prev = top_lscf;
45+
+
46+
+ } else if (modules[i] == &ngx_stream_core_module) {
47+
+ prev = top_cscf;
48+
+
49+
+ } else {
50+
+ prev = module->create_srv_conf(&conf);
51+
+ if (prev == NULL) {
52+
+ return NGX_ERROR;
53+
+ }
54+
}
55+
56+
rv = module->merge_srv_conf(&conf, prev, cur);
57+
@@ -262,24 +270,24 @@ ngx_stream_lua_init_worker(ngx_cycle_t *cycle)
58+
s->main_conf = stream_ctx.main_conf;
59+
s->srv_conf = stream_ctx.srv_conf;
60+
61+
- clcf = ngx_stream_get_module_srv_conf(s, ngx_stream_core_module);
62+
+ cscf = ngx_stream_get_module_srv_conf(s, ngx_stream_core_module);
63+
64+
- llcf = ngx_stream_get_module_srv_conf(s, ngx_stream_lua_module);
65+
+ lscf = ngx_stream_get_module_srv_conf(s, ngx_stream_lua_module);
66+
67+
- if (top_llcf->log_socket_errors != NGX_CONF_UNSET) {
68+
- llcf->log_socket_errors = top_llcf->log_socket_errors;
69+
+ if (top_lscf->log_socket_errors != NGX_CONF_UNSET) {
70+
+ lscf->log_socket_errors = top_lscf->log_socket_errors;
71+
}
72+
73+
- if (top_clcf->resolver != NULL) {
74+
- clcf->resolver = top_clcf->resolver;
75+
+ if (top_cscf->resolver != NULL) {
76+
+ cscf->resolver = top_cscf->resolver;
77+
}
78+
79+
- if (top_clcf->resolver_timeout != NGX_CONF_UNSET_MSEC) {
80+
- clcf->resolver_timeout = top_clcf->resolver_timeout;
81+
+ if (top_cscf->resolver_timeout != NGX_CONF_UNSET_MSEC) {
82+
+ cscf->resolver_timeout = top_cscf->resolver_timeout;
83+
}
84+
85+
#if defined(nginx_version) && nginx_version >= 1009000
86+
- ngx_set_connection_log(s->connection, clcf->error_log);
87+
+ ngx_set_connection_log(s->connection, cscf->error_log);
88+
89+
#else
90+
#endif

0 commit comments

Comments
 (0)