about summary refs log tree commit diff
path: root/resolv
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@redhat.com>2012-11-19 13:01:43 +0530
committerSiddhesh Poyarekar <siddhesh@redhat.com>2012-11-19 13:02:48 +0530
commitcfde9b463d63092ff0908d4c2748ace648e2ead8 (patch)
tree9ac0df733a6b3a01305f937e5e55ea63f3387328 /resolv
parentf6da27e53695ad1cc0e2a9490358decbbfdff5e5 (diff)
downloadglibc-cfde9b463d63092ff0908d4c2748ace648e2ead8.tar.gz
glibc-cfde9b463d63092ff0908d4c2748ace648e2ead8.tar.xz
glibc-cfde9b463d63092ff0908d4c2748ace648e2ead8.zip
Return EAI_SYSTEM if we're out of file descriptors
Resolves BZ #14719.
Diffstat (limited to 'resolv')
-rw-r--r--resolv/nss_dns/dns-host.c25
1 files changed, 21 insertions, 4 deletions
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;