Stream: added preconfiguration step.

This commit is contained in:
Vladimir Homutov 2016-06-15 15:10:24 +03:00
parent c9dae918fd
commit db5a15d2f9
11 changed files with 27 additions and 2 deletions

View 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; pcf = *cf;
cf->ctx = ctx; 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->module_type = NGX_STREAM_MODULE;
cf->cmd_type = NGX_STREAM_MAIN_CONF; cf->cmd_type = NGX_STREAM_MAIN_CONF;
rv = ngx_conf_parse(cf, NULL); rv = ngx_conf_parse(cf, NULL);

View File

@ -145,6 +145,7 @@ struct ngx_stream_session_s {
typedef struct { typedef struct {
ngx_int_t (*preconfiguration)(ngx_conf_t *cf);
ngx_int_t (*postconfiguration)(ngx_conf_t *cf); ngx_int_t (*postconfiguration)(ngx_conf_t *cf);
void *(*create_main_conf)(ngx_conf_t *cf); void *(*create_main_conf)(ngx_conf_t *cf);

View File

@ -88,6 +88,7 @@ static ngx_command_t ngx_stream_access_commands[] = {
static ngx_stream_module_t ngx_stream_access_module_ctx = { static ngx_stream_module_t ngx_stream_access_module_ctx = {
NULL, /* preconfiguration */
ngx_stream_access_init, /* postconfiguration */ ngx_stream_access_init, /* postconfiguration */
NULL, /* create main configuration */ NULL, /* create main configuration */

View File

@ -57,6 +57,7 @@ static ngx_command_t ngx_stream_core_commands[] = {
static ngx_stream_module_t ngx_stream_core_module_ctx = { static ngx_stream_module_t ngx_stream_core_module_ctx = {
NULL, /* preconfiguration */
NULL, /* postconfiguration */ NULL, /* postconfiguration */
ngx_stream_core_create_main_conf, /* create main configuration */ ngx_stream_core_create_main_conf, /* create main configuration */

View 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 = { static ngx_stream_module_t ngx_stream_limit_conn_module_ctx = {
NULL, /* preconfiguration */
ngx_stream_limit_conn_init, /* postconfiguration */ ngx_stream_limit_conn_init, /* postconfiguration */
NULL, /* create main configuration */ NULL, /* create main configuration */

View File

@ -314,6 +314,7 @@ static ngx_command_t ngx_stream_proxy_commands[] = {
static ngx_stream_module_t ngx_stream_proxy_module_ctx = { static ngx_stream_module_t ngx_stream_proxy_module_ctx = {
NULL, /* preconfiguration */
NULL, /* postconfiguration */ NULL, /* postconfiguration */
NULL, /* create main configuration */ NULL, /* create main configuration */

View File

@ -132,6 +132,7 @@ static ngx_command_t ngx_stream_ssl_commands[] = {
static ngx_stream_module_t ngx_stream_ssl_module_ctx = { static ngx_stream_module_t ngx_stream_ssl_module_ctx = {
NULL, /* preconfiguration */
NULL, /* postconfiguration */ NULL, /* postconfiguration */
NULL, /* create main configuration */ NULL, /* create main configuration */

View File

@ -39,6 +39,7 @@ static ngx_command_t ngx_stream_upstream_commands[] = {
static ngx_stream_module_t ngx_stream_upstream_module_ctx = { static ngx_stream_module_t ngx_stream_upstream_module_ctx = {
NULL, /* preconfiguration */
NULL, /* postconfiguration */ NULL, /* postconfiguration */
ngx_stream_upstream_create_main_conf, /* create main configuration */ ngx_stream_upstream_create_main_conf, /* create main configuration */

View 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 = { static ngx_stream_module_t ngx_stream_upstream_hash_module_ctx = {
NULL, /* preconfiguration */
NULL, /* postconfiguration */ NULL, /* postconfiguration */
NULL, /* create main configuration */ NULL, /* create main configuration */

View 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 = { static ngx_stream_module_t ngx_stream_upstream_least_conn_module_ctx = {
NULL, /* preconfiguration */
NULL, /* postconfiguration */ NULL, /* postconfiguration */
NULL, /* create main configuration */ NULL, /* create main configuration */

View 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 = { static ngx_stream_module_t ngx_stream_upstream_zone_module_ctx = {
NULL, /* preconfiguration */
NULL, /* postconfiguration */ NULL, /* postconfiguration */
NULL, /* create main configuration */ NULL, /* create main configuration */