Blame SOURCES/glibc-rh703480.patch

b9ba6d
2011-01-15  Ulrich Drepper  <drepper@gmail.com>
b9ba6d
b9ba6d
	[BZ #6812]
b9ba6d
	* nscd/hstcache.c (tryagain): Define.
b9ba6d
	(cache_addhst): Return tryagain not notfound for temporary errors.
b9ba6d
	(addhstbyX): Also set h_errno to TRY_AGAIN when memory allocation
b9ba6d
	failed.
b9ba6d
b9ba6d
Index: glibc-2.12-2-gc4ccff1/nscd/hstcache.c
b9ba6d
===================================================================
b9ba6d
--- glibc-2.12-2-gc4ccff1.orig/nscd/hstcache.c
b9ba6d
+++ glibc-2.12-2-gc4ccff1/nscd/hstcache.c
b9ba6d
@@ -77,6 +77,20 @@ static const hst_response_header notfoun
b9ba6d
 };
b9ba6d
 
b9ba6d
 
b9ba6d
+/* This is the standard reply in case there are temporary problems.  */
b9ba6d
+static const hst_response_header tryagain =
b9ba6d
+{
b9ba6d
+  .version = NSCD_VERSION,
b9ba6d
+  .found = 0,
b9ba6d
+  .h_name_len = 0,
b9ba6d
+  .h_aliases_cnt = 0,
b9ba6d
+  .h_addrtype = -1,
b9ba6d
+  .h_length = -1,
b9ba6d
+  .h_addr_list_cnt = 0,
b9ba6d
+  .error = TRY_AGAIN
b9ba6d
+};
b9ba6d
+
b9ba6d
+
b9ba6d
 static void
b9ba6d
 cache_addhst (struct database_dyn *db, int fd, request_header *req,
b9ba6d
 	      const void *key, struct hostent *hst, uid_t owner,
b9ba6d
@@ -111,11 +125,15 @@ cache_addhst (struct database_dyn *db, i
b9ba6d
       else
b9ba6d
 	{
b9ba6d
 	  /* We have no data.  This means we send the standard reply for this
b9ba6d
-	     case.  */
b9ba6d
+	     case.  Possibly this is only temporary.  */
b9ba6d
 	  ssize_t total = sizeof (notfound);
b9ba6d
+	  assert (sizeof (notfound) == sizeof (tryagain));
b9ba6d
+
b9ba6d
+	  const hst_response_header *resp = (errval == EAGAIN
b9ba6d
+					     ? &tryagain : &notfound);
b9ba6d
 
b9ba6d
 	  if (fd != -1 &&
b9ba6d
-	      TEMP_FAILURE_RETRY (send (fd, &notfound, total,
b9ba6d
+	      TEMP_FAILURE_RETRY (send (fd, resp, total,
b9ba6d
 					MSG_NOSIGNAL)) != total)
b9ba6d
 	    all_written = false;
b9ba6d
 
b9ba6d
@@ -135,7 +153,7 @@ cache_addhst (struct database_dyn *db, i
b9ba6d
 					   ? db->negtimeout : ttl);
b9ba6d
 
b9ba6d
 	      /* This is the reply.  */
b9ba6d
-	      memcpy (&dataset->resp, &notfound, total);
b9ba6d
+	      memcpy (&dataset->resp, resp, total);
b9ba6d
 
b9ba6d
 	      /* Copy the key data.  */
b9ba6d
 	      memcpy (dataset->strdata, key, req->key_len);
b9ba6d
@@ -490,6 +508,7 @@ addhstbyX (struct database_dyn *db, int 
b9ba6d
 	      /* We set the error to indicate this is (possibly) a
b9ba6d
 		 temporary error and that it does not mean the entry
b9ba6d
 		 is not available at all.  */
b9ba6d
+	      h_errno = TRY_AGAIN;
b9ba6d
 	      errval = EAGAIN;
b9ba6d
 	      break;
b9ba6d
 	    }