Blame SOURCES/glibc-rh703480.patch

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