[nginx] Upstream: simplified proxy_store and friends configurati...

Valentin Bartenev vbart at nginx.com
Mon Dec 22 10:00:18 UTC 2014


details:   http://hg.nginx.org/nginx/rev/d9025ea1f5a5
branches:  
changeset: 5947:d9025ea1f5a5
user:      Valentin Bartenev <vbart at nginx.com>
date:      Mon Dec 22 12:58:56 2014 +0300
description:
Upstream: simplified proxy_store and friends configuration code.

This changes internal API related to handling of the "store"
flag in ngx_http_upstream_conf_t.  Previously, a non-null value
of "store_lengths" was enough to enable store functionality with
custom path.  Now, the "store" flag is also required to be set.

No functional changes.

diffstat:

 src/http/modules/ngx_http_fastcgi_module.c |  15 ++++++---------
 src/http/modules/ngx_http_proxy_module.c   |  15 ++++++---------
 src/http/modules/ngx_http_scgi_module.c    |  13 ++++++-------
 src/http/modules/ngx_http_uwsgi_module.c   |  14 ++++++--------
 src/http/ngx_http_upstream.c               |   2 +-
 5 files changed, 25 insertions(+), 34 deletions(-)

diffs (197 lines):

diff -r ee941e49bd88 -r d9025ea1f5a5 src/http/modules/ngx_http_fastcgi_module.c
--- a/src/http/modules/ngx_http_fastcgi_module.c	Wed Dec 17 15:12:50 2014 +0100
+++ b/src/http/modules/ngx_http_fastcgi_module.c	Mon Dec 22 12:58:56 2014 +0300
@@ -2436,10 +2436,8 @@ ngx_http_fastcgi_merge_loc_conf(ngx_conf
         ngx_conf_merge_value(conf->upstream.store,
                               prev->upstream.store, 0);
 
-        if (conf->upstream.store_lengths == NULL) {
-            conf->upstream.store_lengths = prev->upstream.store_lengths;
-            conf->upstream.store_values = prev->upstream.store_values;
-        }
+        conf->upstream.store_lengths = prev->upstream.store_lengths;
+        conf->upstream.store_values = prev->upstream.store_values;
     }
 
     ngx_conf_merge_uint_value(conf->upstream.store_access,
@@ -3206,9 +3204,7 @@ ngx_http_fastcgi_store(ngx_conf_t *cf, n
     ngx_str_t                  *value;
     ngx_http_script_compile_t   sc;
 
-    if (flcf->upstream.store != NGX_CONF_UNSET
-        || flcf->upstream.store_lengths)
-    {
+    if (flcf->upstream.store != NGX_CONF_UNSET) {
         return "is duplicate";
     }
 
@@ -3229,8 +3225,9 @@ ngx_http_fastcgi_store(ngx_conf_t *cf, n
 
 #endif
 
+    flcf->upstream.store = 1;
+
     if (ngx_strcmp(value[1].data, "on") == 0) {
-        flcf->upstream.store = 1;
         return NGX_CONF_OK;
     }
 
@@ -3275,7 +3272,7 @@ ngx_http_fastcgi_cache(ngx_conf_t *cf, n
         return NGX_CONF_OK;
     }
 
-    if (flcf->upstream.store > 0 || flcf->upstream.store_lengths) {
+    if (flcf->upstream.store > 0) {
         return "is incompatible with \"fastcgi_store\"";
     }
 
diff -r ee941e49bd88 -r d9025ea1f5a5 src/http/modules/ngx_http_proxy_module.c
--- a/src/http/modules/ngx_http_proxy_module.c	Wed Dec 17 15:12:50 2014 +0100
+++ b/src/http/modules/ngx_http_proxy_module.c	Mon Dec 22 12:58:56 2014 +0300
@@ -2628,10 +2628,8 @@ ngx_http_proxy_merge_loc_conf(ngx_conf_t
         ngx_conf_merge_value(conf->upstream.store,
                               prev->upstream.store, 0);
 
-        if (conf->upstream.store_lengths == NULL) {
-            conf->upstream.store_lengths = prev->upstream.store_lengths;
-            conf->upstream.store_values = prev->upstream.store_values;
-        }
+        conf->upstream.store_lengths = prev->upstream.store_lengths;
+        conf->upstream.store_values = prev->upstream.store_values;
     }
 
     ngx_conf_merge_uint_value(conf->upstream.store_access,
@@ -3794,9 +3792,7 @@ ngx_http_proxy_store(ngx_conf_t *cf, ngx
     ngx_str_t                  *value;
     ngx_http_script_compile_t   sc;
 
-    if (plcf->upstream.store != NGX_CONF_UNSET
-        || plcf->upstream.store_lengths)
-    {
+    if (plcf->upstream.store != NGX_CONF_UNSET) {
         return "is duplicate";
     }
 
@@ -3817,8 +3813,9 @@ ngx_http_proxy_store(ngx_conf_t *cf, ngx
 
 #endif
 
+    plcf->upstream.store = 1;
+
     if (ngx_strcmp(value[1].data, "on") == 0) {
-        plcf->upstream.store = 1;
         return NGX_CONF_OK;
     }
 
@@ -3863,7 +3860,7 @@ ngx_http_proxy_cache(ngx_conf_t *cf, ngx
         return NGX_CONF_OK;
     }
 
-    if (plcf->upstream.store > 0 || plcf->upstream.store_lengths) {
+    if (plcf->upstream.store > 0) {
         return "is incompatible with \"proxy_store\"";
     }
 
diff -r ee941e49bd88 -r d9025ea1f5a5 src/http/modules/ngx_http_scgi_module.c
--- a/src/http/modules/ngx_http_scgi_module.c	Wed Dec 17 15:12:50 2014 +0100
+++ b/src/http/modules/ngx_http_scgi_module.c	Mon Dec 22 12:58:56 2014 +0300
@@ -1189,10 +1189,8 @@ ngx_http_scgi_merge_loc_conf(ngx_conf_t 
     if (conf->upstream.store == NGX_CONF_UNSET) {
         ngx_conf_merge_value(conf->upstream.store, prev->upstream.store, 0);
 
-        if (conf->upstream.store_lengths == NULL) {
-            conf->upstream.store_lengths = prev->upstream.store_lengths;
-            conf->upstream.store_values = prev->upstream.store_values;
-        }
+        conf->upstream.store_lengths = prev->upstream.store_lengths;
+        conf->upstream.store_values = prev->upstream.store_values;
     }
 
     ngx_conf_merge_uint_value(conf->upstream.store_access,
@@ -1760,7 +1758,7 @@ ngx_http_scgi_store(ngx_conf_t *cf, ngx_
     ngx_str_t                  *value;
     ngx_http_script_compile_t   sc;
 
-    if (scf->upstream.store != NGX_CONF_UNSET || scf->upstream.store_lengths) {
+    if (scf->upstream.store != NGX_CONF_UNSET) {
         return "is duplicate";
     }
 
@@ -1781,8 +1779,9 @@ ngx_http_scgi_store(ngx_conf_t *cf, ngx_
 
 #endif
 
+    scf->upstream.store = 1;
+
     if (ngx_strcmp(value[1].data, "on") == 0) {
-        scf->upstream.store = 1;
         return NGX_CONF_OK;
     }
 
@@ -1827,7 +1826,7 @@ ngx_http_scgi_cache(ngx_conf_t *cf, ngx_
         return NGX_CONF_OK;
     }
 
-    if (scf->upstream.store > 0 || scf->upstream.store_lengths) {
+    if (scf->upstream.store > 0) {
         return "is incompatible with \"scgi_store\"";
     }
 
diff -r ee941e49bd88 -r d9025ea1f5a5 src/http/modules/ngx_http_uwsgi_module.c
--- a/src/http/modules/ngx_http_uwsgi_module.c	Wed Dec 17 15:12:50 2014 +0100
+++ b/src/http/modules/ngx_http_uwsgi_module.c	Mon Dec 22 12:58:56 2014 +0300
@@ -1403,10 +1403,8 @@ ngx_http_uwsgi_merge_loc_conf(ngx_conf_t
     if (conf->upstream.store == NGX_CONF_UNSET) {
         ngx_conf_merge_value(conf->upstream.store, prev->upstream.store, 0);
 
-        if (conf->upstream.store_lengths == NULL) {
-            conf->upstream.store_lengths = prev->upstream.store_lengths;
-            conf->upstream.store_values = prev->upstream.store_values;
-        }
+        conf->upstream.store_lengths = prev->upstream.store_lengths;
+        conf->upstream.store_values = prev->upstream.store_values;
     }
 
     ngx_conf_merge_uint_value(conf->upstream.store_access,
@@ -2047,8 +2045,7 @@ ngx_http_uwsgi_store(ngx_conf_t *cf, ngx
     ngx_str_t                  *value;
     ngx_http_script_compile_t   sc;
 
-    if (uwcf->upstream.store != NGX_CONF_UNSET || uwcf->upstream.store_lengths)
-    {
+    if (uwcf->upstream.store != NGX_CONF_UNSET) {
         return "is duplicate";
     }
 
@@ -2069,8 +2066,9 @@ ngx_http_uwsgi_store(ngx_conf_t *cf, ngx
 
 #endif
 
+    uwcf->upstream.store = 1;
+
     if (ngx_strcmp(value[1].data, "on") == 0) {
-        uwcf->upstream.store = 1;
         return NGX_CONF_OK;
     }
 
@@ -2115,7 +2113,7 @@ ngx_http_uwsgi_cache(ngx_conf_t *cf, ngx
         return NGX_CONF_OK;
     }
 
-    if (uwcf->upstream.store > 0 || uwcf->upstream.store_lengths) {
+    if (uwcf->upstream.store > 0) {
         return "is incompatible with \"uwsgi_store\"";
     }
 
diff -r ee941e49bd88 -r d9025ea1f5a5 src/http/ngx_http_upstream.c
--- a/src/http/ngx_http_upstream.c	Wed Dec 17 15:12:50 2014 +0100
+++ b/src/http/ngx_http_upstream.c	Mon Dec 22 12:58:56 2014 +0300
@@ -540,7 +540,7 @@ ngx_http_upstream_init_request(ngx_http_
 
 #endif
 
-    u->store = (u->conf->store || u->conf->store_lengths);
+    u->store = u->conf->store;
 
     if (!u->store && !r->post_action && !u->conf->ignore_client_abort) {
         r->read_event_handler = ngx_http_upstream_rd_check_broken_connection;



More information about the nginx-devel mailing list