]> git.kaiwu.me - nginx.git/commitdiff
Stream: added preconfiguration step.
authorVladimir Homutov <vl@nginx.com>
Wed, 15 Jun 2016 12:10:24 +0000 (15:10 +0300)
committerVladimir Homutov <vl@nginx.com>
Wed, 15 Jun 2016 12:10:24 +0000 (15:10 +0300)
src/stream/ngx_stream.c
src/stream/ngx_stream.h
src/stream/ngx_stream_access_module.c
src/stream/ngx_stream_core_module.c
src/stream/ngx_stream_limit_conn_module.c
src/stream/ngx_stream_proxy_module.c
src/stream/ngx_stream_ssl_module.c
src/stream/ngx_stream_upstream.c
src/stream/ngx_stream_upstream_hash_module.c
src/stream/ngx_stream_upstream_least_conn_module.c
src/stream/ngx_stream_upstream_zone_module.c

index 5e7abaebed843db8d16afb4f860fa5f7105e094d..ea731458e1e1cffcc344dd4a370cc21c275fe482 100644 (file)
@@ -143,11 +143,26 @@ ngx_stream_block(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
     }
 
 
-    /* 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);
index 1c351738648834dee11a6f134b28abd52105821e..ffa855cdf8a3ba926ff4af1be97eb5ffa5b74f1d 100644 (file)
@@ -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);
index 64869d230e3d29f1785aeffba237f006208f5f79..6985d36a1e5592aba03916eeb90ce886e1e3c129 100644 (file)
@@ -88,6 +88,7 @@ static ngx_command_t  ngx_stream_access_commands[] = {
 
 
 static ngx_stream_module_t  ngx_stream_access_module_ctx = {
+    NULL,                                  /* preconfiguration */
     ngx_stream_access_init,                /* postconfiguration */
 
     NULL,                                  /* create main configuration */
index 075db82bbd798a741f823b310cd436a4728fdff2..2ed792bd1b4440c4e2ca7b4470ded1686013604f 100644 (file)
@@ -57,6 +57,7 @@ static ngx_command_t  ngx_stream_core_commands[] = {
 
 
 static ngx_stream_module_t  ngx_stream_core_module_ctx = {
+    NULL,                                  /* preconfiguration */
     NULL,                                  /* postconfiguration */
 
     ngx_stream_core_create_main_conf,      /* create main configuration */
index c27d7484a5044873dd6843acdac209ea50d66e88..8c70a8239a9f2dae538ae331f3aeebf68a630794 100644 (file)
@@ -93,6 +93,7 @@ static ngx_command_t  ngx_stream_limit_conn_commands[] = {
 
 
 static ngx_stream_module_t  ngx_stream_limit_conn_module_ctx = {
+    NULL,                                  /* preconfiguration */
     ngx_stream_limit_conn_init,            /* postconfiguration */
 
     NULL,                                  /* create main configuration */
index d7df72c9acfe90b28bde12dad5be17d8a09cc392..fdffd15be2b1ff3a4ffbf7aa00bd0a8ee092078f 100644 (file)
@@ -314,6 +314,7 @@ static ngx_command_t  ngx_stream_proxy_commands[] = {
 
 
 static ngx_stream_module_t  ngx_stream_proxy_module_ctx = {
+    NULL,                                  /* preconfiguration */
     NULL,                                  /* postconfiguration */
 
     NULL,                                  /* create main configuration */
index 9c559c6355df3cc02ce35502c792490b56a8a581..095bdaebc2ca5e5d8c1d483e53252a32060e8ae7 100644 (file)
@@ -132,6 +132,7 @@ static ngx_command_t  ngx_stream_ssl_commands[] = {
 
 
 static ngx_stream_module_t  ngx_stream_ssl_module_ctx = {
+    NULL,                                  /* preconfiguration */
     NULL,                                  /* postconfiguration */
 
     NULL,                                  /* create main configuration */
index 69dddc5b4e45eb8a122124cdb41f3756978a570a..36d05cc886127540cc1f2ccc03c3f088c27495b0 100644 (file)
@@ -39,6 +39,7 @@ static ngx_command_t  ngx_stream_upstream_commands[] = {
 
 
 static ngx_stream_module_t  ngx_stream_upstream_module_ctx = {
+    NULL,                                  /* preconfiguration */
     NULL,                                  /* postconfiguration */
 
     ngx_stream_upstream_create_main_conf,  /* create main configuration */
index 56ff7d6e9872dc243ab687b485cbe42edb59dd1f..f200f47a72e11542aef03c9fee8a4f8002d6c16a 100644 (file)
@@ -76,6 +76,7 @@ static ngx_command_t  ngx_stream_upstream_hash_commands[] = {
 
 
 static ngx_stream_module_t  ngx_stream_upstream_hash_module_ctx = {
+    NULL,                                  /* preconfiguration */
     NULL,                                  /* postconfiguration */
 
     NULL,                                  /* create main configuration */
index c9719f92e71b683a3e50e240e3f005fd8c5ef557..359d78808cd68ec4b921cfb464f6c8c7d170eb53 100644 (file)
@@ -32,6 +32,7 @@ static ngx_command_t  ngx_stream_upstream_least_conn_commands[] = {
 
 
 static ngx_stream_module_t  ngx_stream_upstream_least_conn_module_ctx = {
+    NULL,                                    /* preconfiguration */
     NULL,                                    /* postconfiguration */
 
     NULL,                                    /* create main configuration */
index ffc9e8a69a9f1eb74a3c519e0a75df55f57db9d1..ddcc093c0247375f36953de2c11dfc4bc721bd2f 100644 (file)
@@ -32,6 +32,7 @@ static ngx_command_t  ngx_stream_upstream_zone_commands[] = {
 
 
 static ngx_stream_module_t  ngx_stream_upstream_zone_module_ctx = {
+    NULL,                                  /* preconfiguration */
     NULL,                                  /* postconfiguration */
 
     NULL,                                  /* create main configuration */