Blame SOURCES/glibc-rh703481.patch

b9ba6d
2011-02-05  Ulrich Drepper  <drepper@gmail.com>
b9ba6d
b9ba6d
	* nscd/nscd-client.h: Define MAX_TIMEOUT_VALUE.
b9ba6d
	(struct datahead): Reuse 32 bits of the alignment for a TTL field.
b9ba6d
	* nscd/aicache.c (addhstaiX): Return timeout of added value.
b9ba6d
	(readdhstai): Return value of addhstaiX call.
b9ba6d
	* nscd/grpcache.c (cache_addgr): Return timeout of added value.
b9ba6d
	(addgrbyX): Return value returned by cache_addgr.
b9ba6d
	(readdgrbyname): Return value returned by addgrbyX.
b9ba6d
	(readdgrbygid): Likewise.
b9ba6d
	* nscd/pwdcache.c (cache_addpw): Return timeout of added value.
b9ba6d
	(addpwbyX): Return value returned by cache_addpw.
b9ba6d
	(readdpwbyname): Return value returned by addhstbyX.
b9ba6d
	(readdpwbyuid): Likewise.
b9ba6d
	* nscd/servicescache.c (cache_addserv): Return timeout of added value.
b9ba6d
	(addservbyX): Return value returned by cache_addserv.
b9ba6d
	(readdservbyname): Return value returned by addservbyX:
b9ba6d
	(readdservbyport): Likewise.
b9ba6d
	* nscd/hstcache.c (cache_addhst): Return timeout of added value.
b9ba6d
	(addhstbyX): Return value returned by cache_addhst.
b9ba6d
	(readdhstbyname): Return value returned by addhstbyX.
b9ba6d
	(readdhstbyaddr): Likewise.
b9ba6d
	(readdhstbynamev6): Likewise.
b9ba6d
	(readdhstbyaddrv6): Likewise.
b9ba6d
	* nscd/initgrcache.c (addinitgroupsX): Return timeout of added value.
b9ba6d
	(readdinitgroups): Return value returned by addinitgroupsX.
b9ba6d
	* nscd/cache.c (readdfcts): Change return value of functions to time_t.
b9ba6d
	(prune_cache): Keep track of timeout value of re-added entries.
b9ba6d
	* nscd/connections.c (nscd_run_prune): Use MAX_TIMEOUT_VALUE.
b9ba6d
	* nscd/nscd.h: Adjust prototypes of readd* functions.
b9ba6d
b9ba6d
Index: glibc-2.12-2-gc4ccff1/nscd/aicache.c
b9ba6d
===================================================================
b9ba6d
--- glibc-2.12-2-gc4ccff1.orig/nscd/aicache.c
b9ba6d
+++ glibc-2.12-2-gc4ccff1/nscd/aicache.c
b9ba6d
@@ -58,7 +58,7 @@ static const ai_response_header notfound
b9ba6d
 };
b9ba6d
 
b9ba6d
 
b9ba6d
-static void
b9ba6d
+static time_t
b9ba6d
 addhstaiX (struct database_dyn *db, int fd, request_header *req,
b9ba6d
 	   void *key, uid_t uid, struct hashentry *const he,
b9ba6d
 	   struct datahead *dh)
