mirror of
https://github.com/nginx/nginx.git
synced 2026-05-13 09:36:42 +00:00
Cache: warn when cache_min_uses exceeds the uses bitfield range.
The "uses" counter on ngx_http_cache_node_t is a 10-bit field, so once
"{proxy,fastcgi,uwsgi,scgi}_cache_min_uses" is configured at 1024 or
greater the threshold can never be reached and caching is silently
disabled. Emit a config-time warning at the point where the directive
is set so the misconfiguration is visible without code reading.
This commit is contained in:
parent
1f57d8dc9d
commit
abd92d41ec
4 changed files with 36 additions and 0 deletions
|
|
@ -3166,6 +3166,15 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
if (conf->upstream.cache_min_uses != NGX_CONF_UNSET_UINT
|
||||
&& conf->upstream.cache_min_uses > 1023)
|
||||
{
|
||||
ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
|
||||
"\"fastcgi_cache_min_uses\" value %ui exceeds 1023 "
|
||||
"and effectively disables caching",
|
||||
conf->upstream.cache_min_uses);
|
||||
}
|
||||
|
||||
ngx_conf_merge_uint_value(conf->upstream.cache_min_uses,
|
||||
prev->upstream.cache_min_uses, 1);
|
||||
|
||||
|
|
|
|||
|
|
@ -3849,6 +3849,15 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
if (conf->upstream.cache_min_uses != NGX_CONF_UNSET_UINT
|
||||
&& conf->upstream.cache_min_uses > 1023)
|
||||
{
|
||||
ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
|
||||
"\"proxy_cache_min_uses\" value %ui exceeds 1023 "
|
||||
"and effectively disables caching",
|
||||
conf->upstream.cache_min_uses);
|
||||
}
|
||||
|
||||
ngx_conf_merge_uint_value(conf->upstream.cache_min_uses,
|
||||
prev->upstream.cache_min_uses, 1);
|
||||
|
||||
|
|
|
|||
|
|
@ -1579,6 +1579,15 @@ ngx_http_scgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
if (conf->upstream.cache_min_uses != NGX_CONF_UNSET_UINT
|
||||
&& conf->upstream.cache_min_uses > 1023)
|
||||
{
|
||||
ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
|
||||
"\"scgi_cache_min_uses\" value %ui exceeds 1023 "
|
||||
"and effectively disables caching",
|
||||
conf->upstream.cache_min_uses);
|
||||
}
|
||||
|
||||
ngx_conf_merge_uint_value(conf->upstream.cache_min_uses,
|
||||
prev->upstream.cache_min_uses, 1);
|
||||
|
||||
|
|
|
|||
|
|
@ -1839,6 +1839,15 @@ ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
|
|||
return NGX_CONF_ERROR;
|
||||
}
|
||||
|
||||
if (conf->upstream.cache_min_uses != NGX_CONF_UNSET_UINT
|
||||
&& conf->upstream.cache_min_uses > 1023)
|
||||
{
|
||||
ngx_conf_log_error(NGX_LOG_WARN, cf, 0,
|
||||
"\"uwsgi_cache_min_uses\" value %ui exceeds 1023 "
|
||||
"and effectively disables caching",
|
||||
conf->upstream.cache_min_uses);
|
||||
}
|
||||
|
||||
ngx_conf_merge_uint_value(conf->upstream.cache_min_uses,
|
||||
prev->upstream.cache_min_uses, 1);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue