Mercurial > hg > nginx
changeset 3195:b495a56f1f24
use real file cache length, this fixes cache size counting for responses
without "Content-Length" header and 304 responses.
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 07 Oct 2009 12:55:58 +0000 |
parents | 9966af1d5819 |
children | b7e68ee09e0c |
files | src/http/ngx_http_file_cache.c src/http/ngx_http_upstream.c |
diffstat | 2 files changed, 5 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/src/http/ngx_http_file_cache.c Wed Oct 07 12:48:05 2009 +0000 +++ b/src/http/ngx_http_file_cache.c Wed Oct 07 12:55:58 2009 +0000 @@ -692,7 +692,7 @@ void ngx_http_file_cache_update(ngx_http_request_t *r, ngx_temp_file_t *tf) { - off_t size; + off_t size, length; ngx_int_t rc; ngx_file_uniq_t uniq; ngx_file_info_t fi; @@ -714,6 +714,7 @@ cache = c->file_cache; uniq = 0; + length = 0; ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "http file cache rename: \"%s\" to \"%s\"", @@ -738,10 +739,11 @@ } else { uniq = ngx_file_uniq(&fi); + length = ngx_file_size(&fi); } } - size = (c->length + cache->bsize - 1) / cache->bsize; + size = (length + cache->bsize - 1) / cache->bsize; ngx_shmtx_lock(&cache->shpool->mutex); @@ -751,7 +753,7 @@ size = size - (c->node->length + cache->bsize - 1) / cache->bsize; - c->node->length = c->length; + c->node->length = length; cache->sh->size += size;
--- a/src/http/ngx_http_upstream.c Wed Oct 07 12:48:05 2009 +0000 +++ b/src/http/ngx_http_upstream.c Wed Oct 07 12:55:58 2009 +0000 @@ -2098,11 +2098,6 @@ r->cache->date = now; r->cache->body_start = (u_short) (u->buffer.pos - u->buffer.start); - if (r->headers_out.content_length_n != -1) { - r->cache->length = r->cache->body_start - + r->headers_out.content_length_n; - } - ngx_http_file_cache_set_header(r, u->buffer.start); } else {