changeset 4755:7ab10517ae58

Fixed sorting of listen addresses so that wildcard address is always at the end (closes #187). 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.
author Ruslan Ermilov <ru@nginx.com>
date Tue, 17 Jul 2012 04:47:34 +0000
parents 798e0377fd52
children daa60662b7b5
files src/http/ngx_http.c
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/http/ngx_http.c
+++ b/src/http/ngx_http.c
@@ -1613,6 +1613,11 @@ ngx_http_cmp_conf_addrs(const void *one,
         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;