]> git.kaiwu.me - nginx.git/commitdiff
Merge of r4153:
authorMaxim Dounin <mdounin@mdounin.ru>
Tue, 13 Dec 2011 18:34:34 +0000 (18:34 +0000)
committerMaxim Dounin <mdounin@mdounin.ru>
Tue, 13 Dec 2011 18:34:34 +0000 (18:34 +0000)
Better handling of late upstream creation.

Configuration with duplicate upstream blocks defined after first use, i.e.
like

    server {
        ...
        location / {
            proxy_pass http://backend;
        }
    }

    upstream backend { ... }
    upstream backend { ... }

now correctly results in "duplicate upstream" error.

Additionally, upstream blocks defined after first use now handle various
server directive parameters ("weight", "max_fails", etc.).  Previously
configuration like

    server {
        ...
        location / {
            proxy_pass http://backend;
        }
    }

    upstream backend {
        server 127.0.0.1 max_fails=5;
    }

incorrectly resulted in "invalid parameter "max_fails=5"" error.

src/http/ngx_http_upstream.c

index 7fba19faf0b49a908d0bf748dad929f4ba6abce6..99b252ebbfd41b3a7cf9c74b7f2968c685037067 100644 (file)
@@ -4280,6 +4280,10 @@ ngx_http_upstream_add(ngx_conf_t *cf, ngx_url_t *u, ngx_uint_t flags)
             continue;
         }
 
+        if (flags & NGX_HTTP_UPSTREAM_CREATE) {
+            uscfp[i]->flags = flags;
+        }
+
         return uscfp[i];
     }