b9ba6d
@@ -119,6 +119,7 @@ addhstaiX (struct database_dyn *db, int 
b9ba6d
   ssize_t total = 0;
b9ba6d
   char *key_copy = NULL;
b9ba6d
   bool alloca_used = false;
b9ba6d
+  time_t timeout = MAX_TIMEOUT_VALUE;
b9ba6d
 
b9ba6d
   while (!no_more)
b9ba6d
     {
b9ba6d
@@ -388,8 +389,8 @@ addhstaiX (struct database_dyn *db, int 
b9ba6d
       dataset->head.usable = true;
b9ba6d
 
b9ba6d
       /* Compute the timeout time.  */
b9ba6d
-      dataset->head.timeout = time (NULL) + (ttl == INT32_MAX
b9ba6d
-					     ? db->postimeout : ttl);
b9ba6d
+      dataset->head.ttl = ttl == INT32_MAX ? db->postimeout : ttl;
b9ba6d
+      timeout = dataset->head.timeout = time (NULL) + dataset->head.ttl;
b9ba6d
 
b9ba6d
       dataset->resp.version = NSCD_VERSION;
b9ba6d
       dataset->resp.found = 1;
b9ba6d
@@ -421,6 +422,7 @@ addhstaiX (struct database_dyn *db, int 
b9ba6d
 		 timeout value.  Note that the new record has been
b9ba6d
 		 allocated on the stack and need not be freed.  */
b9ba6d
 	      dh->timeout = dataset->head.timeout;
b9ba6d
+	      dh->ttl = dataset->head.ttl;
b9ba6d
 	      ++dh->nreloads;
b9ba6d
 	    }
b9ba6d
 	  else
b9ba6d
@@ -496,6 +498,9 @@ next_nip:
b9ba6d
       if (reload_count != UINT_MAX && dh->nreloads == reload_count)
b9ba6d
 	/* Do not reset the value if we never not reload the record.  */
b9ba6d
 	dh->nreloads = reload_count - 1;
b9ba6d
+
b9ba6d
+      /* Reload with the same time-to-live value.  */
b9ba6d
+      timeout = dh->timeout = time (NULL) + dh->ttl;
b9ba6d
     }
b9ba6d
   else
b9ba6d
     {
b9ba6d
@@ -517,7 +522,8 @@ next_nip:
b9ba6d
 	  dataset->head.usable = true;
b9ba6d
 
b9ba6d
 	  /* Compute the timeout time.  */
b9ba6d
-	  dataset->head.timeout = time (NULL) + db->negtimeout;
b9ba6d
+	  timeout = dataset->head.timeout = time (NULL) + db->negtimeout;
b9ba6d
+	  dataset->head.ttl = db->negtimeout;
b9ba6d
 
b9ba6d
 	  /* This is the reply.  */
b9ba6d
 	  memcpy (&dataset->resp, &notfound, total);
b9ba6d
@@ -551,6 +557,8 @@ next_nip:
b9ba6d
       if (dh != NULL)
b9ba6d
 	dh->usable = false;
b9ba6d
     }
b9ba6d
+
b9ba6d
+  return timeout;
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
@@ -562,7 +570,7 @@ addhstai (struct database_dyn *db, int f
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
-void
b9ba6d
+time_t
b9ba6d
 readdhstai (struct database_dyn *db, struct hashentry *he, struct datahead *dh)
b9ba6d
 {
b9ba6d
   request_header req =
b9ba6d
@@ -571,5 +579,5 @@ readdhstai (struct database_dyn *db, str
b9ba6d
       .key_len = he->len
b9ba6d
     };
b9ba6d
 
b9ba6d
-  addhstaiX (db, -1, &req, db->data + he->key, he->owner, he, dh);
b9ba6d
+  return addhstaiX (db, -1, &req, db->data + he->key, he->owner, he, dh);
b9ba6d
 }
b9ba6d
Index: glibc-2.12-2-gc4ccff1/nscd/cache.c
b9ba6d
===================================================================
b9ba6d
--- glibc-2.12-2-gc4ccff1.orig/nscd/cache.c
b9ba6d
+++ glibc-2.12-2-gc4ccff1/nscd/cache.c
b9ba6d
@@ -45,9 +45,9 @@ extern void *xcalloc (size_t n, size_t s
b9ba6d
 unsigned int reload_count = DEFAULT_RELOAD_LIMIT;
b9ba6d
 
b9ba6d
 
b9ba6d
-static void (*const readdfcts[LASTREQ]) (struct database_dyn *,
b9ba6d
-					 struct hashentry *,
b9ba6d
-					 struct datahead *) =
b9ba6d
+static time_t (*const readdfcts[LASTREQ]) (struct database_dyn *,
b9ba6d
+					   struct hashentry *,
b9ba6d
+					   struct datahead *) =
b9ba6d
 {
b9ba6d
   [GETPWBYNAME] = readdpwbyname,
b9ba6d
   [GETPWBYUID] = readdpwbyuid,
b9ba6d
@@ -389,7 +389,8 @@ prune_cache (struct database_dyn *table,
b9ba6d
 		      assert (runp->type < LASTREQ
b9ba6d
 			      && readdfcts[runp->type] != NULL);
b9ba6d
 
b9ba6d
-		      readdfcts[runp->type] (table, runp, dh);
b9ba6d
+		      time_t timeout = readdfcts[runp->type] (table, runp, dh);
b9ba6d
+		      next_timeout = MIN (next_timeout, timeout);
b9ba6d
 
b9ba6d
 		      /* If the entry has been replaced, we might need
b9ba6d
 			 cleanup.  */
b9ba6d
Index: glibc-2.12-2-gc4ccff1/nscd/connections.c
b9ba6d
===================================================================
b9ba6d
--- glibc-2.12-2-gc4ccff1.orig/nscd/connections.c
b9ba6d
+++ glibc-2.12-2-gc4ccff1/nscd/connections.c
b9ba6d
@@ -1533,10 +1533,7 @@ nscd_run_prune (void *p)
b9ba6d
 	     pruning we want to know about it.  Therefore set the
b9ba6d
 	     timeout to the maximum.  It will be descreased when adding
b9ba6d
 	     new entries to the cache, if necessary.  */
b9ba6d
-	  if (sizeof (time_t) == sizeof (long int))
b9ba6d
-	    dbs[my_number].wakeup_time = LONG_MAX;
b9ba6d
-	  else
b9ba6d
-	    dbs[my_number].wakeup_time = INT_MAX;
b9ba6d
+	  dbs[my_number].wakeup_time = MAX_TIMEOUT_VALUE;
b9ba6d
 
b9ba6d
 	  /* Unconditionally reset the flag.  */
b9ba6d
 	  time_t prune_now = dbs[my_number].clear_cache ? LONG_MAX : now;
b9ba6d
Index: glibc-2.12-2-gc4ccff1/nscd/grpcache.c
b9ba6d
===================================================================
b9ba6d
--- glibc-2.12-2-gc4ccff1.orig/nscd/grpcache.c
b9ba6d
+++ glibc-2.12-2-gc4ccff1/nscd/grpcache.c
b9ba6d
@@ -71,7 +71,7 @@ static const gr_response_header notfound
b9ba6d
 };
b9ba6d
 
b9ba6d
 
b9ba6d
-static void
b9ba6d
+static time_t
b9ba6d
 cache_addgr (struct database_dyn *db, int fd, request_header *req,
b9ba6d
 	     const void *key, struct group *grp, uid_t owner,
b9ba6d
 	     struct hashentry *const he, struct datahead *dh, int errval)
b9ba6d
@@ -91,6 +91,7 @@ cache_addgr (struct database_dyn *db, in
b9ba6d
 
b9ba6d
   assert (offsetof (struct dataset, resp) == offsetof (struct datahead, data));
b9ba6d
 
b9ba6d
+  time_t timeout = MAX_TIMEOUT_VALUE;
b9ba6d
   if (grp == NULL)
b9ba6d
     {
b9ba6d
       if (he != NULL && errval == EAGAIN)
b9ba6d
@@ -102,6 +103,9 @@ cache_addgr (struct database_dyn *db, in
b9ba6d
 	    /* Do not reset the value if we never not reload the record.  */
b9ba6d
 	    dh->nreloads = reload_count - 1;
b9ba6d
 
b9ba6d
+	  /* Reload with the same time-to-live value.  */
b9ba6d
+	  timeout = dh->timeout = t + db->postimeout;
b9ba6d
+
b9ba6d
 	  written = total = 0;
b9ba6d
 	}
b9ba6d
       else
b9ba6d
@@ -125,7 +129,7 @@ cache_addgr (struct database_dyn *db, in
b9ba6d
 	      dataset->head.usable = true;
b9ba6d
 
b9ba6d
 	      /* Compute the timeout time.  */
b9ba6d
-	      dataset->head.timeout = t + db->negtimeout;
b9ba6d
+	      timeout = dataset->head.timeout = t + db->negtimeout;
b9ba6d
 
b9ba6d
 	      /* This is the reply.  */
b9ba6d
 	      memcpy (&dataset->resp, &notfound, total);
b9ba6d
@@ -217,7 +221,7 @@ cache_addgr (struct database_dyn *db, in
b9ba6d
       dataset->head.usable = true;
b9ba6d
 
b9ba6d
       /* Compute the timeout time.  */
b9ba6d
-      dataset->head.timeout = t + db->postimeout;
b9ba6d
+      timeout = dataset->head.timeout = t + db->postimeout;
b9ba6d
 
b9ba6d
       dataset->resp.version = NSCD_VERSION;
b9ba6d
       dataset->resp.found = 1;
b9ba6d
@@ -379,6 +383,8 @@ cache_addgr (struct database_dyn *db, in
b9ba6d
       dbg_log (_("short write in %s: %s"),  __FUNCTION__,
b9ba6d
 	       strerror_r (errno, buf, sizeof (buf)));
b9ba6d
     }
b9ba6d
+
b9ba6d
+  return timeout;
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
@@ -400,7 +406,7 @@ lookup (int type, union keytype key, str
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
-static void
b9ba6d
+static time_t
b9ba6d
 addgrbyX (struct database_dyn *db, int fd, request_header *req,
b9ba6d
 	  union keytype key, const char *keystr, uid_t uid,
b9ba6d
 	  struct hashentry *he, struct datahead *dh)
b9ba6d
@@ -456,10 +462,12 @@ addgrbyX (struct database_dyn *db, int f
b9ba6d
 	buffer = (char *) extend_alloca (buffer, buflen, 2 * buflen);
b9ba6d
     }
b9ba6d
 
b9ba6d
-  cache_addgr (db, fd, req, keystr, grp, uid, he, dh, errval);
b9ba6d
+  time_t timeout = cache_addgr (db, fd, req, keystr, grp, uid, he, dh, errval);
b9ba6d
 
b9ba6d
   if (use_malloc)
b9ba6d
     free (buffer);
b9ba6d
+
b9ba6d
+  return timeout;
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
@@ -473,7 +481,7 @@ addgrbyname (struct database_dyn *db, in
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
-void
b9ba6d
+time_t
b9ba6d
 readdgrbyname (struct database_dyn *db, struct hashentry *he,
b9ba6d
 	       struct datahead *dh)
b9ba6d
 {
b9ba6d
@@ -484,7 +492,7 @@ readdgrbyname (struct database_dyn *db, 
b9ba6d
     };
b9ba6d
   union keytype u = { .v = db->data + he->key };
b9ba6d
 
b9ba6d
-  addgrbyX (db, -1, &req, u, db->data + he->key, he->owner, he, dh);
b9ba6d
+  return addgrbyX (db, -1, &req, u, db->data + he->key, he->owner, he, dh);
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
@@ -510,7 +518,7 @@ addgrbygid (struct database_dyn *db, int
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
-void
b9ba6d
+time_t
b9ba6d
 readdgrbygid (struct database_dyn *db, struct hashentry *he,
b9ba6d
 	      struct datahead *dh)
b9ba6d
 {
b9ba6d
@@ -527,5 +535,5 @@ readdgrbygid (struct database_dyn *db, s
b9ba6d
     };
b9ba6d
   union keytype u = { .g = gid };
b9ba6d
 
b9ba6d
-  addgrbyX (db, -1, &req, u, db->data + he->key, he->owner, he, dh);
b9ba6d
+  return addgrbyX (db, -1, &req, u, db->data + he->key, he->owner, he, dh);
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
@@ -91,7 +91,7 @@ static const hst_response_header tryagai
b9ba6d
 };
b9ba6d
 
b9ba6d
 
b9ba6d
-static void
b9ba6d
+static time_t
b9ba6d
 cache_addhst (struct database_dyn *db, int fd, request_header *req,
b9ba6d
 	      const void *key, struct hostent *hst, uid_t owner,
b9ba6d
 	      struct hashentry *const he, struct datahead *dh, int errval,
b9ba6d
@@ -111,6 +111,7 @@ cache_addhst (struct database_dyn *db, i
b9ba6d
 
b9ba6d
   assert (offsetof (struct dataset, resp) == offsetof (struct datahead, data));
b9ba6d
 
b9ba6d
+  time_t timeout = MAX_TIMEOUT_VALUE;
b9ba6d
   if (hst == NULL)
b9ba6d
     {
b9ba6d
       if (he != NULL && errval == EAGAIN)
b9ba6d
@@ -121,6 +122,9 @@ cache_addhst (struct database_dyn *db, i
b9ba6d
 	  if (reload_count != UINT_MAX)
b9ba6d
 	    /* Do not reset the value if we never not reload the record.  */
b9ba6d
 	    dh->nreloads = reload_count - 1;
b9ba6d
+
b9ba6d
+	  /* Reload with the same time-to-live value.  */
b9ba6d
+	  timeout = dh->timeout = t + dh->ttl;
b9ba6d
 	}
b9ba6d
       else
b9ba6d
 	{
b9ba6d
@@ -149,8 +153,8 @@ cache_addhst (struct database_dyn *db, i
b9ba6d
 	      dataset->head.usable = true;
b9ba6d
 
b9ba6d
 	      /* Compute the timeout time.  */
b9ba6d
-	      dataset->head.timeout = t + (ttl == INT32_MAX
b9ba6d
-					   ? db->negtimeout : ttl);
b9ba6d
+	      dataset->head.ttl = ttl == INT32_MAX ? db->negtimeout : ttl;
b9ba6d
+	      timeout = dataset->head.timeout = t + dataset->head.ttl;
b9ba6d
 
b9ba6d
 	      /* This is the reply.  */
b9ba6d
 	      memcpy (&dataset->resp, resp, total);
b9ba6d
@@ -214,7 +218,7 @@ cache_addhst (struct database_dyn *db, i
b9ba6d
 
b9ba6d
       if (h_addr_list_cnt == 0)
b9ba6d
 	/* Invalid entry.  */
b9ba6d
-	return;
b9ba6d
+	return MAX_TIMEOUT_VALUE;
b9ba6d
 
b9ba6d
       total += (sizeof (struct dataset)
b9ba6d
 		+ h_name_len
b9ba6d
@@ -255,7 +259,8 @@ cache_addhst (struct database_dyn *db, i
b9ba6d
       dataset->head.usable = true;
b9ba6d
 
b9ba6d
       /* Compute the timeout time.  */
b9ba6d
-      dataset->head.timeout = t + (ttl == INT32_MAX ? db->postimeout : ttl);
b9ba6d
+      dataset->head.ttl = ttl == INT32_MAX ? db->postimeout : ttl;
b9ba6d
+      timeout = dataset->head.timeout = t + dataset->head.ttl;
b9ba6d
 
b9ba6d
       dataset->resp.version = NSCD_VERSION;
b9ba6d
       dataset->resp.found = 1;
b9ba6d
@@ -312,6 +317,7 @@ cache_addhst (struct database_dyn *db, i
b9ba6d
 		 timeout value.  Note that the new record has been
b9ba6d
 		 allocated on the stack and need not be freed.  */
b9ba6d
 	      assert (h_addr_list_cnt == 1);
b9ba6d
+	      dh->ttl = dataset->head.ttl;
b9ba6d
 	      dh->timeout = dataset->head.timeout;
b9ba6d
 	      ++dh->nreloads;
b9ba6d
 	    }
b9ba6d
@@ -433,6 +439,8 @@ cache_addhst (struct database_dyn *db, i
b9ba6d
       dbg_log (_("short write in %s: %s"),  __FUNCTION__,
b9ba6d
 	       strerror_r (errno, buf, sizeof (buf)));
b9ba6d
     }
b9ba6d
+
b9ba6d
+  return timeout;
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
@@ -454,7 +462,7 @@ lookup (int type, void *key, struct host
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
-static void
b9ba6d
+static time_t
b9ba6d
 addhstbyX (struct database_dyn *db, int fd, request_header *req,
b9ba6d
 	   void *key, uid_t uid, struct hashentry *he, struct datahead *dh)
b9ba6d
 {
b9ba6d
@@ -520,11 +528,13 @@ addhstbyX (struct database_dyn *db, int 
b9ba6d
 	buffer = (char *) extend_alloca (buffer, buflen, 2 * buflen);
b9ba6d
     }
b9ba6d
 
b9ba6d
-  cache_addhst (db, fd, req, key, hst, uid, he, dh,
b9ba6d
-		h_errno == TRY_AGAIN ? errval : 0, ttl);
b9ba6d
+  time_t timeout = cache_addhst (db, fd, req, key, hst, uid, he, dh,
b9ba6d
+				 h_errno == TRY_AGAIN ? errval : 0, ttl);
b9ba6d
 
b9ba6d
   if (use_malloc)
b9ba6d
     free (buffer);
b9ba6d
+
b9ba6d
+  return timeout;
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
@@ -536,7 +546,7 @@ addhstbyname (struct database_dyn *db, i
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
-void
b9ba6d
+time_t
b9ba6d
 readdhstbyname (struct database_dyn *db, struct hashentry *he,
b9ba6d
 		struct datahead *dh)
b9ba6d
 {
b9ba6d
@@ -546,7 +556,7 @@ readdhstbyname (struct database_dyn *db,
b9ba6d
       .key_len = he->len
b9ba6d
     };
b9ba6d
 
b9ba6d
-  addhstbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
b9ba6d
+  return addhstbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
@@ -558,7 +568,7 @@ addhstbyaddr (struct database_dyn *db, i
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
-void
b9ba6d
+time_t
b9ba6d
 readdhstbyaddr (struct database_dyn *db, struct hashentry *he,
b9ba6d
 		struct datahead *dh)
b9ba6d
 {
b9ba6d
@@ -568,7 +578,7 @@ readdhstbyaddr (struct database_dyn *db,
b9ba6d
       .key_len = he->len
b9ba6d
     };
b9ba6d
 
b9ba6d
-  addhstbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
b9ba6d
+  return addhstbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
@@ -580,7 +590,7 @@ addhstbynamev6 (struct database_dyn *db,
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
-void
b9ba6d
+time_t
b9ba6d
 readdhstbynamev6 (struct database_dyn *db, struct hashentry *he,
b9ba6d
 		  struct datahead *dh)
b9ba6d
 {
b9ba6d
@@ -590,7 +600,7 @@ readdhstbynamev6 (struct database_dyn *d
b9ba6d
       .key_len = he->len
b9ba6d
     };
b9ba6d
 
b9ba6d
-  addhstbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
b9ba6d
+  return addhstbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
@@ -602,7 +612,7 @@ addhstbyaddrv6 (struct database_dyn *db,
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
-void
b9ba6d
+time_t
b9ba6d
 readdhstbyaddrv6 (struct database_dyn *db, struct hashentry *he,
b9ba6d
 		  struct datahead *dh)
b9ba6d
 {
b9ba6d
@@ -612,5 +622,5 @@ readdhstbyaddrv6 (struct database_dyn *d
b9ba6d
       .key_len = he->len
b9ba6d
     };
b9ba6d
 
b9ba6d
-  addhstbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
b9ba6d
+  return addhstbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
b9ba6d
 }
b9ba6d
Index: glibc-2.12-2-gc4ccff1/nscd/initgrcache.c
b9ba6d
===================================================================
b9ba6d
--- glibc-2.12-2-gc4ccff1.orig/nscd/initgrcache.c
b9ba6d
+++ glibc-2.12-2-gc4ccff1/nscd/initgrcache.c
b9ba6d
@@ -52,7 +52,7 @@ static const initgr_response_header notf
b9ba6d
 #include "../grp/compat-initgroups.c"
b9ba6d
 
b9ba6d
 
b9ba6d
-static void
b9ba6d
+static time_t
b9ba6d
 addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
b9ba6d
 		void *key, uid_t uid, struct hashentry *const he,
b9ba6d
 		struct datahead *dh)
b9ba6d
@@ -174,7 +174,9 @@ addinitgroupsX (struct database_dyn *db,
b9ba6d
 
b9ba6d
   ssize_t total;
b9ba6d
   ssize_t written;
b9ba6d
+  time_t timeout;
b9ba6d
  out:
b9ba6d
+  timeout = MAX_TIMEOUT_VALUE;
b9ba6d
   if (!any_success)
b9ba6d
     {
b9ba6d
       /* Nothing found.  Create a negative result record.  */
b9ba6d
@@ -188,6 +190,9 @@ addinitgroupsX (struct database_dyn *db,
b9ba6d
 	  if (reload_count != UINT_MAX && dh->nreloads == reload_count)
b9ba6d
 	    /* Do not reset the value if we never not reload the record.  */
b9ba6d
 	    dh->nreloads = reload_count - 1;
b9ba6d
+
b9ba6d
+	  /* Reload with the same time-to-live value.  */
b9ba6d
+	  timeout = dh->timeout = time (NULL) + db->postimeout;
b9ba6d
 	}
b9ba6d
       else
b9ba6d
 	{
b9ba6d
@@ -209,7 +214,7 @@ addinitgroupsX (struct database_dyn *db,
b9ba6d
 	      dataset->head.usable = true;
b9ba6d
 
b9ba6d
 	      /* Compute the timeout time.  */
b9ba6d
-	      dataset->head.timeout = time (NULL) + db->negtimeout;
b9ba6d
+	      timeout = dataset->head.timeout = time (NULL) + db->negtimeout;
b9ba6d
 
b9ba6d
 	      /* This is the reply.  */
b9ba6d
 	      memcpy (&dataset->resp, &notfound, total);
b9ba6d
@@ -273,7 +278,7 @@ addinitgroupsX (struct database_dyn *db,
b9ba6d
       dataset->head.usable = true;
b9ba6d
 
b9ba6d
       /* Compute the timeout time.  */
b9ba6d
-      dataset->head.timeout = time (NULL) + db->postimeout;
b9ba6d
+      timeout = dataset->head.timeout = time (NULL) + db->postimeout;
b9ba6d
 
b9ba6d
       dataset->resp.version = NSCD_VERSION;
b9ba6d
       dataset->resp.found = 1;
b9ba6d
@@ -401,6 +406,8 @@ addinitgroupsX (struct database_dyn *db,
b9ba6d
       dbg_log (_("short write in %s: %s"), __FUNCTION__,
b9ba6d
 	       strerror_r (errno, buf, sizeof (buf)));
b9ba6d
     }
b9ba6d
+
b9ba6d
+  return timeout;
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
@@ -412,7 +419,7 @@ addinitgroups (struct database_dyn *db, 
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
-void
b9ba6d
+time_t
b9ba6d
 readdinitgroups (struct database_dyn *db, struct hashentry *he,
b9ba6d
 		 struct datahead *dh)
b9ba6d
 {
b9ba6d
@@ -422,5 +429,5 @@ readdinitgroups (struct database_dyn *db
b9ba6d
       .key_len = he->len
b9ba6d
     };
b9ba6d
 
b9ba6d
-  addinitgroupsX (db, -1, &req, db->data + he->key, he->owner, he, dh);
b9ba6d
+  return addinitgroupsX (db, -1, &req, db->data + he->key, he->owner, he, dh);
b9ba6d
 }
b9ba6d
Index: glibc-2.12-2-gc4ccff1/nscd/nscd-client.h
b9ba6d
===================================================================
b9ba6d
--- glibc-2.12-2-gc4ccff1.orig/nscd/nscd-client.h
b9ba6d
+++ glibc-2.12-2-gc4ccff1/nscd/nscd-client.h
b9ba6d
@@ -179,6 +179,10 @@ typedef uint32_t ref_t;
b9ba6d
 /* Timestamp type.  */
b9ba6d
 typedef uint64_t nscd_time_t;
b9ba6d
 
b9ba6d
+/* Maximum timestamp.  */
b9ba6d
+#define MAX_TIMEOUT_VALUE \
b9ba6d
+  (sizeof (time_t) == sizeof (long int) ? LONG_MAX : INT_MAX)
b9ba6d
+
b9ba6d
 /* Alignment requirement of the beginning of the data region.  */
b9ba6d
 #define ALIGN 16
b9ba6d
 
b9ba6d
@@ -192,7 +196,8 @@ struct datahead
b9ba6d
   uint8_t notfound;		/* Nonzero if data has not been found.  */
b9ba6d
   uint8_t nreloads;		/* Reloads without use.  */
b9ba6d
   uint8_t usable;		/* False if the entry must be ignored.  */
b9ba6d
-  uint64_t :40;			/* Alignment.  */
b9ba6d
+  uint8_t unused;		/* Unused.  */
b9ba6d
+  uint32_t ttl;			/* TTL value used.  */
b9ba6d
 
b9ba6d
   /* We need to have the following element aligned for the response
b9ba6d
      header data types and their use in the 'struct dataset' types
b9ba6d
Index: glibc-2.12-2-gc4ccff1/nscd/nscd.h
b9ba6d
===================================================================
b9ba6d
--- glibc-2.12-2-gc4ccff1.orig/nscd/nscd.h
b9ba6d
+++ glibc-2.12-2-gc4ccff1/nscd/nscd.h
b9ba6d
@@ -217,20 +217,20 @@ extern void addpwbyname (struct database
b9ba6d
 			 void *key, uid_t uid);
b9ba6d
 extern void addpwbyuid (struct database_dyn *db, int fd, request_header *req,
b9ba6d
 			void *key, uid_t uid);
b9ba6d
-extern void readdpwbyname (struct database_dyn *db, struct hashentry *he,
b9ba6d
-			   struct datahead *dh);
b9ba6d
-extern void readdpwbyuid (struct database_dyn *db, struct hashentry *he,
b9ba6d
-			  struct datahead *dh);
b9ba6d
+extern time_t readdpwbyname (struct database_dyn *db, struct hashentry *he,
b9ba6d
+			     struct datahead *dh);
b9ba6d
+extern time_t readdpwbyuid (struct database_dyn *db, struct hashentry *he,
b9ba6d
+			    struct datahead *dh);
b9ba6d
 
b9ba6d
 /* grpcache.c */
b9ba6d
 extern void addgrbyname (struct database_dyn *db, int fd, request_header *req,
b9ba6d
 			 void *key, uid_t uid);
b9ba6d
 extern void addgrbygid (struct database_dyn *db, int fd, request_header *req,
b9ba6d
 			void *key, uid_t uid);
b9ba6d
-extern void readdgrbyname (struct database_dyn *db, struct hashentry *he,
b9ba6d
-			   struct datahead *dh);
b9ba6d
-extern void readdgrbygid (struct database_dyn *db, struct hashentry *he,
b9ba6d
-			  struct datahead *dh);
b9ba6d
+extern time_t readdgrbyname (struct database_dyn *db, struct hashentry *he,
b9ba6d
+			     struct datahead *dh);
b9ba6d
+extern time_t readdgrbygid (struct database_dyn *db, struct hashentry *he,
b9ba6d
+			    struct datahead *dh);
b9ba6d
 
b9ba6d
 /* hstcache.c */
b9ba6d
 extern void addhstbyname (struct database_dyn *db, int fd, request_header *req,
b9ba6d
@@ -241,37 +241,37 @@ extern void addhstbynamev6 (struct datab
b9ba6d
 			    request_header *req, void *key, uid_t uid);
b9ba6d
 extern void addhstbyaddrv6 (struct database_dyn *db, int fd,
b9ba6d
 			    request_header *req, void *key, uid_t uid);
b9ba6d
-extern void readdhstbyname (struct database_dyn *db, struct hashentry *he,
b9ba6d
-			    struct datahead *dh);
b9ba6d
-extern void readdhstbyaddr (struct database_dyn *db, struct hashentry *he,
b9ba6d
-			    struct datahead *dh);
b9ba6d
-extern void readdhstbynamev6 (struct database_dyn *db, struct hashentry *he,
b9ba6d
+extern time_t readdhstbyname (struct database_dyn *db, struct hashentry *he,
b9ba6d
 			      struct datahead *dh);
b9ba6d
-extern void readdhstbyaddrv6 (struct database_dyn *db, struct hashentry *he,
b9ba6d
+extern time_t readdhstbyaddr (struct database_dyn *db, struct hashentry *he,
b9ba6d
 			      struct datahead *dh);
b9ba6d
+extern time_t readdhstbynamev6 (struct database_dyn *db, struct hashentry *he,
b9ba6d
+				struct datahead *dh);
b9ba6d
+extern time_t readdhstbyaddrv6 (struct database_dyn *db, struct hashentry *he,
b9ba6d
+				struct datahead *dh);
b9ba6d
 
b9ba6d
 /* aicache.c */
b9ba6d
 extern void addhstai (struct database_dyn *db, int fd, request_header *req,
b9ba6d
 		      void *key, uid_t uid);
b9ba6d
-extern void readdhstai (struct database_dyn *db, struct hashentry *he,
b9ba6d
-			struct datahead *dh);
b9ba6d
+extern time_t readdhstai (struct database_dyn *db, struct hashentry *he,
b9ba6d
+			  struct datahead *dh);
b9ba6d
 
b9ba6d
 
b9ba6d
 /* initgrcache.c */
b9ba6d
 extern void addinitgroups (struct database_dyn *db, int fd,
b9ba6d
 			   request_header *req, void *key, uid_t uid);
b9ba6d
-extern void readdinitgroups (struct database_dyn *db, struct hashentry *he,
b9ba6d
-			     struct datahead *dh);
b9ba6d
+extern time_t readdinitgroups (struct database_dyn *db, struct hashentry *he,
b9ba6d
+			       struct datahead *dh);
b9ba6d
 
b9ba6d
 /* servicecache.c */
b9ba6d
 extern void addservbyname (struct database_dyn *db, int fd,
b9ba6d
 			   request_header *req, void *key, uid_t uid);
b9ba6d
-extern void readdservbyname (struct database_dyn *db, struct hashentry *he,
b9ba6d
-			     struct datahead *dh);
b9ba6d
+extern time_t readdservbyname (struct database_dyn *db, struct hashentry *he,
b9ba6d
+			       struct datahead *dh);
b9ba6d
 extern void addservbyport (struct database_dyn *db, int fd,
b9ba6d
 			   request_header *req, void *key, uid_t uid);
b9ba6d
-extern void readdservbyport (struct database_dyn *db, struct hashentry *he,
b9ba6d
-			     struct datahead *dh);
b9ba6d
+extern time_t readdservbyport (struct database_dyn *db, struct hashentry *he,
b9ba6d
+			       struct datahead *dh);
b9ba6d
 
b9ba6d
 /* mem.c */
b9ba6d
 extern void *mempool_alloc (struct database_dyn *db, size_t len,
b9ba6d
Index: glibc-2.12-2-gc4ccff1/nscd/pwdcache.c
b9ba6d
===================================================================
b9ba6d
--- glibc-2.12-2-gc4ccff1.orig/nscd/pwdcache.c
b9ba6d
+++ glibc-2.12-2-gc4ccff1/nscd/pwdcache.c
b9ba6d
@@ -77,7 +77,7 @@ static const pw_response_header notfound
b9ba6d
 };
b9ba6d
 
b9ba6d
 
b9ba6d
-static void
b9ba6d
+static time_t
b9ba6d
 cache_addpw (struct database_dyn *db, int fd, request_header *req,
b9ba6d
 	     const void *key, struct passwd *pwd, uid_t owner,
b9ba6d
 	     struct hashentry *const he, struct datahead *dh, int errval)
b9ba6d
@@ -97,6 +97,7 @@ cache_addpw (struct database_dyn *db, in
b9ba6d
 
b9ba6d
   assert (offsetof (struct dataset, resp) == offsetof (struct datahead, data));
b9ba6d
 
b9ba6d
+  time_t timeout = MAX_TIMEOUT_VALUE;
b9ba6d
   if (pwd == NULL)
b9ba6d
     {
b9ba6d
       if (he != NULL && errval == EAGAIN)
b9ba6d
@@ -108,6 +109,9 @@ cache_addpw (struct database_dyn *db, in
b9ba6d
 	    /* Do not reset the value if we never not reload the record.  */
b9ba6d
 	    dh->nreloads = reload_count - 1;
b9ba6d
 
b9ba6d
+	  /* Reload with the same time-to-live value.  */
b9ba6d
+	  timeout = dh->timeout = t + db->postimeout;
b9ba6d
+
b9ba6d
 	  written = total = 0;
b9ba6d
 	}
b9ba6d
       else
b9ba6d
@@ -132,7 +136,7 @@ cache_addpw (struct database_dyn *db, in
b9ba6d
 	      dataset->head.usable = true;
b9ba6d
 
b9ba6d
 	      /* Compute the timeout time.  */
b9ba6d
-	      dataset->head.timeout = t + db->negtimeout;
b9ba6d
+	      timeout = dataset->head.timeout = t + db->negtimeout;
b9ba6d
 
b9ba6d
 	      /* This is the reply.  */
b9ba6d
 	      memcpy (&dataset->resp, &notfound, total);
b9ba6d
@@ -212,7 +216,7 @@ cache_addpw (struct database_dyn *db, in
b9ba6d
       dataset->head.usable = true;
b9ba6d
 
b9ba6d
       /* Compute the timeout time.  */
b9ba6d
-      dataset->head.timeout = t + db->postimeout;
b9ba6d
+      timeout = dataset->head.timeout = t + db->postimeout;
b9ba6d
 
b9ba6d
       dataset->resp.version = NSCD_VERSION;
b9ba6d
       dataset->resp.found = 1;
b9ba6d
@@ -293,8 +297,8 @@ cache_addpw (struct database_dyn *db, in
b9ba6d
 	      assert ((char *) dataset - (char *) db->head
b9ba6d
 		      + total
b9ba6d
 		      <= (sizeof (struct database_pers_head)
b9ba6d
-                          + db->head->module * sizeof (ref_t)
b9ba6d
-                          + db->head->data_size));
b9ba6d
+			  + db->head->module * sizeof (ref_t)
b9ba6d
+			  + db->head->data_size));
b9ba6d
 	      written = sendfileall (fd, db->wr_fd,
b9ba6d
 				     (char *) &dataset->resp
b9ba6d
 				     - (char *) db->head, dataset->head.recsize );
b9ba6d
@@ -374,6 +378,8 @@ cache_addpw (struct database_dyn *db, in
b9ba6d
       dbg_log (_("short write in %s: %s"),  __FUNCTION__,
b9ba6d
 	       strerror_r (errno, buf, sizeof (buf)));
b9ba6d
     }
b9ba6d
+
b9ba6d
+  return timeout;
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
@@ -395,7 +401,7 @@ lookup (int type, union keytype key, str
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
-static void
b9ba6d
+static time_t
b9ba6d
 addpwbyX (struct database_dyn *db, int fd, request_header *req,
b9ba6d
 	  union keytype key, const char *keystr, uid_t c_uid,
b9ba6d
 	  struct hashentry *he, struct datahead *dh)
b9ba6d
@@ -452,10 +458,13 @@ addpwbyX (struct database_dyn *db, int f
b9ba6d
     }
b9ba6d
 
b9ba6d
   /* Add the entry to the cache.  */
b9ba6d
-  cache_addpw (db, fd, req, keystr, pwd, c_uid, he, dh, errval);
b9ba6d
+  time_t timeout = cache_addpw (db, fd, req, keystr, pwd, c_uid, he, dh,
b9ba6d
+				errval);
b9ba6d
 
b9ba6d
   if (use_malloc)
b9ba6d
     free (buffer);
b9ba6d
+
b9ba6d
+  return timeout;
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
@@ -469,7 +478,7 @@ addpwbyname (struct database_dyn *db, in
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
-void
b9ba6d
+time_t
b9ba6d
 readdpwbyname (struct database_dyn *db, struct hashentry *he,
b9ba6d
 	       struct datahead *dh)
b9ba6d
 {
b9ba6d
@@ -480,7 +489,7 @@ readdpwbyname (struct database_dyn *db, 
b9ba6d
     };
b9ba6d
   union keytype u = { .v = db->data + he->key };
b9ba6d
 
b9ba6d
-  addpwbyX (db, -1, &req, u, db->data + he->key, he->owner, he, dh);
b9ba6d
+  return addpwbyX (db, -1, &req, u, db->data + he->key, he->owner, he, dh);
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
@@ -506,7 +515,7 @@ addpwbyuid (struct database_dyn *db, int
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
-void
b9ba6d
+time_t
b9ba6d
 readdpwbyuid (struct database_dyn *db, struct hashentry *he,
b9ba6d
 	      struct datahead *dh)
b9ba6d
 {
b9ba6d
@@ -523,5 +532,5 @@ readdpwbyuid (struct database_dyn *db, s
b9ba6d
     };
b9ba6d
   union keytype u = { .u = uid };
b9ba6d
 
b9ba6d
-  addpwbyX (db, -1, &req, u, db->data + he->key, he->owner, he, dh);
b9ba6d
+  return addpwbyX (db, -1, &req, u, db->data + he->key, he->owner, he, dh);
b9ba6d
 }
b9ba6d
Index: glibc-2.12-2-gc4ccff1/nscd/servicescache.c
b9ba6d
===================================================================
b9ba6d
--- glibc-2.12-2-gc4ccff1.orig/nscd/servicescache.c
b9ba6d
+++ glibc-2.12-2-gc4ccff1/nscd/servicescache.c
b9ba6d
@@ -61,7 +61,7 @@ static const serv_response_header notfou
b9ba6d
 };
b9ba6d
 
b9ba6d
 
b9ba6d
-static void
b9ba6d
+static time_t
b9ba6d
 cache_addserv (struct database_dyn *db, int fd, request_header *req,
b9ba6d
 	       const void *key, struct servent *serv, uid_t owner,
b9ba6d
 	       struct hashentry *const he, struct datahead *dh, int errval)
b9ba6d
@@ -81,6 +81,7 @@ cache_addserv (struct database_dyn *db, 
b9ba6d
 
b9ba6d
   assert (offsetof (struct dataset, resp) == offsetof (struct datahead, data));
b9ba6d
 
b9ba6d
+  time_t timeout = MAX_TIMEOUT_VALUE;
b9ba6d
   if (serv == NULL)
b9ba6d
     {
b9ba6d
       if (he != NULL && errval == EAGAIN)
b9ba6d
@@ -92,6 +93,9 @@ cache_addserv (struct database_dyn *db, 
b9ba6d
 	    /* Do not reset the value if we never not reload the record.  */
b9ba6d
 	    dh->nreloads = reload_count - 1;
b9ba6d
 
b9ba6d
+	  /* Reload with the same time-to-live value.  */
b9ba6d
+	  timeout = dh->timeout = t + db->postimeout;
b9ba6d
+
b9ba6d
 	  written = total = 0;
b9ba6d
 	}
b9ba6d
       else
b9ba6d
@@ -115,7 +119,7 @@ cache_addserv (struct database_dyn *db, 
b9ba6d
 	      dataset->head.usable = true;
b9ba6d
 
b9ba6d
 	      /* Compute the timeout time.  */
b9ba6d
-	      dataset->head.timeout = t + db->negtimeout;
b9ba6d
+	      timeout = dataset->head.timeout = t + db->negtimeout;
b9ba6d
 
b9ba6d
 	      /* This is the reply.  */
b9ba6d
 	      memcpy (&dataset->resp, &notfound, total);
b9ba6d
@@ -203,7 +207,7 @@ cache_addserv (struct database_dyn *db, 
b9ba6d
       dataset->head.usable = true;
b9ba6d
 
b9ba6d
       /* Compute the timeout time.  */
b9ba6d
-      dataset->head.timeout = t + db->postimeout;
b9ba6d
+      timeout = dataset->head.timeout = t + db->postimeout;
b9ba6d
 
b9ba6d
       dataset->resp.version = NSCD_VERSION;
b9ba6d
       dataset->resp.found = 1;
b9ba6d
@@ -328,6 +332,8 @@ cache_addserv (struct database_dyn *db, 
b9ba6d
       dbg_log (_("short write in %s: %s"),  __FUNCTION__,
b9ba6d
 	       strerror_r (errno, buf, sizeof (buf)));
b9ba6d
     }
b9ba6d
+
b9ba6d
+  return timeout;
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
@@ -354,7 +360,7 @@ lookup (int type, char *key, struct serv
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
-static void
b9ba6d
+static time_t
b9ba6d
 addservbyX (struct database_dyn *db, int fd, request_header *req,
b9ba6d
 	    char *key, uid_t uid, struct hashentry *he, struct datahead *dh)
b9ba6d
 {
b9ba6d
@@ -409,10 +415,12 @@ addservbyX (struct database_dyn *db, int
b9ba6d
 	buffer = (char *) extend_alloca (buffer, buflen, 2 * buflen);
b9ba6d
     }
b9ba6d
 
b9ba6d
-  cache_addserv (db, fd, req, key, serv, uid, he, dh, errval);
b9ba6d
+  time_t timeout = cache_addserv (db, fd, req, key, serv, uid, he, dh, errval);
b9ba6d
 
b9ba6d
   if (use_malloc)
b9ba6d
     free (buffer);
b9ba6d
+
b9ba6d
+  return timeout;
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
@@ -424,7 +432,7 @@ addservbyname (struct database_dyn *db, 
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
-void
b9ba6d
+time_t
b9ba6d
 readdservbyname (struct database_dyn *db, struct hashentry *he,
b9ba6d
 		 struct datahead *dh)
b9ba6d
 {
b9ba6d
@@ -434,7 +442,7 @@ readdservbyname (struct database_dyn *db
b9ba6d
       .key_len = he->len
b9ba6d
     };
b9ba6d
 
b9ba6d
-  addservbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
b9ba6d
+  return addservbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
@@ -446,7 +454,7 @@ addservbyport (struct database_dyn *db, 
b9ba6d
 }
b9ba6d
 
b9ba6d
 
b9ba6d
-void
b9ba6d
+time_t
b9ba6d
 readdservbyport (struct database_dyn *db, struct hashentry *he,
b9ba6d
 		 struct datahead *dh)
b9ba6d
 {
b9ba6d
@@ -456,5 +464,5 @@ readdservbyport (struct database_dyn *db
b9ba6d
       .key_len = he->len
b9ba6d
     };
b9ba6d
 
b9ba6d
-  addservbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
b9ba6d
+  return addservbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
b9ba6d
 }