[PATCH 13 of 15] Tempfiles: Skip cached file if there is already newer tempfile
Vadim Fedorenko
vadimjunk at gmail.com
Mon Jan 31 00:37:10 UTC 2022
Hi!
Thanks for sharing patches. It's interesting for me and I'm going to test
it soon.
For this particular patch I would suggest to reduce the scope of mutex
locking
and remove it when "serve_tempfile" is not configured. See my version below:
diff --git a/src/http/ngx_http_file_cache.c b/src/http/ngx_http_file_cache.c
index db379450..97982aed 100644
--- a/src/http/ngx_http_file_cache.c
+++ b/src/http/ngx_http_file_cache.c
@@ -460,6 +460,22 @@ ngx_http_file_cache_open(ngx_http_request_t *r)
goto done;
}
+ if (c->serve_tempfile) {
+ ngx_shmtx_lock(&cache->shpool->mutex);
+
+ if (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;
Best wishes,
Vadim
пт, 28 янв. 2022 г. в 17:00, Jiří Setnička via nginx-devel <
nginx-devel at nginx.org>:
> # 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;
> _______________________________________________
> nginx-devel mailing list -- nginx-devel at nginx.org
> To unsubscribe send an email to nginx-devel-leave at nginx.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20220131/dfb68ac5/attachment.htm>
More information about the nginx-devel
mailing list