comparison src/core/ngx_inet.c @ 7479:8be88b22fe81

Removed sorting of getaddrinfo() results. Previously the ngx_inet_resolve_host() function sorted addresses in a way that IPv4 addresses came before IPv6 addresses. This was implemented in eaf95350d75c (1.3.10) along with the introduction of getaddrinfo() which could resolve host names to IPv6 addresses. Since the "listen" directive only used the first address, sorting allowed to preserve "listen" compatibility with the previous behavior and with the behavior of nginx built without IPv6 support. Now "listen" uses all resolved addresses which makes sorting pointless.
author Roman Arutyunyan <arut@nginx.com>
date Wed, 20 Mar 2019 20:31:59 +0300
parents 4f9b72a229c1
children d9c3917c7f90
comparison
equal deleted inserted replaced
7478:4f9b72a229c1 7479:8be88b22fe81
1078 goto failed; 1078 goto failed;
1079 } 1079 }
1080 1080
1081 /* MP: ngx_shared_palloc() */ 1081 /* MP: ngx_shared_palloc() */
1082 1082
1083 /* AF_INET addresses first */
1084
1085 for (rp = res; rp != NULL; rp = rp->ai_next) { 1083 for (rp = res; rp != NULL; rp = rp->ai_next) {
1086 1084
1087 if (rp->ai_family != AF_INET) { 1085 switch (rp->ai_family) {
1088 continue; 1086
1089 } 1087 case AF_INET:
1090 1088 case AF_INET6:
1091 if (ngx_inet_add_addr(pool, u, rp->ai_addr, rp->ai_addrlen, n) 1089 break;
1092 != NGX_OK) 1090
1093 { 1091 default:
1094 goto failed;
1095 }
1096 }
1097
1098 for (rp = res; rp != NULL; rp = rp->ai_next) {
1099
1100 if (rp->ai_family != AF_INET6) {
1101 continue; 1092 continue;
1102 } 1093 }
1103 1094
1104 if (ngx_inet_add_addr(pool, u, rp->ai_addr, rp->ai_addrlen, n) 1095 if (ngx_inet_add_addr(pool, u, rp->ai_addr, rp->ai_addrlen, n)
1105 != NGX_OK) 1096 != NGX_OK)