comparison src/http/modules/proxy/ngx_http_proxy_handler.c @ 174:ea464a6c0581

nginx-0.0.1-2003-11-05-01:12:39 import
author Igor Sysoev <igor@sysoev.ru>
date Tue, 04 Nov 2003 22:12:39 +0000
parents caa57ddf6d77
children e92c2c647c57
comparison
equal deleted inserted replaced
173:4fb2a2cff023 174:ea464a6c0581
126 { ngx_string("proxy_cache"), 126 { ngx_string("proxy_cache"),
127 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, 127 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
128 ngx_conf_set_flag_slot, 128 ngx_conf_set_flag_slot,
129 NGX_HTTP_LOC_CONF_OFFSET, 129 NGX_HTTP_LOC_CONF_OFFSET,
130 offsetof(ngx_http_proxy_loc_conf_t, cache), 130 offsetof(ngx_http_proxy_loc_conf_t, cache),
131 NULL },
132
133
134 { ngx_string("proxy_busy_lock"),
135 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE3,
136 ngx_http_set_busy_lock_slot,
137 NGX_HTTP_LOC_CONF_OFFSET,
138 offsetof(ngx_http_proxy_loc_conf_t, busy_lock),
131 NULL }, 139 NULL },
132 140
133 141
134 { ngx_string("proxy_pass_server"), 142 { ngx_string("proxy_pass_server"),
135 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG, 143 NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_FLAG,
253 261
254 if (!(p->state = ngx_push_array(&p->states))) { 262 if (!(p->state = ngx_push_array(&p->states))) {
255 return NGX_HTTP_INTERNAL_SERVER_ERROR; 263 return NGX_HTTP_INTERNAL_SERVER_ERROR;
256 } 264 }
257 265
266 ngx_memzero(p->state, sizeof(ngx_http_proxy_state_t));
267
258 268
259 if (!p->lcf->cache) { 269 if (!p->lcf->cache) {
260 p->state->cache = NGX_HTTP_PROXY_CACHE_PASS; 270 p->state->cache = NGX_HTTP_PROXY_CACHE_PASS;
261 271
262 } else if (r->bypass_cache) { 272 } else if (r->bypass_cache) {
277 if (p->state->cache) { 287 if (p->state->cache) {
278 return ngx_http_proxy_request_upstream(p); 288 return ngx_http_proxy_request_upstream(p);
279 } 289 }
280 290
281 rc = ngx_http_proxy_get_cached_response(p); 291 rc = ngx_http_proxy_get_cached_response(p);
292
293 p->valid_header_in = 1;
282 294
283 if (rc == NGX_OK) { 295 if (rc == NGX_OK) {
284 return ngx_http_proxy_send_cached_response(p); 296 return ngx_http_proxy_send_cached_response(p);
285 } 297 }
286 298
404 conf->peers = NULL; 416 conf->peers = NULL;
405 417
406 conf->cache_path = NULL; 418 conf->cache_path = NULL;
407 conf->temp_path = NULL; 419 conf->temp_path = NULL;
408 420
421 conf->busy_lock = NULL;
422
409 */ 423 */
410 424
411 conf->request_buffer_size = NGX_CONF_UNSET; 425 conf->request_buffer_size = NGX_CONF_UNSET;
412 conf->connect_timeout = NGX_CONF_UNSET; 426 conf->connect_timeout = NGX_CONF_UNSET;
413 conf->send_timeout = NGX_CONF_UNSET; 427 conf->send_timeout = NGX_CONF_UNSET;
480 ngx_conf_merge_path_value(conf->temp_path, prev->temp_path, 494 ngx_conf_merge_path_value(conf->temp_path, prev->temp_path,
481 "temp", 1, 2, 0, cf->pool); 495 "temp", 1, 2, 0, cf->pool);
482 496
483 ngx_conf_merge_value(conf->cache, prev->cache, 0); 497 ngx_conf_merge_value(conf->cache, prev->cache, 0);
484 498
499
500 /* conf->cache must be merged */
501
502 if (conf->busy_lock == NULL) {
503 conf->busy_lock = prev->busy_lock;
504 }
505
506 if (conf->busy_lock && conf->cache && conf->busy_lock->busy == NULL) {
507
508 /* 16 bytes are 128 bits of the md5 */
509
510 /* ngx_alloc_shared() */
511 conf->busy_lock->busy = ngx_palloc(cf->pool,
512 16 * conf->busy_lock->max_conn);
513 if (conf->busy_lock->busy == NULL) {
514 return NGX_CONF_ERROR;
515 }
516 }
517
518
485 ngx_conf_merge_value(conf->pass_server, prev->pass_server, 0); 519 ngx_conf_merge_value(conf->pass_server, prev->pass_server, 0);
486 ngx_conf_merge_value(conf->pass_x_accel_expires, 520 ngx_conf_merge_value(conf->pass_x_accel_expires,
487 prev->pass_x_accel_expires, 0); 521 prev->pass_x_accel_expires, 0);
488 ngx_conf_merge_value(conf->ignore_expires, prev->ignore_expires, 0); 522 ngx_conf_merge_value(conf->ignore_expires, prev->ignore_expires, 0);
489 ngx_conf_merge_value(conf->lm_factor, prev->lm_factor, 0); 523 ngx_conf_merge_value(conf->lm_factor, prev->lm_factor, 0);