[nginx] svn commit: r4570 - trunk/src/http

mdounin at mdounin.ru mdounin at mdounin.ru
Mon Apr 2 21:29:35 UTC 2012


Author: mdounin
Date: 2012-04-02 21:29:35 +0000 (Mon, 02 Apr 2012)
New Revision: 4570
URL: http://trac.nginx.org/nginx/changeset/4570/nginx

Log:
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.


Modified:
   trunk/src/http/ngx_http_upstream_round_robin.c

Modified: trunk/src/http/ngx_http_upstream_round_robin.c
===================================================================
--- trunk/src/http/ngx_http_upstream_round_robin.c	2012-04-02 21:28:31 UTC (rev 4569)
+++ trunk/src/http/ngx_http_upstream_round_robin.c	2012-04-02 21:29:35 UTC (rev 4570)
@@ -49,6 +49,13 @@
             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) {



More information about the nginx-devel mailing list