Blame SOURCES/glibc-rh703481.patch

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