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.c83
1 files changed, 44 insertions, 39 deletions
diff --git a/src/http/modules/ngx_http_fastcgi_module.c b/src/http/modules/ngx_http_fastcgi_module.c
index aad8ecdf0..1e0043175 100644
--- a/src/http/modules/ngx_http_fastcgi_module.c
+++ b/src/http/modules/ngx_http_fastcgi_module.c
@@ -11,22 +11,27 @@
typedef struct {
+ ngx_array_t *flushes;
+ ngx_array_t *lengths;
+ ngx_array_t *values;
+ ngx_uint_t number;
+ ngx_hash_t hash;
+} ngx_http_fastcgi_params_t;
+
+
+typedef struct {
ngx_http_upstream_conf_t upstream;
ngx_str_t index;
- ngx_array_t *flushes;
- ngx_array_t *params_len;
- ngx_array_t *params;
+ ngx_http_fastcgi_params_t params;
+
ngx_array_t *params_source;
ngx_array_t *catch_stderr;
ngx_array_t *fastcgi_lengths;
ngx_array_t *fastcgi_values;
- ngx_hash_t headers_hash;
- ngx_uint_t header_params;
-
ngx_flag_t keep_conn;
#if (NGX_HTTP_CACHE)
@@ -151,7 +156,7 @@ 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_init_params(ngx_conf_t *cf,
- ngx_http_fastcgi_loc_conf_t *conf);
+ ngx_http_fastcgi_loc_conf_t *conf, ngx_http_fastcgi_params_t *params);
static ngx_int_t ngx_http_fastcgi_script_name_variable(ngx_http_request_t *r,
ngx_http_variable_value_t *v, uintptr_t data);
@@ -780,6 +785,7 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
ngx_http_script_code_pt code;
ngx_http_script_engine_t e, le;
ngx_http_fastcgi_header_t *h;
+ ngx_http_fastcgi_params_t *params;
ngx_http_fastcgi_loc_conf_t *flcf;
ngx_http_script_len_code_pt lcode;
@@ -789,13 +795,15 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
flcf = ngx_http_get_module_loc_conf(r, ngx_http_fastcgi_module);
- if (flcf->params_len) {
+ params = &flcf->params;
+
+ if (params->lengths) {
ngx_memzero(&le, sizeof(ngx_http_script_engine_t));
- ngx_http_script_flush_no_cacheable_variables(r, flcf->flushes);
+ ngx_http_script_flush_no_cacheable_variables(r, params->flushes);
le.flushed = 1;
- le.ip = flcf->params_len->elts;
+ le.ip = params->lengths->elts;
le.request = r;
while (*(uintptr_t *) le.ip) {
@@ -824,7 +832,7 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
allocated = 0;
lowcase_key = NULL;
- if (flcf->header_params) {
+ if (params->number) {
n = 0;
part = &r->headers_in.headers.part;
@@ -854,7 +862,7 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
i = 0;
}
- if (flcf->header_params) {
+ if (params->number) {
if (allocated < header[i].key.len) {
allocated = header[i].key.len + 16;
lowcase_key = ngx_pnalloc(r->pool, allocated);
@@ -879,7 +887,7 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
lowcase_key[n] = ch;
}
- if (ngx_hash_find(&flcf->headers_hash, hash, lowcase_key, n)) {
+ if (ngx_hash_find(&params->hash, hash, lowcase_key, n)) {
ignored[header_params++] = &header[i];
continue;
}
@@ -949,15 +957,15 @@ ngx_http_fastcgi_create_request(ngx_http_request_t *r)
+ sizeof(ngx_http_fastcgi_header_t);
- if (flcf->params_len) {
+ if (params->lengths) {
ngx_memzero(&e, sizeof(ngx_http_script_engine_t));
- e.ip = flcf->params->elts;
+ e.ip = params->values->elts;
e.pos = b->last;
e.request = r;
e.flushed = 1;
- le.ip = flcf->params_len->elts;
+ le.ip = params->lengths->elts;
while (*(uintptr_t *) le.ip) {
@@ -2710,15 +2718,11 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
if ((conf->upstream.cache == NULL) == (prev->upstream.cache == NULL))
#endif
{
- conf->flushes = prev->flushes;
- conf->params_len = prev->params_len;
conf->params = prev->params;
- conf->headers_hash = prev->headers_hash;
- conf->header_params = prev->header_params;
}
}
- if (ngx_http_fastcgi_init_params(cf, conf) != NGX_OK) {
+ if (ngx_http_fastcgi_init_params(cf, conf, &conf->params) != NGX_OK) {
return NGX_CONF_ERROR;
}
@@ -2727,7 +2731,8 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
static ngx_int_t
-ngx_http_fastcgi_init_params(ngx_conf_t *cf, ngx_http_fastcgi_loc_conf_t *conf)
+ngx_http_fastcgi_init_params(ngx_conf_t *cf, ngx_http_fastcgi_loc_conf_t *conf,
+ ngx_http_fastcgi_params_t *params)
{
u_char *p;
size_t size;
@@ -2743,7 +2748,7 @@ ngx_http_fastcgi_init_params(ngx_conf_t *cf, ngx_http_fastcgi_loc_conf_t *conf)
ngx_http_script_compile_t sc;
ngx_http_script_copy_code_t *copy;
- if (conf->headers_hash.buckets) {
+ if (params->hash.buckets) {
return NGX_OK;
}
@@ -2753,17 +2758,17 @@ ngx_http_fastcgi_init_params(ngx_conf_t *cf, ngx_http_fastcgi_loc_conf_t *conf)
#endif
)
{
- conf->headers_hash.buckets = (void *) 1;
+ params->hash.buckets = (void *) 1;
return NGX_OK;
}
- conf->params_len = ngx_array_create(cf->pool, 64, 1);
- if (conf->params_len == NULL) {
+ params->lengths = ngx_array_create(cf->pool, 64, 1);
+ if (params->lengths == NULL) {
return NGX_ERROR;
}
- conf->params = ngx_array_create(cf->pool, 512, 1);
- if (conf->params == NULL) {
+ params->values = ngx_array_create(cf->pool, 512, 1);
+ if (params->values == NULL) {
return NGX_ERROR;
}
@@ -2858,7 +2863,7 @@ ngx_http_fastcgi_init_params(ngx_conf_t *cf, ngx_http_fastcgi_loc_conf_t *conf)
}
}
- copy = ngx_array_push_n(conf->params_len,
+ copy = ngx_array_push_n(params->lengths,
sizeof(ngx_http_script_copy_code_t));
if (copy == NULL) {
return NGX_ERROR;
@@ -2867,7 +2872,7 @@ ngx_http_fastcgi_init_params(ngx_conf_t *cf, ngx_http_fastcgi_loc_conf_t *conf)
copy->code = (ngx_http_script_code_pt) ngx_http_script_copy_len_code;
copy->len = src[i].key.len;
- copy = ngx_array_push_n(conf->params_len,
+ copy = ngx_array_push_n(params->lengths,
sizeof(ngx_http_script_copy_code_t));
if (copy == NULL) {
return NGX_ERROR;
@@ -2881,7 +2886,7 @@ ngx_http_fastcgi_init_params(ngx_conf_t *cf, ngx_http_fastcgi_loc_conf_t *conf)
+ src[i].key.len + sizeof(uintptr_t) - 1)
& ~(sizeof(uintptr_t) - 1);
- copy = ngx_array_push_n(conf->params, size);
+ copy = ngx_array_push_n(params->values, size);
if (copy == NULL) {
return NGX_ERROR;
}
@@ -2897,15 +2902,15 @@ ngx_http_fastcgi_init_params(ngx_conf_t *cf, ngx_http_fastcgi_loc_conf_t *conf)
sc.cf = cf;
sc.source = &src[i].value;
- sc.flushes = &conf->flushes;
- sc.lengths = &conf->params_len;
- sc.values = &conf->params;
+ sc.flushes = &params->flushes;
+ sc.lengths = &params->lengths;
+ sc.values = &params->values;
if (ngx_http_script_compile(&sc) != NGX_OK) {
return NGX_ERROR;
}
- code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t));
+ code = ngx_array_push_n(params->lengths, sizeof(uintptr_t));
if (code == NULL) {
return NGX_ERROR;
}
@@ -2913,7 +2918,7 @@ ngx_http_fastcgi_init_params(ngx_conf_t *cf, ngx_http_fastcgi_loc_conf_t *conf)
*code = (uintptr_t) NULL;
- code = ngx_array_push_n(conf->params, sizeof(uintptr_t));
+ code = ngx_array_push_n(params->values, sizeof(uintptr_t));
if (code == NULL) {
return NGX_ERROR;
}
@@ -2921,16 +2926,16 @@ ngx_http_fastcgi_init_params(ngx_conf_t *cf, ngx_http_fastcgi_loc_conf_t *conf)
*code = (uintptr_t) NULL;
}
- code = ngx_array_push_n(conf->params_len, sizeof(uintptr_t));
+ code = ngx_array_push_n(params->lengths, sizeof(uintptr_t));
if (code == NULL) {
return NGX_ERROR;
}
*code = (uintptr_t) NULL;
- conf->header_params = headers_names.nelts;
+ params->number = headers_names.nelts;
- hash.hash = &conf->headers_hash;
+ hash.hash = &params->hash;
hash.key = ngx_hash_key_lc;
hash.max_size = 512;
hash.bucket_size = 64;