From 91425b5e7204b05165e2c5b244f3dad502f9627d Mon Sep 17 00:00:00 2001 From: Brian Wellington Date: Thu, 8 Feb 2001 00:31:21 +0000 Subject: [PATCH] 730. [bug] lwres_getaddrinfo() returns the correct result when it fails to contact a server. [RT #768] --- CHANGES | 4 ++++ lib/lwres/getaddrinfo.c | 28 +++++++++++++++++++++------- 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/CHANGES b/CHANGES index caaa3d62aa..03a41bd6fa 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ + + 730. [bug] lwres_getaddrinfo() returns the correct result when + it fails to contact a server. [RT #768] + 729. [port] pthread_setconcurrency() needs to be called on Solaris. 728. [bug] Fix comment processing on master file directives. diff --git a/lib/lwres/getaddrinfo.c b/lib/lwres/getaddrinfo.c index 833c0d02d0..b78a1e58c5 100644 --- a/lib/lwres/getaddrinfo.c +++ b/lib/lwres/getaddrinfo.c @@ -19,7 +19,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: getaddrinfo.c,v 1.37 2001/01/31 22:06:33 bwelling Exp $ */ +/* $Id: getaddrinfo.c,v 1.38 2001/02/08 00:31:21 bwelling Exp $ */ #include @@ -462,7 +462,7 @@ add_ipv4(const char *hostname, int flags, struct addrinfo **aip, int result = 0; lwres = lwres_context_create(&lwrctx, NULL, NULL, NULL, 0); - if (lwres != 0) + if (lwres != LWRES_R_SUCCESS) ERR(EAI_FAIL); (void) lwres_conf_parse(lwrctx, lwres_resolv_conf); if (hostname == NULL && (flags & AI_PASSIVE) == 0) { @@ -476,8 +476,15 @@ add_ipv4(const char *hostname, int flags, struct addrinfo **aip, ai->ai_socktype = socktype; SIN(ai->ai_addr)->sin_port = port; memcpy(&SIN(ai->ai_addr)->sin_addr, v4_loop, 4); - } else if (lwres_getaddrsbyname(lwrctx, hostname, - LWRES_ADDRTYPE_V4, &by) == 0) { + } else { + lwres = lwres_getaddrsbyname(lwrctx, hostname, + LWRES_ADDRTYPE_V4, &by); + if (lwres != LWRES_R_SUCCESS) { + if (lwres == LWRES_R_NOTFOUND) + goto cleanup; + else + ERR(EAI_FAIL); + } addr = LWRES_LIST_HEAD(by->addrs); while (addr != NULL) { ai = ai_clone(*aip, AF_INET); @@ -522,7 +529,7 @@ add_ipv6(const char *hostname, int flags, struct addrinfo **aip, int result = 0; lwres = lwres_context_create(&lwrctx, NULL, NULL, NULL, 0); - if (lwres != 0) + if (lwres != LWRES_R_SUCCESS) ERR(EAI_FAIL); (void) lwres_conf_parse(lwrctx, lwres_resolv_conf); @@ -537,8 +544,15 @@ add_ipv6(const char *hostname, int flags, struct addrinfo **aip, ai->ai_socktype = socktype; SIN6(ai->ai_addr)->sin6_port = port; memcpy(&SIN6(ai->ai_addr)->sin6_addr, v6_loop, 16); - } else if (lwres_getaddrsbyname(lwrctx, hostname, - LWRES_ADDRTYPE_V6, &by) == 0) { + } else { + lwres = lwres_getaddrsbyname(lwrctx, hostname, + LWRES_ADDRTYPE_V6, &by); + if (lwres != LWRES_R_SUCCESS) { + if (lwres == LWRES_R_NOTFOUND) + goto cleanup; + else + ERR(EAI_FAIL); + } addr = LWRES_LIST_HEAD(by->addrs); while (addr != NULL) { ai = ai_clone(*aip, AF_INET6);