comparison src/http/ngx_http_upstream.c @ 3056:d22afd261e72

do not create cache key in AIO invocation
author Igor Sysoev <igor@sysoev.ru>
date Fri, 28 Aug 2009 11:23:50 +0000
parents 92b6cfaa3c27
children ffe8bfb38184
comparison
equal deleted inserted replaced
3055:92b6cfaa3c27 3056:d22afd261e72
378 u->peer.log_error = NGX_ERROR_ERR; 378 u->peer.log_error = NGX_ERROR_ERR;
379 #if (NGX_THREADS) 379 #if (NGX_THREADS)
380 u->peer.lock = &r->connection->lock; 380 u->peer.lock = &r->connection->lock;
381 #endif 381 #endif
382 382
383 #if (NGX_HTTP_CACHE)
384 r->cache = NULL;
385 #endif
386
383 return NGX_OK; 387 return NGX_OK;
384 } 388 }
385 389
386 390
387 void 391 void
605 ngx_http_upstream_cache(ngx_http_request_t *r, ngx_http_upstream_t *u) 609 ngx_http_upstream_cache(ngx_http_request_t *r, ngx_http_upstream_t *u)
606 { 610 {
607 ngx_int_t rc; 611 ngx_int_t rc;
608 ngx_http_cache_t *c; 612 ngx_http_cache_t *c;
609 613
610 if (!(r->method & u->conf->cache_methods)) { 614 c = r->cache;
611 return NGX_DECLINED; 615
612 }
613
614 if (r->method & NGX_HTTP_HEAD) {
615 u->method = ngx_http_core_get_method;
616 }
617
618 c = ngx_pcalloc(r->pool, sizeof(ngx_http_cache_t));
619 if (c == NULL) { 616 if (c == NULL) {
620 return NGX_ERROR; 617
621 } 618 if (!(r->method & u->conf->cache_methods)) {
622 619 return NGX_DECLINED;
623 if (ngx_array_init(&c->keys, r->pool, 4, sizeof(ngx_str_t)) != NGX_OK) { 620 }
624 return NGX_ERROR; 621
625 } 622 if (r->method & NGX_HTTP_HEAD) {
626 623 u->method = ngx_http_core_get_method;
627 r->cache = c; 624 }
628 c->file.log = r->connection->log; 625
629 626 c = ngx_pcalloc(r->pool, sizeof(ngx_http_cache_t));
630 if (u->create_key(r) != NGX_OK) { 627 if (c == NULL) {
631 return NGX_ERROR; 628 return NGX_ERROR;
632 } 629 }
633 630
634 /* TODO: add keys */ 631 if (ngx_array_init(&c->keys, r->pool, 4, sizeof(ngx_str_t)) != NGX_OK) {
635 632 return NGX_ERROR;
636 ngx_http_file_cache_create_key(r); 633 }
637 634
638 u->cacheable = 1; 635 r->cache = c;
639 636 c->file.log = r->connection->log;
640 c->min_uses = u->conf->cache_min_uses; 637
641 c->body_start = u->conf->buffer_size; 638 if (u->create_key(r) != NGX_OK) {
642 c->file_cache = u->conf->cache->data; 639 return NGX_ERROR;
643 640 }
644 u->cache_status = NGX_HTTP_CACHE_MISS; 641
642 /* TODO: add keys */
643
644 ngx_http_file_cache_create_key(r);
645
646 u->cacheable = 1;
647
648 c->min_uses = u->conf->cache_min_uses;
649 c->body_start = u->conf->buffer_size;
650 c->file_cache = u->conf->cache->data;
651
652 u->cache_status = NGX_HTTP_CACHE_MISS;
653 }
645 654
646 rc = ngx_http_file_cache_open(r); 655 rc = ngx_http_file_cache_open(r);
647 656
648 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 657 ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
649 "http upstream cache: %i", rc); 658 "http upstream cache: %i", rc);