[nginx] Stream: added preconfiguration step.
Vladimir Homutov
vl at nginx.com
Mon Jul 4 14:50:11 UTC 2016
details: http://hg.nginx.org/nginx/rev/2f41d383c9c7
branches:
changeset: 6606:2f41d383c9c7
user: Vladimir Homutov <vl at nginx.com>
date: Wed Jun 15 15:10:24 2016 +0300
description:
Stream: added preconfiguration step.
diffstat:
src/stream/ngx_stream.c | 19 +++++++++++++++++--
src/stream/ngx_stream.h | 1 +
src/stream/ngx_stream_access_module.c | 1 +
src/stream/ngx_stream_core_module.c | 1 +
src/stream/ngx_stream_limit_conn_module.c | 1 +
src/stream/ngx_stream_proxy_module.c | 1 +
src/stream/ngx_stream_ssl_module.c | 1 +
src/stream/ngx_stream_upstream.c | 1 +
src/stream/ngx_stream_upstream_hash_module.c | 1 +
src/stream/ngx_stream_upstream_least_conn_module.c | 1 +
src/stream/ngx_stream_upstream_zone_module.c | 1 +
11 files changed, 27 insertions(+), 2 deletions(-)
diffs (142 lines):
diff -r f379b32e4733 -r 2f41d383c9c7 src/stream/ngx_stream.c
--- a/src/stream/ngx_stream.c Sat Jul 02 15:59:53 2016 +0300
+++ b/src/stream/ngx_stream.c Wed Jun 15 15:10:24 2016 +0300
@@ -143,11 +143,26 @@ ngx_stream_block(ngx_conf_t *cf, ngx_com
}
- /* parse inside the stream{} block */
-
pcf = *cf;
cf->ctx = ctx;
+ for (m = 0; cf->cycle->modules[m]; m++) {
+ if (cf->cycle->modules[m]->type != NGX_STREAM_MODULE) {
+ continue;
+ }
+
+ module = cf->cycle->modules[m]->ctx;
+
+ if (module->preconfiguration) {
+ if (module->preconfiguration(cf) != NGX_OK) {
+ return NGX_CONF_ERROR;
+ }
+ }
+ }
+
+
+ /* parse inside the stream{} block */
+
cf->module_type = NGX_STREAM_MODULE;
cf->cmd_type = NGX_STREAM_MAIN_CONF;
rv = ngx_conf_parse(cf, NULL);
diff -r f379b32e4733 -r 2f41d383c9c7 src/stream/ngx_stream.h
--- a/src/stream/ngx_stream.h Sat Jul 02 15:59:53 2016 +0300
+++ b/src/stream/ngx_stream.h Wed Jun 15 15:10:24 2016 +0300
@@ -145,6 +145,7 @@ struct ngx_stream_session_s {
typedef struct {
+ ngx_int_t (*preconfiguration)(ngx_conf_t *cf);
ngx_int_t (*postconfiguration)(ngx_conf_t *cf);
void *(*create_main_conf)(ngx_conf_t *cf);
diff -r f379b32e4733 -r 2f41d383c9c7 src/stream/ngx_stream_access_module.c
--- a/src/stream/ngx_stream_access_module.c Sat Jul 02 15:59:53 2016 +0300
+++ b/src/stream/ngx_stream_access_module.c Wed Jun 15 15:10:24 2016 +0300
@@ -88,6 +88,7 @@ static ngx_command_t ngx_stream_access_
static ngx_stream_module_t ngx_stream_access_module_ctx = {
+ NULL, /* preconfiguration */
ngx_stream_access_init, /* postconfiguration */
NULL, /* create main configuration */
diff -r f379b32e4733 -r 2f41d383c9c7 src/stream/ngx_stream_core_module.c
--- a/src/stream/ngx_stream_core_module.c Sat Jul 02 15:59:53 2016 +0300
+++ b/src/stream/ngx_stream_core_module.c Wed Jun 15 15:10:24 2016 +0300
@@ -57,6 +57,7 @@ static ngx_command_t ngx_stream_core_co
static ngx_stream_module_t ngx_stream_core_module_ctx = {
+ NULL, /* preconfiguration */
NULL, /* postconfiguration */
ngx_stream_core_create_main_conf, /* create main configuration */
diff -r f379b32e4733 -r 2f41d383c9c7 src/stream/ngx_stream_limit_conn_module.c
--- a/src/stream/ngx_stream_limit_conn_module.c Sat Jul 02 15:59:53 2016 +0300
+++ b/src/stream/ngx_stream_limit_conn_module.c Wed Jun 15 15:10:24 2016 +0300
@@ -93,6 +93,7 @@ static ngx_command_t ngx_stream_limit_c
static ngx_stream_module_t ngx_stream_limit_conn_module_ctx = {
+ NULL, /* preconfiguration */
ngx_stream_limit_conn_init, /* postconfiguration */
NULL, /* create main configuration */
diff -r f379b32e4733 -r 2f41d383c9c7 src/stream/ngx_stream_proxy_module.c
--- a/src/stream/ngx_stream_proxy_module.c Sat Jul 02 15:59:53 2016 +0300
+++ b/src/stream/ngx_stream_proxy_module.c Wed Jun 15 15:10:24 2016 +0300
@@ -314,6 +314,7 @@ static ngx_command_t ngx_stream_proxy_c
static ngx_stream_module_t ngx_stream_proxy_module_ctx = {
+ NULL, /* preconfiguration */
NULL, /* postconfiguration */
NULL, /* create main configuration */
diff -r f379b32e4733 -r 2f41d383c9c7 src/stream/ngx_stream_ssl_module.c
--- a/src/stream/ngx_stream_ssl_module.c Sat Jul 02 15:59:53 2016 +0300
+++ b/src/stream/ngx_stream_ssl_module.c Wed Jun 15 15:10:24 2016 +0300
@@ -132,6 +132,7 @@ static ngx_command_t ngx_stream_ssl_com
static ngx_stream_module_t ngx_stream_ssl_module_ctx = {
+ NULL, /* preconfiguration */
NULL, /* postconfiguration */
NULL, /* create main configuration */
diff -r f379b32e4733 -r 2f41d383c9c7 src/stream/ngx_stream_upstream.c
--- a/src/stream/ngx_stream_upstream.c Sat Jul 02 15:59:53 2016 +0300
+++ b/src/stream/ngx_stream_upstream.c Wed Jun 15 15:10:24 2016 +0300
@@ -39,6 +39,7 @@ static ngx_command_t ngx_stream_upstrea
static ngx_stream_module_t ngx_stream_upstream_module_ctx = {
+ NULL, /* preconfiguration */
NULL, /* postconfiguration */
ngx_stream_upstream_create_main_conf, /* create main configuration */
diff -r f379b32e4733 -r 2f41d383c9c7 src/stream/ngx_stream_upstream_hash_module.c
--- a/src/stream/ngx_stream_upstream_hash_module.c Sat Jul 02 15:59:53 2016 +0300
+++ b/src/stream/ngx_stream_upstream_hash_module.c Wed Jun 15 15:10:24 2016 +0300
@@ -76,6 +76,7 @@ static ngx_command_t ngx_stream_upstrea
static ngx_stream_module_t ngx_stream_upstream_hash_module_ctx = {
+ NULL, /* preconfiguration */
NULL, /* postconfiguration */
NULL, /* create main configuration */
diff -r f379b32e4733 -r 2f41d383c9c7 src/stream/ngx_stream_upstream_least_conn_module.c
--- a/src/stream/ngx_stream_upstream_least_conn_module.c Sat Jul 02 15:59:53 2016 +0300
+++ b/src/stream/ngx_stream_upstream_least_conn_module.c Wed Jun 15 15:10:24 2016 +0300
@@ -32,6 +32,7 @@ static ngx_command_t ngx_stream_upstrea
static ngx_stream_module_t ngx_stream_upstream_least_conn_module_ctx = {
+ NULL, /* preconfiguration */
NULL, /* postconfiguration */
NULL, /* create main configuration */
diff -r f379b32e4733 -r 2f41d383c9c7 src/stream/ngx_stream_upstream_zone_module.c
--- a/src/stream/ngx_stream_upstream_zone_module.c Sat Jul 02 15:59:53 2016 +0300
+++ b/src/stream/ngx_stream_upstream_zone_module.c Wed Jun 15 15:10:24 2016 +0300
@@ -32,6 +32,7 @@ static ngx_command_t ngx_stream_upstrea
static ngx_stream_module_t ngx_stream_upstream_zone_module_ctx = {
+ NULL, /* preconfiguration */
NULL, /* postconfiguration */
NULL, /* create main configuration */
More information about the nginx-devel
mailing list