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

Jiří Setnička jiri.setnicka at cdn77.com
Mon Feb 7 11:18:52 UTC 2022


Hello!

> Thanks for sharing patches. It's interesting for me and I'm going to 
> test it soon.

Did you already had some time to test it? I am interested in you 
thoughts and results :)

> 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 
> <http://file.name>);
>     if (rc != NGX_DECLINED) {
>         return rc;


Yes, this is of course better, thank you.

Jiří Setnička
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20220207/8d6bbb37/attachment.htm>


More information about the nginx-devel mailing list