[PATCH 13 of 15] Tempfiles: Skip cached file if there is already newer tempfile

Jiří Setnička jiri.setnicka at cdn77.com
Fri Jan 28 16:32:05 UTC 2022


# HG changeset patch
# User Jiří Setnička  <jiri.setnicka at cdn77.com>
# Date 1643385660 -3600
#      Fri Jan 28 17:01:00 2022 +0100
# Node ID 5e64af4c94860cd5cf4b9af5a265d3a087e7b735
# Parent  0e00ffe7fab3dcf3d3167851237327e5fb9e10b6
Tempfiles: Skip cached file if there is already newer tempfile

diff --git a/src/http/ngx_http_file_cache.c b/src/http/ngx_http_file_cache.c
--- a/src/http/ngx_http_file_cache.c
+++ b/src/http/ngx_http_file_cache.c
@@ -455,6 +455,20 @@ ngx_http_file_cache_open(ngx_http_reques
         goto done;
     }
 
+    ngx_shmtx_lock(&cache->shpool->mutex);
+
+    if (c->serve_tempfile && c->node->updating) {
+        /* Do not try old cached file, jump directly to cache_lock and use tempfile */
+        test = 0;
+    }
+
+    ngx_shmtx_unlock(&cache->shpool->mutex);
+
+    if (!test) {
+        rv = NGX_DECLINED;
+        goto done;
+    }
+
     rc = ngx_http_file_cache_open_file(r, &c->file.name);
     if (rc != NGX_DECLINED) {
         return rc;


More information about the nginx-devel mailing list