# HG changeset patch # User Maxim Dounin <mdou...@mdounin.ru> # Date 1748208420 -10800 # Mon May 26 00:27:00 2025 +0300 # Node ID 811bf7dc0d46e5e6d69e700a1a5a3852d4ba0381 # Parent e2a6fefd81dbe201a88876a95f34620df87259a2 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. 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; }