Mercurial > hg > nginx-quic
comparison src/http/ngx_http_file_cache.c @ 2944:f892042956e3 stable-0.7
merge r2895, r2896, r2926, r2927, r2928, r2930, and r2936:
various proxy/fastcgi cache features and fixes:
*) report about proxy/fastcgi_store and proxy/fastcgi_cache incompatibility
*) delete useless r->cache->uses
*) proxy_cache_use_stale/fastcgi_cache_use_stale updating
*) inherit proxy_set_header, proxy_hide_header, and fastcgi_hide_header
only if cache settings are similar
*) add response file uniq while loading cold cache on demand
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 15 Jun 2009 09:30:59 +0000 |
parents | b3b8c66bd520 |
children | 4f28e63e42b4 |
comparison
equal
deleted
inserted
replaced
2943:5da043342fe4 | 2944:f892042956e3 |
---|---|
170 return NGX_ERROR; | 170 return NGX_ERROR; |
171 } | 171 } |
172 | 172 |
173 rc = ngx_http_file_cache_exists(cache, c); | 173 rc = ngx_http_file_cache_exists(cache, c); |
174 | 174 |
175 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 175 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, |
176 "http file cache exists: %i u:%ui e:%d", | 176 "http file cache exists: %i e:%d", rc, c->exists); |
177 rc, c->uses, c->exists); | |
178 | 177 |
179 if (rc == NGX_ERROR) { | 178 if (rc == NGX_ERROR) { |
180 return rc; | 179 return rc; |
181 } | 180 } |
182 | 181 |
319 | 318 |
320 if (!c->node->exists) { | 319 if (!c->node->exists) { |
321 c->node->uses = 1; | 320 c->node->uses = 1; |
322 c->node->body_start = c->body_start; | 321 c->node->body_start = c->body_start; |
323 c->node->exists = 1; | 322 c->node->exists = 1; |
323 c->node->uniq = of.uniq; | |
324 | 324 |
325 cache->sh->size += (c->length + cache->bsize - 1) / cache->bsize; | 325 cache->sh->size += (c->length + cache->bsize - 1) / cache->bsize; |
326 } | 326 } |
327 | 327 |
328 ngx_shmtx_unlock(&cache->shpool->mutex); | 328 ngx_shmtx_unlock(&cache->shpool->mutex); |
330 | 330 |
331 now = ngx_time(); | 331 now = ngx_time(); |
332 | 332 |
333 if (c->valid_sec < now) { | 333 if (c->valid_sec < now) { |
334 | 334 |
335 c->uses = c->min_uses; | 335 ngx_shmtx_lock(&cache->shpool->mutex); |
336 | 336 |
337 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | 337 if (c->node->updating) { |
338 "http file cache expired: %T %T", c->valid_sec, now); | 338 rc = NGX_HTTP_CACHE_UPDATING; |
339 | 339 |
340 return NGX_HTTP_CACHE_STALE; | 340 } else { |
341 } | 341 c->node->updating = 1; |
342 | 342 rc = NGX_HTTP_CACHE_STALE; |
343 /* TODO: NGX_HTTP_CACHE_AGED */ | 343 } |
344 | |
345 ngx_shmtx_unlock(&cache->shpool->mutex); | |
346 | |
347 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, | |
348 "http file cache expired: %i %T %T", | |
349 rc, c->valid_sec, now); | |
350 | |
351 return rc; | |
352 } | |
344 | 353 |
345 return NGX_OK; | 354 return NGX_OK; |
346 } | 355 } |
347 | 356 |
348 | 357 |
440 fcn->expire = ngx_time() + cache->inactive; | 449 fcn->expire = ngx_time() + cache->inactive; |
441 | 450 |
442 ngx_queue_insert_head(&cache->sh->queue, &fcn->queue); | 451 ngx_queue_insert_head(&cache->sh->queue, &fcn->queue); |
443 | 452 |
444 c->uniq = fcn->uniq; | 453 c->uniq = fcn->uniq; |
445 c->uses = fcn->uses; | |
446 c->error = fcn->error; | 454 c->error = fcn->error; |
447 c->node = fcn; | 455 c->node = fcn; |
448 | 456 |
449 failed: | 457 failed: |
450 | 458 |
652 | 660 |
653 if (rc == NGX_OK) { | 661 if (rc == NGX_OK) { |
654 c->node->exists = 1; | 662 c->node->exists = 1; |
655 } | 663 } |
656 | 664 |
665 c->node->updating = 0; | |
666 | |
657 ngx_shmtx_unlock(&cache->shpool->mutex); | 667 ngx_shmtx_unlock(&cache->shpool->mutex); |
658 } | 668 } |
659 | 669 |
660 | 670 |
661 ngx_int_t | 671 ngx_int_t |
733 if (c->error) { | 743 if (c->error) { |
734 c->node->valid_sec = c->valid_sec; | 744 c->node->valid_sec = c->valid_sec; |
735 c->node->valid_msec = c->valid_msec; | 745 c->node->valid_msec = c->valid_msec; |
736 c->node->error = c->error; | 746 c->node->error = c->error; |
737 } | 747 } |
748 | |
749 c->node->updating = 0; | |
738 | 750 |
739 ngx_shmtx_unlock(&cache->shpool->mutex); | 751 ngx_shmtx_unlock(&cache->shpool->mutex); |
740 | 752 |
741 if (c->temp_file) { | 753 if (c->temp_file) { |
742 if (tf && tf->file.fd != NGX_INVALID_FILE) { | 754 if (tf && tf->file.fd != NGX_INVALID_FILE) { |