summaryrefslogtreecommitdiffstats
path: root/libc/dns
diff options
context:
space:
mode:
authorYabin Cui <yabinc@google.com>2014-12-19 10:10:04 -0800
committerYabin Cui <yabinc@google.com>2014-12-19 14:11:29 -0800
commit7069256495ef8a38a16a39a8570800e9e5290004 (patch)
treed066b29c564593cb24adb0d863313ca49be74d69 /libc/dns
parent65e6985617d035ef45da86f8c8bcceea7bc47239 (diff)
downloadbionic-7069256495ef8a38a16a39a8570800e9e5290004.zip
bionic-7069256495ef8a38a16a39a8570800e9e5290004.tar.gz
bionic-7069256495ef8a38a16a39a8570800e9e5290004.tar.bz2
Support gethostbyname_r_ERANGE.
Bug: 18802601 Change-Id: Iaa64921e96f91e330f1845c5399ee8aba39d9c10
Diffstat (limited to 'libc/dns')
-rw-r--r--libc/dns/gethnamaddr.c3
-rw-r--r--libc/dns/net/nsdispatch.c5
-rw-r--r--libc/dns/net/sethostent.c13
3 files changed, 18 insertions, 3 deletions
diff --git a/libc/dns/gethnamaddr.c b/libc/dns/gethnamaddr.c
index 63a6a60..8f5800a 100644
--- a/libc/dns/gethnamaddr.c
+++ b/libc/dns/gethnamaddr.c
@@ -1208,7 +1208,7 @@ _dns_gethtbyname(void *rv, void *cb_data, va_list ap)
free(buf);
__res_put_state(res);
if (hp == NULL)
- switch (h_errno) {
+ switch (*info->he) {
case HOST_NOT_FOUND:
return NS_NOTFOUND;
case TRY_AGAIN:
@@ -1326,6 +1326,7 @@ _dns_gethtbyaddr(void *rv, void *cb_data, va_list ap)
*info->he = NETDB_SUCCESS;
return NS_SUCCESS;
nospc:
+ errno = ENOSPC;
*info->he = NETDB_INTERNAL;
return NS_UNAVAIL;
}
diff --git a/libc/dns/net/nsdispatch.c b/libc/dns/net/nsdispatch.c
index fb6d8f6..d025592 100644
--- a/libc/dns/net/nsdispatch.c
+++ b/libc/dns/net/nsdispatch.c
@@ -71,6 +71,7 @@
#include <sys/cdefs.h>
#include <assert.h>
+#include <errno.h>
#include <nsswitch.h>
#include <stdarg.h>
#include <strings.h>
@@ -133,6 +134,10 @@ nsdispatch(void *retval, const ns_dtab disp_tab[], const char *database,
continue;
if (result & srclist[i].flags)
break;
+ /* Stop trying next resolver when there is a memory space fatal error. */
+ if ((result & NS_UNAVAIL) != 0 && errno == ENOSPC) {
+ break;
+ }
}
}
result &= NS_STATUSMASK; /* clear private flags in result */
diff --git a/libc/dns/net/sethostent.c b/libc/dns/net/sethostent.c
index f501c8b..916421e 100644
--- a/libc/dns/net/sethostent.c
+++ b/libc/dns/net/sethostent.c
@@ -116,7 +116,9 @@ _hf_gethtbyname(void *rv, void *cb_data, va_list ap)
hp = _hf_gethtbyname2(name, af, info);
#endif
if (hp == NULL) {
- *info->he = HOST_NOT_FOUND;
+ if (*info->he == NETDB_INTERNAL && errno == ENOSPC) {
+ return NS_UNAVAIL;
+ }
return NS_NOTFOUND;
}
return NS_SUCCESS;
@@ -159,8 +161,12 @@ _hf_gethtbyname2(const char *name, int af, struct getnamaddr *info)
hp = netbsd_gethostent_r(hf, info->hp, info->buf, info->buflen,
info->he);
- if (hp == NULL)
+ if (hp == NULL) {
+ if (*info->he == NETDB_INTERNAL && errno == ENOSPC) {
+ goto nospc;
+ }
break;
+ }
if (strcasecmp(hp->h_name, name) != 0) {
char **cp;
@@ -259,6 +265,9 @@ _hf_gethtbyaddr(void *rv, void *cb_data, va_list ap)
endhostent_r(&hf);
if (hp == NULL) {
+ if (errno == ENOSPC) {
+ return NS_UNAVAIL;
+ }
*info->he = HOST_NOT_FOUND;
return NS_NOTFOUND;
}