--- a/ngx_http_slowfs_module.c 2013-03-07 17:01:55.000000000 +0400 +++ b/ngx_http_slowfs_module.c 2023-03-13 13:34:38.294577255 +0300 @@ -62,6 +62,12 @@ ngx_int_t ngx_http_slowfs_cache_status(ngx_http_request_t *, ngx_http_variable_value_t *, uintptr_t); +static void * ngx_http_slowfs_create_main_conf(ngx_conf_t *cf); + +typedef struct { + ngx_array_t caches; /* ngx_http_file_cache_t * */ +} ngx_http_slowfs_main_conf_t; + typedef struct { ngx_flag_t enabled; ngx_shm_zone_t *cache; @@ -108,8 +114,8 @@ { ngx_string("slowfs_cache_path"), NGX_HTTP_MAIN_CONF|NGX_CONF_2MORE, ngx_http_file_cache_set_slot, - 0, - 0, + NGX_HTTP_MAIN_CONF_OFFSET, + offsetof(ngx_http_slowfs_main_conf_t, caches), &ngx_http_slowfs_module }, { ngx_string("slowfs_cache_min_uses"), @@ -156,7 +162,7 @@ ngx_http_slowfs_add_variables, /* preconfiguration */ ngx_http_slowfs_init, /* postconfiguration */ - NULL, /* create main configuration */ + ngx_http_slowfs_create_main_conf, /* create main configuration */ NULL, /* init main configuration */ NULL, /* create server configuration */ @@ -1170,6 +1176,29 @@ return NGX_OK; } +static void * +ngx_http_slowfs_create_main_conf(ngx_conf_t *cf) +{ + ngx_http_slowfs_main_conf_t *conf; + + conf = ngx_pcalloc(cf->pool, sizeof(ngx_http_slowfs_main_conf_t)); + if (conf == NULL) { + return NULL; + } + +#if (NGX_HTTP_CACHE) + if (ngx_array_init(&conf->caches, cf->pool, 4, + sizeof(ngx_http_file_cache_t *)) + != NGX_OK) + { + return NULL; + } +#endif + + return conf; +} + + #else /* !NGX_HTTP_CACHE */