[nginx] Removed sorting of getaddrinfo() results.
Roman Arutyunyan
arut at nginx.com
Thu Mar 21 11:09:56 UTC 2019
details: https://hg.nginx.org/nginx/rev/8be88b22fe81
branches:
changeset: 7479:8be88b22fe81
user: Roman Arutyunyan <arut at nginx.com>
date: Wed Mar 20 20:31:59 2019 +0300
description:
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.
diffstat:
src/core/ngx_inet.c | 19 +++++--------------
1 files changed, 5 insertions(+), 14 deletions(-)
diffs (33 lines):
diff -r 4f9b72a229c1 -r 8be88b22fe81 src/core/ngx_inet.c
--- a/src/core/ngx_inet.c Fri Mar 15 15:45:56 2019 +0300
+++ b/src/core/ngx_inet.c Wed Mar 20 20:31:59 2019 +0300
@@ -1080,24 +1080,15 @@ ngx_inet_resolve_host(ngx_pool_t *pool,
/* MP: ngx_shared_palloc() */
- /* AF_INET addresses first */
-
for (rp = res; rp != NULL; rp = rp->ai_next) {
- if (rp->ai_family != AF_INET) {
- continue;
- }
+ switch (rp->ai_family) {
- if (ngx_inet_add_addr(pool, u, rp->ai_addr, rp->ai_addrlen, n)
- != NGX_OK)
- {
- goto failed;
- }
- }
+ case AF_INET:
+ case AF_INET6:
+ break;
- for (rp = res; rp != NULL; rp = rp->ai_next) {
-
- if (rp->ai_family != AF_INET6) {
+ default:
continue;
}
More information about the nginx-devel
mailing list