summaryrefslogtreecommitdiffstats
path: root/httpd-2.4.4-dump-vhost-twice.patch
blob: 945fd5e977e8370fbc9b514b42e8f383eae0bf86 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
--- trunk/server/vhost.c	2013/05/11 11:51:28	1481305
+++ trunk/server/vhost.c	2013/05/11 12:05:24	1481306
@@ -577,14 +577,21 @@
      */
 
     for (s = main_s->next; s; s = s->next) {
+        server_addr_rec *sar_prev = NULL;
         has_default_vhost_addr = 0;
         for (sar = s->addrs; sar; sar = sar->next) {
             ipaddr_chain *ic;
             char inaddr_any[16] = {0}; /* big enough to handle IPv4 or IPv6 */
-
+            /* XXX: this treats 0.0.0.0 as a "default" server which matches no-exact-match for IPv6 */
             if (!memcmp(sar->host_addr->ipaddr_ptr, inaddr_any, sar->host_addr->ipaddr_len)) {
                 ic = find_default_server(sar->host_port);
-                if (!ic || sar->host_port != ic->sar->host_port) {
+
+                if (ic && sar->host_port == ic->sar->host_port) { /* we're a match for an existing "default server"  */
+                    if (!sar_prev || memcmp(sar_prev->host_addr->ipaddr_ptr, inaddr_any, sar_prev->host_addr->ipaddr_len)) { 
+                        add_name_vhost_config(p, main_s, s, sar, ic);
+                    }
+                }
+                else { 
                     /* No default server, or we found a default server but
                     ** exactly one of us is a wildcard port, which means we want
                     ** two ip-based vhosts not an NVH with two names
@@ -592,6 +599,7 @@
                     ic = new_ipaddr_chain(p, s, sar);
                     ic->next = default_list;
                     default_list = ic;
+                    add_name_vhost_config(p, main_s, s, sar, ic);
                 }
                 has_default_vhost_addr = 1;
             }
@@ -609,8 +617,9 @@
                     ic->next = *iphash_table_tail[bucket];
                     *iphash_table_tail[bucket] = ic;
                 }
+                add_name_vhost_config(p, main_s, s, sar, ic);
             }
-            add_name_vhost_config(p, main_s, s, sar, ic);
+            sar_prev = sar;
         }
 
         /* Ok now we want to set up a server_hostname if the user was