diff options
author | Maxim Dounin <mdounin@mdounin.ru> | 2011-11-14 13:24:43 +0000 |
---|---|---|
committer | Maxim Dounin <mdounin@mdounin.ru> | 2011-11-14 13:24:43 +0000 |
commit | ca01f46103a8767496fe1c0dfc4cf88da51d01eb (patch) | |
tree | 3c61fde9698e51d78a7f7d53b84cbf3ff7272ad2 /src/http/modules/ngx_http_scgi_module.c | |
parent | 86a851907b015ed748d8907aadc4b76c1a77bdde (diff) | |
download | nginx-ca01f46103a8767496fe1c0dfc4cf88da51d01eb.tar.gz nginx-ca01f46103a8767496fe1c0dfc4cf88da51d01eb.zip |
Separate functions to merge fastcgi/scgi/uwsgi params.
No functional changes.
Diffstat (limited to 'src/http/modules/ngx_http_scgi_module.c')
-rw-r--r-- | src/http/modules/ngx_http_scgi_module.c | 70 |
1 files changed, 41 insertions, 29 deletions
diff --git a/src/http/modules/ngx_http_scgi_module.c b/src/http/modules/ngx_http_scgi_module.c index 393edde24..e815490f7 100644 --- a/src/http/modules/ngx_http_scgi_module.c +++ b/src/http/modules/ngx_http_scgi_module.c @@ -43,6 +43,8 @@ static void ngx_http_scgi_finalize_request(ngx_http_request_t *r, ngx_int_t rc); static void *ngx_http_scgi_create_loc_conf(ngx_conf_t *cf); static char *ngx_http_scgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child); +static ngx_int_t ngx_http_scgi_merge_params(ngx_conf_t *cf, + ngx_http_scgi_loc_conf_t *conf, ngx_http_scgi_loc_conf_t *prev); static char *ngx_http_scgi_pass(ngx_conf_t *cf, ngx_command_t *cmd, void *conf); static char *ngx_http_scgi_store(ngx_conf_t *cf, ngx_command_t *cmd, @@ -1059,17 +1061,9 @@ ngx_http_scgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) ngx_http_scgi_loc_conf_t *prev = parent; ngx_http_scgi_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, prev->upstream.store, 0); @@ -1307,6 +1301,29 @@ ngx_http_scgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) } } + if (ngx_http_scgi_merge_params(cf, conf, prev) != NGX_OK) { + return NGX_CONF_ERROR; + } + + return NGX_CONF_OK; +} + + +static ngx_int_t +ngx_http_scgi_merge_params(ngx_conf_t *cf, ngx_http_scgi_loc_conf_t *conf, + ngx_http_scgi_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; @@ -1321,20 +1338,20 @@ ngx_http_scgi_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_scgi_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 @@ -1342,18 +1359,18 @@ ngx_http_scgi_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; @@ -1373,7 +1390,7 @@ ngx_http_scgi_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; @@ -1395,7 +1412,7 @@ ngx_http_scgi_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; @@ -1411,7 +1428,7 @@ ngx_http_scgi_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; @@ -1424,7 +1441,7 @@ ngx_http_scgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child) 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; @@ -1443,12 +1460,12 @@ ngx_http_scgi_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; @@ -1456,7 +1473,7 @@ ngx_http_scgi_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; @@ -1464,14 +1481,14 @@ ngx_http_scgi_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; code = ngx_array_push_n(conf->params, sizeof(uintptr_t)); if (code == NULL) { - return NGX_CONF_ERROR; + return NGX_ERROR; } *code = (uintptr_t) NULL; @@ -1486,12 +1503,7 @@ ngx_http_scgi_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); } |