[nginx] Disabled open_file_cache on platforms without pread().
Maxim Dounin
mdounin at mdounin.ru
Wed Jun 4 23:37:03 UTC 2025
details: http://freenginx.org/hg/nginx/rev/5249bce09d1f
branches:
changeset: 9363:5249bce09d1f
user: Maxim Dounin <mdounin at mdounin.ru>
date: Thu Jun 05 02:16:42 2025 +0300
description:
Disabled open_file_cache on platforms without pread().
Current open file cache code cannot properly work on platforms without
pread(), since file->sys_offset is not shared across files. Further, it
is not set on file initialization after ngx_open_cached_file(), leading
to incorrect value 0 instead of non-zero current offset for cached file
descriptors.
Since platforms without pread() are rather exotic nowadays, fix is to
disable open_file_cache for them.
diffstat:
src/http/ngx_http_core_module.c | 18 +++++++++++++-----
1 files changed, 13 insertions(+), 5 deletions(-)
diffs (35 lines):
diff --git a/src/http/ngx_http_core_module.c b/src/http/ngx_http_core_module.c
--- a/src/http/ngx_http_core_module.c
+++ b/src/http/ngx_http_core_module.c
@@ -4981,6 +4981,8 @@ ngx_http_core_error_page(ngx_conf_t *cf,
static char *
ngx_http_core_open_file_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
{
+#if (NGX_HAVE_PREAD || NGX_WIN32)
+
ngx_http_core_loc_conf_t *clcf = conf;
time_t inactive;
@@ -5048,11 +5050,17 @@ ngx_http_core_open_file_cache(ngx_conf_t
}
clcf->open_file_cache = ngx_open_file_cache_init(cf->pool, max, inactive);
- if (clcf->open_file_cache) {
- return NGX_CONF_OK;
- }
-
- return NGX_CONF_ERROR;
+ if (clcf->open_file_cache == NULL) {
+ return NGX_CONF_ERROR;
+ }
+
+#else
+ ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
+ "\"open_file_cache\" is not supported "
+ "on this platform, ignored");
+#endif
+
+ return NGX_CONF_OK;
}
More information about the nginx-devel
mailing list