comparison src/http/modules/ngx_http_fastcgi_module.c @ 5949:634da79665d3

Upstream: refactored proxy_cache and friends. The configuration handling code has changed to look similar to the proxy_store directive and friends. This simplifies adding variable support in the following patch. No functional changes.
author Valentin Bartenev <vbart@nginx.com>
date Mon, 22 Dec 2014 12:59:02 +0300
parents f2ff0aa89126
children 610832763648
comparison
equal deleted inserted replaced
5948:f2ff0aa89126 5949:634da79665d3
2350 * set by ngx_pcalloc(): 2350 * set by ngx_pcalloc():
2351 * 2351 *
2352 * conf->upstream.bufs.num = 0; 2352 * conf->upstream.bufs.num = 0;
2353 * conf->upstream.ignore_headers = 0; 2353 * conf->upstream.ignore_headers = 0;
2354 * conf->upstream.next_upstream = 0; 2354 * conf->upstream.next_upstream = 0;
2355 * conf->upstream.cache_zone = NULL;
2355 * conf->upstream.cache_use_stale = 0; 2356 * conf->upstream.cache_use_stale = 0;
2356 * conf->upstream.cache_methods = 0; 2357 * conf->upstream.cache_methods = 0;
2357 * conf->upstream.temp_path = NULL; 2358 * conf->upstream.temp_path = NULL;
2358 * conf->upstream.hide_headers_hash = { NULL, 0 }; 2359 * conf->upstream.hide_headers_hash = { NULL, 0 };
2359 * conf->upstream.uri = { 0, NULL }; 2360 * conf->upstream.uri = { 0, NULL };
2388 2389
2389 conf->upstream.pass_request_headers = NGX_CONF_UNSET; 2390 conf->upstream.pass_request_headers = NGX_CONF_UNSET;
2390 conf->upstream.pass_request_body = NGX_CONF_UNSET; 2391 conf->upstream.pass_request_body = NGX_CONF_UNSET;
2391 2392
2392 #if (NGX_HTTP_CACHE) 2393 #if (NGX_HTTP_CACHE)
2393 conf->upstream.cache = NGX_CONF_UNSET_PTR; 2394 conf->upstream.cache = NGX_CONF_UNSET;
2394 conf->upstream.cache_min_uses = NGX_CONF_UNSET_UINT; 2395 conf->upstream.cache_min_uses = NGX_CONF_UNSET_UINT;
2395 conf->upstream.cache_bypass = NGX_CONF_UNSET_PTR; 2396 conf->upstream.cache_bypass = NGX_CONF_UNSET_PTR;
2396 conf->upstream.no_cache = NGX_CONF_UNSET_PTR; 2397 conf->upstream.no_cache = NGX_CONF_UNSET_PTR;
2397 conf->upstream.cache_valid = NGX_CONF_UNSET_PTR; 2398 conf->upstream.cache_valid = NGX_CONF_UNSET_PTR;
2398 conf->upstream.cache_lock = NGX_CONF_UNSET; 2399 conf->upstream.cache_lock = NGX_CONF_UNSET;
2433 ngx_http_core_loc_conf_t *clcf; 2434 ngx_http_core_loc_conf_t *clcf;
2434 2435
2435 #if (NGX_HTTP_CACHE) 2436 #if (NGX_HTTP_CACHE)
2436 2437
2437 if (conf->upstream.store > 0) { 2438 if (conf->upstream.store > 0) {
2438 conf->upstream.cache = NULL; 2439 conf->upstream.cache = 0;
2439 } 2440 }
2440 2441
2441 if (conf->upstream.cache != NGX_CONF_UNSET_PTR 2442 if (conf->upstream.cache > 0) {
2442 && conf->upstream.cache != NULL)
2443 {
2444 conf->upstream.store = 0; 2443 conf->upstream.store = 0;
2445 } 2444 }
2446 2445
2447 #endif 2446 #endif
2448 2447
2611 return NGX_CONF_ERROR; 2610 return NGX_CONF_ERROR;
2612 } 2611 }
2613 2612
2614 #if (NGX_HTTP_CACHE) 2613 #if (NGX_HTTP_CACHE)
2615 2614
2616 ngx_conf_merge_ptr_value(conf->upstream.cache, 2615 if (conf->upstream.cache == NGX_CONF_UNSET) {
2617 prev->upstream.cache, NULL); 2616 ngx_conf_merge_value(conf->upstream.cache,
2618 2617 prev->upstream.cache, 0);
2619 if (conf->upstream.cache && conf->upstream.cache->data == NULL) { 2618
2619 conf->upstream.cache_zone = prev->upstream.cache_zone;
2620 }
2621
2622 if (conf->upstream.cache_zone && conf->upstream.cache_zone->data == NULL) {
2620 ngx_shm_zone_t *shm_zone; 2623 ngx_shm_zone_t *shm_zone;
2621 2624
2622 shm_zone = conf->upstream.cache; 2625 shm_zone = conf->upstream.cache_zone;
2623 2626
2624 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0, 2627 ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
2625 "\"fastcgi_cache\" zone \"%V\" is unknown", 2628 "\"fastcgi_cache\" zone \"%V\" is unknown",
2626 &shm_zone->shm.name); 2629 &shm_zone->shm.name);
2627 2630
3228 flcf->upstream.store = 0; 3231 flcf->upstream.store = 0;
3229 return NGX_CONF_OK; 3232 return NGX_CONF_OK;
3230 } 3233 }
3231 3234
3232 #if (NGX_HTTP_CACHE) 3235 #if (NGX_HTTP_CACHE)
3233 3236 if (flcf->upstream.cache > 0) {
3234 if (flcf->upstream.cache != NGX_CONF_UNSET_PTR
3235 && flcf->upstream.cache != NULL)
3236 {
3237 return "is incompatible with \"fastcgi_cache\""; 3237 return "is incompatible with \"fastcgi_cache\"";
3238 } 3238 }
3239
3240 #endif 3239 #endif
3241 3240
3242 flcf->upstream.store = 1; 3241 flcf->upstream.store = 1;
3243 3242
3244 if (ngx_strcmp(value[1].data, "on") == 0) { 3243 if (ngx_strcmp(value[1].data, "on") == 0) {
3275 3274
3276 ngx_str_t *value; 3275 ngx_str_t *value;
3277 3276
3278 value = cf->args->elts; 3277 value = cf->args->elts;
3279 3278
3280 if (flcf->upstream.cache != NGX_CONF_UNSET_PTR) { 3279 if (flcf->upstream.cache != NGX_CONF_UNSET) {
3281 return "is duplicate"; 3280 return "is duplicate";
3282 } 3281 }
3283 3282
3284 if (ngx_strcmp(value[1].data, "off") == 0) { 3283 if (ngx_strcmp(value[1].data, "off") == 0) {
3285 flcf->upstream.cache = NULL; 3284 flcf->upstream.cache = 0;
3286 return NGX_CONF_OK; 3285 return NGX_CONF_OK;
3287 } 3286 }
3288 3287
3289 if (flcf->upstream.store > 0) { 3288 if (flcf->upstream.store > 0) {
3290 return "is incompatible with \"fastcgi_store\""; 3289 return "is incompatible with \"fastcgi_store\"";
3291 } 3290 }
3292 3291
3293 flcf->upstream.cache = ngx_shared_memory_add(cf, &value[1], 0, 3292 flcf->upstream.cache = 1;
3294 &ngx_http_fastcgi_module); 3293
3295 if (flcf->upstream.cache == NULL) { 3294 flcf->upstream.cache_zone = ngx_shared_memory_add(cf, &value[1], 0,
3295 &ngx_http_fastcgi_module);
3296 if (flcf->upstream.cache_zone == NULL) {
3296 return NGX_CONF_ERROR; 3297 return NGX_CONF_ERROR;
3297 } 3298 }
3298 3299
3299 return NGX_CONF_OK; 3300 return NGX_CONF_OK;
3300 } 3301 }