aboutsummaryrefslogtreecommitdiff
path: root/src/http/modules/ngx_http_fastcgi_module.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/http/modules/ngx_http_fastcgi_module.c')
-rw-r--r--src/http/modules/ngx_http_fastcgi_module.c72
1 files changed, 42 insertions, 30 deletions
diff --git a/src/http/modules/ngx_http_fastcgi_module.c b/src/http/modules/ngx_http_fastcgi_module.c
index 8176be632..77e45ea7d 100644
--- a/src/http/modules/ngx_http_fastcgi_module.c
+++ b/src/http/modules/ngx_http_fastcgi_module.c
@@ -147,6 +147,9 @@ static ngx_int_t ngx_http_fastcgi_add_variables(ngx_conf_t *cf);
static void *ngx_http_fastcgi_create_loc_conf(ngx_conf_t *cf);
static char *ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf,
void *parent, void *child);
+static ngx_int_t ngx_http_fastcgi_merge_params(ngx_conf_t *cf,
+ ngx_http_fastcgi_loc_conf_t *conf, ngx_http_fastcgi_loc_conf_t *prev);
+
static ngx_int_t ngx_http_fastcgi_script_name_variable(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
static ngx_int_t ngx_http_fastcgi_path_info_variable(ngx_http_request_t *r,
@@ -2085,17 +2088,9 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_http_fastcgi_loc_conf_t *prev = parent;
ngx_http_fastcgi_loc_conf_t *conf = child;
- u_char *p;
size_t size;
- uintptr_t *code;
- ngx_uint_t i;
- ngx_array_t headers_names;
- ngx_keyval_t *src;
- ngx_hash_key_t *hk;
ngx_hash_init_t hash;
ngx_http_core_loc_conf_t *clcf;
- ngx_http_script_compile_t sc;
- ngx_http_script_copy_code_t *copy;
if (conf->upstream.store != 0) {
ngx_conf_merge_value(conf->upstream.store,
@@ -2355,6 +2350,29 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
}
#endif
+ if (ngx_http_fastcgi_merge_params(cf, conf, prev) != NGX_OK) {
+ return NGX_CONF_ERROR;
+ }
+
+ return NGX_CONF_OK;
+}
+
+
+static ngx_int_t
+ngx_http_fastcgi_merge_params(ngx_conf_t *cf,
+ ngx_http_fastcgi_loc_conf_t *conf, ngx_http_fastcgi_loc_conf_t *prev)
+{
+ u_char *p;
+ size_t size;
+ uintptr_t *code;
+ ngx_uint_t i;
+ ngx_array_t headers_names;
+ ngx_keyval_t *src;
+ ngx_hash_key_t *hk;
+ ngx_hash_init_t hash;
+ ngx_http_script_compile_t sc;
+ ngx_http_script_copy_code_t *copy;
+
if (conf->params_source == NULL) {
conf->flushes = prev->flushes;
conf->params_len = prev->params_len;
@@ -2369,20 +2387,20 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
if ((conf->upstream.cache == NULL)
== (prev->upstream.cache == NULL))
{
- return NGX_CONF_OK;
+ return NGX_OK;
}
/* 6 is a number of ngx_http_fastcgi_cache_headers entries */
conf->params_source = ngx_array_create(cf->pool, 6,
sizeof(ngx_keyval_t));
if (conf->params_source == NULL) {
- return NGX_CONF_ERROR;
+ return NGX_ERROR;
}
}
#else
if (conf->params_source == NULL) {
- return NGX_CONF_OK;
+ return NGX_OK;
}
#endif
@@ -2390,18 +2408,18 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
conf->params_len = ngx_array_create(cf->pool, 64, 1);
if (conf->params_len == NULL) {
- return NGX_CONF_ERROR;
+ return NGX_ERROR;
}
conf->params = ngx_array_create(cf->pool, 512, 1);
if (conf->params == NULL) {
- return NGX_CONF_ERROR;
+ return NGX_ERROR;
}
if (ngx_array_init(&headers_names, cf->temp_pool, 4, sizeof(ngx_hash_key_t))
!= NGX_OK)
{
- return NGX_CONF_ERROR;
+ return NGX_ERROR;
}
src = conf->params_source->elts;
@@ -2421,7 +2439,7 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
s = ngx_array_push(conf->params_source);
if (s == NULL) {
- return NGX_CONF_ERROR;
+ return NGX_ERROR;
}
*s = *h;
@@ -2443,7 +2461,7 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
{
hk = ngx_array_push(&headers_names);
if (hk == NULL) {
- return NGX_CONF_ERROR;
+ return NGX_ERROR;
}
hk->key.len = src[i].key.len - 5;
@@ -2459,7 +2477,7 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
copy = ngx_array_push_n(conf->params_len,
sizeof(ngx_http_script_copy_code_t));
if (copy == NULL) {
- return NGX_CONF_ERROR;
+ return NGX_ERROR;
}
copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code;
@@ -2468,11 +2486,11 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
size = (sizeof(ngx_http_script_copy_code_t)
+ src[i].key.len + sizeof(uintptr_t) - 1)
- & ~(sizeof(uintptr_t) - 1);
+ & ~(sizeof(uintptr_t) - 1);
copy = ngx_array_push_n(conf->params, size);
if (copy == NULL) {
- return NGX_CONF_ERROR;
+ return NGX_ERROR;
}
copy->code = ngx_http_script_copy_code;
@@ -2491,12 +2509,12 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
sc.values = &conf->params;
if (ngx_http_script_compile(&sc) != NGX_OK) {
- return NGX_CONF_ERROR;
+ return NGX_ERROR;
}
code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t));
if (code == NULL) {
- return NGX_CONF_ERROR;
+ return NGX_ERROR;
}
*code = (uintptr_t) NULL;
@@ -2504,7 +2522,7 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
code = ngx_array_push_n(conf->params, sizeof(uintptr_t));
if (code == NULL) {
- return NGX_CONF_ERROR;
+ return NGX_ERROR;
}
*code = (uintptr_t) NULL;
@@ -2512,12 +2530,11 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t));
if (code == NULL) {
- return NGX_CONF_ERROR;
+ return NGX_ERROR;
}
*code = (uintptr_t) NULL;
-
conf->header_params = headers_names.nelts;
hash.hash = &conf->headers_hash;
@@ -2528,12 +2545,7 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
hash.pool = cf->pool;
hash.temp_pool = NULL;
- if (ngx_hash_init(&hash, headers_names.elts, headers_names.nelts) != NGX_OK)
- {
- return NGX_CONF_ERROR;
- }
-
- return NGX_CONF_OK;
+ return ngx_hash_init(&hash, headers_names.elts, headers_names.nelts);
}