comparison src/http/ngx_http_file_cache.c @ 496:116d5de7cbb6 NGINX_0_7_60

nginx 0.7.60 *) Feature: the "updating" parameter in "proxy_cache_use_stale" and "fastcgi_cache_use_stale" directives. *) Feature: the "keepalive_requests" directive. *) Bugfix: in open_file_cache and proxy/fastcgi cache interaction on start up. *) Bugfix: open_file_cache might cache open file descriptors too long. *) Bugfix: the "If-Modified-Since", "If-Range", etc. client request header lines were passed to backend while caching if no "proxy_set_header" directive was used with any parameters. *) Bugfix: the "Set-Cookie" and "P3P" response header lines were not hidden while caching if no "proxy_hide_header/fastcgi_hide_header" directives were used with any parameters. *) Bugfix: the ngx_http_image_filter_module did not support GIF87a format. Thanks to Denis Ilyinyh. *) Bugfix: nginx could not be built modules on Solaris 10 and early; the bug had appeared in 0.7.56. *) Bugfix: XLST filter did not work in subrequests. *) Bugfix: in relative paths handling in nginx/Windows. *) Bugfix: in proxy_store, fastcgi_store, proxy_cache, and fastcgi_cache in nginx/Windows.
author Igor Sysoev <http://sysoev.ru>
date Mon, 15 Jun 2009 00:00:00 +0400
parents 549994537f15
children ed3d382670c7
comparison
equal deleted inserted replaced
495:6d9fb4461113 496:116d5de7cbb6
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) {