Skip to content

Commit

Permalink
Removed sorting of getaddrinfo() results.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
arut committed Mar 20, 2019
1 parent 4e17b93 commit b92e8ff
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions src/core/ngx_inet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1080,24 +1080,15 @@ ngx_inet_resolve_host(ngx_pool_t *pool, ngx_url_t *u)

/* MP: ngx_shared_palloc() */

/* AF_INET addresses first */

for (rp = res; rp != NULL; rp = rp->ai_next) {

if (rp->ai_family != AF_INET) {
continue;
}

if (ngx_inet_add_addr(pool, u, rp->ai_addr, rp->ai_addrlen, n)
!= NGX_OK)
{
goto failed;
}
}
switch (rp->ai_family) {

for (rp = res; rp != NULL; rp = rp->ai_next) {
case AF_INET:
case AF_INET6:
break;

if (rp->ai_family != AF_INET6) {
default:
continue;
}

Expand Down

0 comments on commit b92e8ff

Please sign in to comment.