]> git.kaiwu.me - nginx.git/commitdiff
test a duplicate listen in a server
authorIgor Sysoev <igor@sysoev.ru>
Thu, 22 Oct 2009 08:15:16 +0000 (08:15 +0000)
committerIgor Sysoev <igor@sysoev.ru>
Thu, 22 Oct 2009 08:15:16 +0000 (08:15 +0000)
src/http/ngx_http.c

index e5387c4c3fb38234839c6affb9627b19023fac7e..cf47c23d93f2c50b35c60bedaa330c47c7113e0e 100644 (file)
@@ -1289,6 +1289,7 @@ static ngx_int_t
 ngx_http_add_server(ngx_conf_t *cf, ngx_http_core_srv_conf_t *cscf,
     ngx_http_conf_addr_t *addr)
 {
+    ngx_uint_t                  i;
     ngx_http_core_srv_conf_t  **server;
 
     if (addr->servers.elts == NULL) {
@@ -1298,6 +1299,16 @@ ngx_http_add_server(ngx_conf_t *cf, ngx_http_core_srv_conf_t *cscf,
         {
             return NGX_ERROR;
         }
+
+    } else {
+        server = addr->servers.elts;
+        for (i = 0; i < addr->servers.nelts; i++) {
+            if (server[i] == cscf) {
+                ngx_conf_log_error(NGX_LOG_EMERG, cf, 0,
+                                   "a duplicate listen %s", addr->opt.addr);
+                return NGX_ERROR;
+            }
+        }
     }
 
     server = ngx_array_push(&addr->servers);