# HG changeset patch # User Jiří Setnička <jiri.setni...@cdn77.com> # Date 1643385660 -3600 # Fri Jan 28 17:01:00 2022 +0100 # Node ID 0e00ffe7fab3dcf3d3167851237327e5fb9e10b6 # Parent 64a2e216aeeeb847eb0b9a83ed6e6082ade4ac9e Tempfiles: Expired tempfiles When tempfile expires before it is downloaded we try to fire one request to download newer version of the tempfile and remain other requests locked.
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 @@ -939,10 +939,15 @@ ngx_http_file_cache_read(ngx_http_reques ngx_shmtx_lock(&cache->shpool->mutex); - if (c->node->updating) { + /* If serving tempfile and it is already expired try to download a new + * one (but only if not downloading it already) */ + if (c->node->updating + && (!c->tf_node || c->node->tf_number != c->tf_node->node.key) + ) { rc = NGX_HTTP_CACHE_UPDATING; } else { + c->node->tf_number = 0; c->node->updating = 1; c->updating = 1; c->node->lock_time = ngx_current_msec + (c->lock ? c->lock_age : c->tempfile_timeout); @@ -1791,8 +1796,10 @@ ngx_http_file_cache_update(ngx_http_requ ngx_http_file_cache_tf_delete(c, cache); } - c->node->updating = 0; - c->node->tf_number = 0; + if (c->node->lock_time == c->lock_time) { + c->node->updating = 0; + c->node->tf_number = 0; + } ngx_shmtx_unlock(&cache->shpool->mutex); } _______________________________________________ nginx-devel mailing list -- nginx-devel@nginx.org To unsubscribe send an email to nginx-devel-le...@nginx.org