[PATCH 4 of 5] Open file cache: fixed file->uses loss on retest
Maxim Dounin
mdounin at mdounin.ru
Sun May 25 21:29:18 UTC 2025
# HG changeset patch
# User Maxim Dounin <mdounin at mdounin.ru>
# Date 1748208430 -10800
# Mon May 26 00:27:10 2025 +0300
# Node ID 6032949667f1e5fda9ce364d6eb1668074274c56
# Parent f84080a83901176c0dd95681b19290f070de045c
Open file cache: fixed file->uses loss on retest.
If an open file was reopened during a retest, but was in use by another
request, the cache entry was re-created with file->uses set to 1. Fix
is to preserve existing file->uses.
diff --git a/src/core/ngx_open_file_cache.c b/src/core/ngx_open_file_cache.c
--- a/src/core/ngx_open_file_cache.c
+++ b/src/core/ngx_open_file_cache.c
@@ -147,6 +147,7 @@ ngx_open_cached_file(ngx_open_file_cache
time_t now;
uint32_t hash;
ngx_int_t rc;
+ ngx_uint_t uses;
ngx_file_info_t fi;
ngx_pool_cleanup_t *cln;
ngx_cached_open_file_t *file;
@@ -348,6 +349,8 @@ ngx_open_cached_file(ngx_open_file_cache
file->close = 1;
+ uses = file->uses;
+
goto create;
}
@@ -359,6 +362,8 @@ ngx_open_cached_file(ngx_open_file_cache
goto failed;
}
+ uses = 1;
+
create:
if (cache->current >= cache->max) {
@@ -387,7 +392,7 @@ create:
cache->current++;
- file->uses = 1;
+ file->uses = uses;
file->count = 0;
file->use_event = 0;
file->event = NULL;
More information about the nginx-devel
mailing list