]> git.kaiwu.me - nginx.git/commitdiff
Upstream: honor the "down" flag for a single server.
authorRuslan Ermilov <ru@nginx.com>
Fri, 16 Nov 2012 12:18:05 +0000 (12:18 +0000)
committerRuslan Ermilov <ru@nginx.com>
Fri, 16 Nov 2012 12:18:05 +0000 (12:18 +0000)
If an upstream block was defined with the only server marked as
"down", e.g.

    upstream u {
        server 127.0.0.1:8080 down;
    }

an attempt was made to contact the server despite the "down" flag.
It is believed that immediate 502 response is better in such a
case, and it's also consistent with what is currently done in case
of multiple servers all marked as "down".

src/http/ngx_http_upstream_round_robin.c

index c4998fca5194f7bb9202644a4adbe3778aac1800..4b78cffd84004add33919a79f3ffe8dc69f3c722 100644 (file)
@@ -430,6 +430,10 @@ ngx_http_upstream_get_round_robin_peer(ngx_peer_connection_t *pc, void *data)
     if (rrp->peers->single) {
         peer = &rrp->peers->peer[0];
 
+        if (peer->down) {
+            goto failed;
+        }
+
     } else {
 
         /* there are several peers */