comparison src/http/ngx_http_file_cache.c @ 2927:55ceaef03d34

proxy_cache_use_stale/fastcgi_cache_use_stale updating
author Igor Sysoev <igor@sysoev.ru>
date Sat, 06 Jun 2009 18:49:47 +0000
parents 80a314b63c56
children 92cc13f7487d
comparison
equal deleted inserted replaced
2926:80a314b63c56 2927:55ceaef03d34
329 329
330 now = ngx_time(); 330 now = ngx_time();
331 331
332 if (c->valid_sec < now) { 332 if (c->valid_sec < now) {
333 333
334 ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, 334 ngx_shmtx_lock(&cache->shpool->mutex);
335 "http file cache expired: %T %T", c->valid_sec, now); 335
336 336 if (c->node->updating) {
337 return NGX_HTTP_CACHE_STALE; 337 rc = NGX_HTTP_CACHE_UPDATING;
338
339 } else {
340 c->node->updating = 1;
341 rc = NGX_HTTP_CACHE_STALE;
342 }
343
344 ngx_shmtx_unlock(&cache->shpool->mutex);
345
346 ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
347 "http file cache expired: %i %T %T",
348 rc, c->valid_sec, now);
349
350 return rc;
338 } 351 }
339 352
340 return NGX_OK; 353 return NGX_OK;
341 } 354 }
342 355
646 659
647 if (rc == NGX_OK) { 660 if (rc == NGX_OK) {
648 c->node->exists = 1; 661 c->node->exists = 1;
649 } 662 }
650 663
664 c->node->updating = 0;
665
651 ngx_shmtx_unlock(&cache->shpool->mutex); 666 ngx_shmtx_unlock(&cache->shpool->mutex);
652 } 667 }
653 668
654 669
655 ngx_int_t 670 ngx_int_t
727 if (c->error) { 742 if (c->error) {
728 c->node->valid_sec = c->valid_sec; 743 c->node->valid_sec = c->valid_sec;
729 c->node->valid_msec = c->valid_msec; 744 c->node->valid_msec = c->valid_msec;
730 c->node->error = c->error; 745 c->node->error = c->error;
731 } 746 }
747
748 c->node->updating = 0;
732 749
733 ngx_shmtx_unlock(&cache->shpool->mutex); 750 ngx_shmtx_unlock(&cache->shpool->mutex);
734 751
735 if (c->temp_file) { 752 if (c->temp_file) {
736 if (tf && tf->file.fd != NGX_INVALID_FILE) { 753 if (tf && tf->file.fd != NGX_INVALID_FILE) {