Blame SOURCES/glibc-rh703480.patch

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