From a84b0f3f082025dec737a537a9a443bdd6d6af9d Mon Sep 17 00:00:00 2001 From: FedericoHeichou <34757141+FedericoHeichou@users.noreply.github.com> Date: Wed, 22 Feb 2023 06:08:16 +0100 Subject: [PATCH] Fix race-condition with two parallel PURGE (#42) --- ngx_cache_purge_module.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ngx_cache_purge_module.c b/ngx_cache_purge_module.c index 1ea54e4..251d3fe 100644 --- a/ngx_cache_purge_module.c +++ b/ngx_cache_purge_module.c @@ -1337,6 +1337,9 @@ ngx_http_purge_file_cache_delete_partial_file(ngx_tree_ctx_t *ctx, ngx_str_t *pa file.offset = file.sys_offset = 0; file.fd = ngx_open_file(path->data, NGX_FILE_RDONLY, NGX_FILE_OPEN, NGX_FILE_DEFAULT_ACCESS); + if (file.fd == -1) { + return NGX_OK; + } file.log = ctx->log; /* I don't know if it's a good idea to use the ngx_cycle pool for this,