# HG changeset patch # User Igor Sysoev # Date 1251458630 0 # Node ID d22afd261e72af456ee9e98c189ce83135017156 # Parent 92b6cfaa3c27103c25f0fd2f31a4074e178287fc do not create cache key in AIO invocation diff --git a/src/http/ngx_http_upstream.c b/src/http/ngx_http_upstream.c --- a/src/http/ngx_http_upstream.c +++ b/src/http/ngx_http_upstream.c @@ -380,6 +380,10 @@ ngx_http_upstream_create(ngx_http_reques u->peer.lock = &r->connection->lock; #endif +#if (NGX_HTTP_CACHE) + r->cache = NULL; +#endif + return NGX_OK; } @@ -607,42 +611,47 @@ ngx_http_upstream_cache(ngx_http_request ngx_int_t rc; ngx_http_cache_t *c; - if (!(r->method & u->conf->cache_methods)) { - return NGX_DECLINED; - } - - if (r->method & NGX_HTTP_HEAD) { - u->method = ngx_http_core_get_method; - } - - c = ngx_pcalloc(r->pool, sizeof(ngx_http_cache_t)); + c = r->cache; + if (c == NULL) { - return NGX_ERROR; - } - - if (ngx_array_init(&c->keys, r->pool, 4, sizeof(ngx_str_t)) != NGX_OK) { - return NGX_ERROR; + + if (!(r->method & u->conf->cache_methods)) { + return NGX_DECLINED; + } + + if (r->method & NGX_HTTP_HEAD) { + u->method = ngx_http_core_get_method; + } + + c = ngx_pcalloc(r->pool, sizeof(ngx_http_cache_t)); + if (c == NULL) { + return NGX_ERROR; + } + + if (ngx_array_init(&c->keys, r->pool, 4, sizeof(ngx_str_t)) != NGX_OK) { + return NGX_ERROR; + } + + r->cache = c; + c->file.log = r->connection->log; + + if (u->create_key(r) != NGX_OK) { + return NGX_ERROR; + } + + /* TODO: add keys */ + + ngx_http_file_cache_create_key(r); + + u->cacheable = 1; + + c->min_uses = u->conf->cache_min_uses; + c->body_start = u->conf->buffer_size; + c->file_cache = u->conf->cache->data; + + u->cache_status = NGX_HTTP_CACHE_MISS; } - r->cache = c; - c->file.log = r->connection->log; - - if (u->create_key(r) != NGX_OK) { - return NGX_ERROR; - } - - /* TODO: add keys */ - - ngx_http_file_cache_create_key(r); - - u->cacheable = 1; - - c->min_uses = u->conf->cache_min_uses; - c->body_start = u->conf->buffer_size; - c->file_cache = u->conf->cache->data; - - u->cache_status = NGX_HTTP_CACHE_MISS; - rc = ngx_http_file_cache_open(r); ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,