From 3693daa20f13712afc413691a74c6116c5a5bce2 Mon Sep 17 00:00:00 2001 From: Ruslan Ermilov Date: Mon, 5 Aug 2013 13:44:56 +0400 Subject: [PATCH] Core: guard use of AI_ADDRCONFIG. Some systems (notably NetBSD and OpenBSD) lack AI_ADDRCONFIG support. Reported by Piotr Sikora. --- auto/unix | 8 ++------ src/core/ngx_inet.c | 2 ++ 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/auto/unix b/auto/unix index bc3c0f193..cd4209e7b 100755 --- a/auto/unix +++ b/auto/unix @@ -788,11 +788,7 @@ ngx_feature_incs="#include #include " 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 index bb03720f7..0792d6e8c 100644 --- 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_url_t *u) 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"; -- 2.47.3