Skip to content

Commit de3fbf3

Browse files
committed
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.
1 parent 1d5a658 commit de3fbf3

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/http/ngx_http_core_module.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4981,6 +4981,8 @@ ngx_http_core_error_page(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
49814981
static char *
49824982
ngx_http_core_open_file_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
49834983
{
4984+
#if (NGX_HAVE_PREAD || NGX_WIN32)
4985+
49844986
ngx_http_core_loc_conf_t *clcf = conf;
49854987

49864988
time_t inactive;
@@ -5048,11 +5050,17 @@ ngx_http_core_open_file_cache(ngx_conf_t *cf, ngx_command_t *cmd, void *conf)
50485050
}
50495051

50505052
clcf->open_file_cache = ngx_open_file_cache_init(cf->pool, max, inactive);
5051-
if (clcf->open_file_cache) {
5052-
return NGX_CONF_OK;
5053+
if (clcf->open_file_cache == NULL) {
5054+
return NGX_CONF_ERROR;
50535055
}
50545056

5055-
return NGX_CONF_ERROR;
5057+
#else
5058+
ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
5059+
"\"open_file_cache\" is not supported "
5060+
"on this platform, ignored");
5061+
#endif
5062+
5063+
return NGX_CONF_OK;
50565064
}
50575065

50585066

0 commit comments

Comments
 (0)