]> git.kaiwu.me - nginx.git/commitdiff
Merge of r4756: fixed listen addresses sorting (ticket #187)
authorMaxim Dounin <mdounin@mdounin.ru>
Mon, 6 Aug 2012 16:03:56 +0000 (16:03 +0000)
committerMaxim Dounin <mdounin@mdounin.ru>
Mon, 6 Aug 2012 16:03:56 +0000 (16:03 +0000)
Fixed sorting of listen addresses so that wildcard address is always at
the end.  Failure to do so could result in several listen sockets to be
created instead of only one listening on wildcard address.

Reported by Roman Odaisky.

src/http/ngx_http.c

index 3e077fb95ab9ee4288e49fa4c42d4a7b07ab12e1..f1f8a48e08f8e314a9378ff4a34394b725ddc212 100644 (file)
@@ -1613,6 +1613,11 @@ ngx_http_cmp_conf_addrs(const void *one, const void *two)
         return 1;
     }
 
+    if (second->opt.wildcard) {
+        /* a wildcard address must be the last resort, shift it to the end */
+        return -1;
+    }
+
     if (first->opt.bind && !second->opt.bind) {
         /* shift explicit bind()ed addresses to the start */
         return -1;