Welcome! Log In Create A New Profile

Advanced

Re: [PATCH] Core: guard use of AI_ADDRCONFIG

Ruslan Ermilov
August 05, 2013 05:30AM
On Mon, Aug 05, 2013 at 12:45:11AM -0700, Piotr Sikora wrote:
> # HG changeset patch
> # User Piotr Sikora <piotr@cloudflare.com>
> # Date 1375688648 0
> # Mon Aug 05 07:44:08 2013 +0000
> # Node ID c9e0a2f54810335ba91b86fdb92ef63571680dae
> # Parent ec8594b9bf11de3599af15de8e73e41bf7a8b42c
> Core: guard use of AI_ADDRCONFIG.
>
> AI_ADDRCONFIG is not available on all operating systems (e.g. OpenBSD)
> and using it without a guard results in dropped getaddrinfo() support.
>
> Signed-off-by: Piotr Sikora <piotr@cloudflare.com>

Thanks. I suggest a different patch instead:

# HG changeset patch
# User Ruslan Ermilov <ru@nginx.com>
# Date 1375694198 -14400
# Mon Aug 05 13:16:38 2013 +0400
# Node ID 294cead2bb846e1f6cf1469af14c9221adac74d3
# Parent ec8594b9bf11de3599af15de8e73e41bf7a8b42c
Core: guard use of AI_ADDRCONFIG.

Some systems (notably NetBSD and OpenBSD) lack AI_ADDRCONFIG support.

Reported by Piotr Sikora.

diff --git a/auto/unix b/auto/unix
--- a/auto/unix
+++ b/auto/unix
@@ -788,11 +788,7 @@ ngx_feature_incs="#include <sys/types.h>
#include <netdb.h>"
ngx_feature_path=
ngx_feature_libs=
-ngx_feature_test='struct addrinfo hints, *res;
- hints.ai_family = AF_UNSPEC;
- hints.ai_socktype = SOCK_STREAM;
- hints.ai_flags = AI_ADDRCONFIG;
- if (getaddrinfo("localhost", NULL, &hints, &res) != 0)
- return 1;
+ngx_feature_test='struct addrinfo *res;
+ if (getaddrinfo("localhost", NULL, NULL, &res) != 0) return 1;
freeaddrinfo(res)'
. auto/feature
diff --git a/src/core/ngx_inet.c b/src/core/ngx_inet.c
--- a/src/core/ngx_inet.c
+++ b/src/core/ngx_inet.c
@@ -963,7 +963,9 @@ ngx_inet_resolve_host(ngx_pool_t *pool,
ngx_memzero(&hints, sizeof(struct addrinfo));
hints.ai_family = AF_UNSPEC;
hints.ai_socktype = SOCK_STREAM;
+#ifdef AI_ADDRCONFIG
hints.ai_flags = AI_ADDRCONFIG;
+#endif

if (getaddrinfo((char *) host, NULL, &hints, &res) != 0) {
u->err = "host not found";

_______________________________________________
nginx-devel mailing list
nginx-devel@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx-devel
Subject Author Views Posted

[PATCH] Core: guard use of AI_ADDRCONFIG

Piotr Sikora 1017 August 05, 2013 03:46AM

Re: [PATCH] Core: guard use of AI_ADDRCONFIG

Ruslan Ermilov 453 August 05, 2013 05:30AM

Re: [PATCH] Core: guard use of AI_ADDRCONFIG

Piotr Sikora 468 August 05, 2013 05:40AM



Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 146
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready