]> git.kaiwu.me - nginx.git/commitdiff
Upstream: mutually exclusive inheritance of "cache" and "store".
authorValentin Bartenev <vbart@nginx.com>
Mon, 22 Dec 2014 09:58:59 +0000 (12:58 +0300)
committerValentin Bartenev <vbart@nginx.com>
Mon, 22 Dec 2014 09:58:59 +0000 (12:58 +0300)
Currently, storing and caching mechanisms cannot work together, and a
configuration error is thrown when the proxy_store and proxy_cache
directives (as well as their friends) are configured on the same level.

But configurations like in the example below were allowed and could result
in critical errors in the error log:

    proxy_store on;

    location / {
        proxy_cache one;
    }

Only proxy_store worked in this case.

For more predictable and errorless behavior these directives now prevent
each other from being inherited from the previous level.

src/http/modules/ngx_http_fastcgi_module.c
src/http/modules/ngx_http_proxy_module.c
src/http/modules/ngx_http_scgi_module.c
src/http/modules/ngx_http_uwsgi_module.c

index b7d07daad5e0e4949fc16dd0f139faab21345f81..aa2dcd7e50f759f54b1c8591d3605d760a63a178 100644 (file)
@@ -2432,6 +2432,20 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
     ngx_hash_init_t               hash;
     ngx_http_core_loc_conf_t     *clcf;
 
+#if (NGX_HTTP_CACHE)
+
+    if (conf->upstream.store > 0) {
+        conf->upstream.cache = NULL;
+    }
+
+    if (conf->upstream.cache != NGX_CONF_UNSET_PTR
+        && conf->upstream.cache != NULL)
+    {
+        conf->upstream.store = 0;
+    }
+
+#endif
+
     if (conf->upstream.store == NGX_CONF_UNSET) {
         ngx_conf_merge_value(conf->upstream.store,
                               prev->upstream.store, 0);
index 323d03d847dbb0c51874d73b70938b41c552e2ad..69a704cbc83b076420149a92ccf655a6d8bbda31 100644 (file)
@@ -2624,6 +2624,20 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
     ngx_http_proxy_rewrite_t   *pr;
     ngx_http_script_compile_t   sc;
 
+#if (NGX_HTTP_CACHE)
+
+    if (conf->upstream.store > 0) {
+        conf->upstream.cache = NULL;
+    }
+
+    if (conf->upstream.cache != NGX_CONF_UNSET_PTR
+        && conf->upstream.cache != NULL)
+    {
+        conf->upstream.store = 0;
+    }
+
+#endif
+
     if (conf->upstream.store == NGX_CONF_UNSET) {
         ngx_conf_merge_value(conf->upstream.store,
                               prev->upstream.store, 0);
index 8369d5683a82c781520192eed84012f19782fcea..fed916ace600d96c9ddf3d76bb467c637651ff4f 100644 (file)
@@ -1186,6 +1186,20 @@ ngx_http_scgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
     ngx_hash_init_t               hash;
     ngx_http_core_loc_conf_t     *clcf;
 
+#if (NGX_HTTP_CACHE)
+
+    if (conf->upstream.store > 0) {
+        conf->upstream.cache = NULL;
+    }
+
+    if (conf->upstream.cache != NGX_CONF_UNSET_PTR
+        && conf->upstream.cache != NULL)
+    {
+        conf->upstream.store = 0;
+    }
+
+#endif
+
     if (conf->upstream.store == NGX_CONF_UNSET) {
         ngx_conf_merge_value(conf->upstream.store, prev->upstream.store, 0);
 
index 0243e0037514d33b0097b91c4b2a028876f893b8..85db4222607b0f3301c0e376b5fb6c0bccbead05 100644 (file)
@@ -1400,6 +1400,20 @@ ngx_http_uwsgi_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
     ngx_hash_init_t               hash;
     ngx_http_core_loc_conf_t     *clcf;
 
+#if (NGX_HTTP_CACHE)
+
+    if (conf->upstream.store > 0) {
+        conf->upstream.cache = NULL;
+    }
+
+    if (conf->upstream.cache != NGX_CONF_UNSET_PTR
+        && conf->upstream.cache != NULL)
+    {
+        conf->upstream.store = 0;
+    }
+
+#endif
+
     if (conf->upstream.store == NGX_CONF_UNSET) {
         ngx_conf_merge_value(conf->upstream.store, prev->upstream.store, 0);