aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxim Dounin <mdounin@mdounin.ru>2012-04-02 21:29:35 +0000
committerMaxim Dounin <mdounin@mdounin.ru>2012-04-02 21:29:35 +0000
commita5d4f66ad6ebccf281743995718c67d10f5ef18c (patch)
tree287fe082a40c79b56efa953c11ed4db1f611993b /src
parent525e1f75e4e32fad8cfa198630bf29b7c147263a (diff)
downloadnginx-a5d4f66ad6ebccf281743995718c67d10f5ef18c.tar.gz
nginx-a5d4f66ad6ebccf281743995718c67d10f5ef18c.zip
Upstream: reject upstreams without normal servers.
Such upstreams cause CPU hog later in the code as number of peers isn't expected to be 0. Currently this may happen either if there are only backup servers defined in an upstream block, or if server with ipv6 address used in an upstream block.
Diffstat (limited to 'src')
-rw-r--r--src/http/ngx_http_upstream_round_robin.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/http/ngx_http_upstream_round_robin.c b/src/http/ngx_http_upstream_round_robin.c
index 410559d50..f0fac8736 100644
--- a/src/http/ngx_http_upstream_round_robin.c
+++ b/src/http/ngx_http_upstream_round_robin.c
@@ -49,6 +49,13 @@ ngx_http_upstream_init_round_robin(ngx_conf_t *cf,
n += server[i].naddrs;
}
+ if (n == 0) {
+ ngx_log_error(NGX_LOG_EMERG, cf->log, 0,
+ "no servers in upstream \"%V\" in %s:%ui",
+ &us->host, us->file_name, us->line);
+ return NGX_ERROR;
+ }
+
peers = ngx_pcalloc(cf->pool, sizeof(ngx_http_upstream_rr_peers_t)
+ sizeof(ngx_http_upstream_rr_peer_t) * (n - 1));
if (peers == NULL) {