From cfde9b463d63092ff0908d4c2748ace648e2ead8 Mon Sep 17 00:00:00 2001 From: Siddhesh Poyarekar Date: Mon, 19 Nov 2012 13:01:43 +0530 Subject: Return EAI_SYSTEM if we're out of file descriptors Resolves BZ #14719. --- resolv/nss_dns/dns-host.c | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'resolv/nss_dns') diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c index 6b62c05883..f78b87990f 100644 --- a/resolv/nss_dns/dns-host.c +++ b/resolv/nss_dns/dns-host.c @@ -199,6 +199,11 @@ _nss_dns_gethostbyname3_r (const char *name, int af, struct hostent *result, status = NSS_STATUS_TRYAGAIN; h_errno = TRY_AGAIN; break; + /* System has run out of file descriptors. */ + case EMFILE: + case ENFILE: + h_errno = NETDB_INTERNAL; + /* Fall through. */ case ECONNREFUSED: case ETIMEDOUT: status = NSS_STATUS_UNAVAIL; @@ -311,14 +316,26 @@ _nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat, &ans2p, &nans2p, &resplen2); if (n < 0) { - if (errno == ESRCH) + switch (errno) { + case ESRCH: status = NSS_STATUS_TRYAGAIN; h_errno = TRY_AGAIN; + break; + /* System has run out of file descriptors. */ + case EMFILE: + case ENFILE: + h_errno = NETDB_INTERNAL; + /* Fall through. */ + case ECONNREFUSED: + case ETIMEDOUT: + status = NSS_STATUS_UNAVAIL; + break; + default: + status = NSS_STATUS_NOTFOUND; + break; } - else - status = (errno == ECONNREFUSED - ? NSS_STATUS_UNAVAIL : NSS_STATUS_NOTFOUND); + *herrnop = h_errno; if (h_errno == TRY_AGAIN) *errnop = EAGAIN; -- cgit 1.4.1