1 2011-02-05 Ulrich Drepper <drepper@gmail.com>
3 * nscd/nscd-client.h: Define MAX_TIMEOUT_VALUE.
4 (struct datahead): Reuse 32 bits of the alignment for a TTL field.
5 * nscd/aicache.c (addhstaiX): Return timeout of added value.
6 (readdhstai): Return value of addhstaiX call.
7 * nscd/grpcache.c (cache_addgr): Return timeout of added value.
8 (addgrbyX): Return value returned by cache_addgr.
9 (readdgrbyname): Return value returned by addgrbyX.
10 (readdgrbygid): Likewise.
11 * nscd/pwdcache.c (cache_addpw): Return timeout of added value.
12 (addpwbyX): Return value returned by cache_addpw.
13 (readdpwbyname): Return value returned by addhstbyX.
14 (readdpwbyuid): Likewise.
15 * nscd/servicescache.c (cache_addserv): Return timeout of added value.
16 (addservbyX): Return value returned by cache_addserv.
17 (readdservbyname): Return value returned by addservbyX:
18 (readdservbyport): Likewise.
19 * nscd/hstcache.c (cache_addhst): Return timeout of added value.
20 (addhstbyX): Return value returned by cache_addhst.
21 (readdhstbyname): Return value returned by addhstbyX.
22 (readdhstbyaddr): Likewise.
23 (readdhstbynamev6): Likewise.
24 (readdhstbyaddrv6): Likewise.
25 * nscd/initgrcache.c (addinitgroupsX): Return timeout of added value.
26 (readdinitgroups): Return value returned by addinitgroupsX.
27 * nscd/cache.c (readdfcts): Change return value of functions to time_t.
28 (prune_cache): Keep track of timeout value of re-added entries.
29 * nscd/connections.c (nscd_run_prune): Use MAX_TIMEOUT_VALUE.
30 * nscd/nscd.h: Adjust prototypes of readd* functions.
32 Index: glibc-2.12-2-gc4ccff1/nscd/aicache.c
33 ===================================================================
34 --- glibc-2.12-2-gc4ccff1.orig/nscd/aicache.c
35 +++ glibc-2.12-2-gc4ccff1/nscd/aicache.c
36 @@ -58,7 +58,7 @@ static const ai_response_header notfound
42 addhstaiX (struct database_dyn *db, int fd, request_header *req,
43 void *key, uid_t uid, struct hashentry *const he,
45 @@ -119,6 +119,7 @@ addhstaiX (struct database_dyn *db, int
47 char *key_copy = NULL;
48 bool alloca_used = false;
49 + time_t timeout = MAX_TIMEOUT_VALUE;
53 @@ -388,8 +389,8 @@ addhstaiX (struct database_dyn *db, int
54 dataset->head.usable = true;
56 /* Compute the timeout time. */
57 - dataset->head.timeout = time (NULL) + (ttl == INT32_MAX
58 - ? db->postimeout : ttl);
59 + dataset->head.ttl = ttl == INT32_MAX ? db->postimeout : ttl;
60 + timeout = dataset->head.timeout = time (NULL) + dataset->head.ttl;
62 dataset->resp.version = NSCD_VERSION;
63 dataset->resp.found = 1;
64 @@ -421,6 +422,7 @@ addhstaiX (struct database_dyn *db, int
65 timeout value. Note that the new record has been
66 allocated on the stack and need not be freed. */
67 dh->timeout = dataset->head.timeout;
68 + dh->ttl = dataset->head.ttl;
72 @@ -496,6 +498,9 @@ next_nip:
73 if (reload_count != UINT_MAX && dh->nreloads == reload_count)
74 /* Do not reset the value if we never not reload the record. */
75 dh->nreloads = reload_count - 1;
77 + /* Reload with the same time-to-live value. */
78 + timeout = dh->timeout = time (NULL) + dh->ttl;
82 @@ -517,7 +522,8 @@ next_nip:
83 dataset->head.usable = true;
85 /* Compute the timeout time. */
86 - dataset->head.timeout = time (NULL) + db->negtimeout;
87 + timeout = dataset->head.timeout = time (NULL) + db->negtimeout;
88 + dataset->head.ttl = db->negtimeout;
90 /* This is the reply. */
91 memcpy (&dataset->resp, ¬found, total);
92 @@ -551,6 +557,8 @@ next_nip:
101 @@ -562,7 +570,7 @@ addhstai (struct database_dyn *db, int f
107 readdhstai (struct database_dyn *db, struct hashentry *he, struct datahead *dh)
110 @@ -571,5 +579,5 @@ readdhstai (struct database_dyn *db, str
114 - addhstaiX (db, -1, &req, db->data + he->key, he->owner, he, dh);
115 + return addhstaiX (db, -1, &req, db->data + he->key, he->owner, he, dh);
117 Index: glibc-2.12-2-gc4ccff1/nscd/cache.c
118 ===================================================================
119 --- glibc-2.12-2-gc4ccff1.orig/nscd/cache.c
120 +++ glibc-2.12-2-gc4ccff1/nscd/cache.c
121 @@ -45,9 +45,9 @@ extern void *xcalloc (size_t n, size_t s
122 unsigned int reload_count = DEFAULT_RELOAD_LIMIT;
125 -static void (*const readdfcts[LASTREQ]) (struct database_dyn *,
126 - struct hashentry *,
127 - struct datahead *) =
128 +static time_t (*const readdfcts[LASTREQ]) (struct database_dyn *,
129 + struct hashentry *,
130 + struct datahead *) =
132 [GETPWBYNAME] = readdpwbyname,
133 [GETPWBYUID] = readdpwbyuid,
134 @@ -389,7 +389,8 @@ prune_cache (struct database_dyn *table,
135 assert (runp->type < LASTREQ
136 && readdfcts[runp->type] != NULL);
138 - readdfcts[runp->type] (table, runp, dh);
139 + time_t timeout = readdfcts[runp->type] (table, runp, dh);
140 + next_timeout = MIN (next_timeout, timeout);
142 /* If the entry has been replaced, we might need
144 Index: glibc-2.12-2-gc4ccff1/nscd/connections.c
145 ===================================================================
146 --- glibc-2.12-2-gc4ccff1.orig/nscd/connections.c
147 +++ glibc-2.12-2-gc4ccff1/nscd/connections.c
148 @@ -1533,10 +1533,7 @@ nscd_run_prune (void *p)
149 pruning we want to know about it. Therefore set the
150 timeout to the maximum. It will be descreased when adding
151 new entries to the cache, if necessary. */
152 - if (sizeof (time_t) == sizeof (long int))
153 - dbs[my_number].wakeup_time = LONG_MAX;
155 - dbs[my_number].wakeup_time = INT_MAX;
156 + dbs[my_number].wakeup_time = MAX_TIMEOUT_VALUE;
158 /* Unconditionally reset the flag. */
159 time_t prune_now = dbs[my_number].clear_cache ? LONG_MAX : now;
160 Index: glibc-2.12-2-gc4ccff1/nscd/grpcache.c
161 ===================================================================
162 --- glibc-2.12-2-gc4ccff1.orig/nscd/grpcache.c
163 +++ glibc-2.12-2-gc4ccff1/nscd/grpcache.c
164 @@ -71,7 +71,7 @@ static const gr_response_header notfound
170 cache_addgr (struct database_dyn *db, int fd, request_header *req,
171 const void *key, struct group *grp, uid_t owner,
172 struct hashentry *const he, struct datahead *dh, int errval)
173 @@ -91,6 +91,7 @@ cache_addgr (struct database_dyn *db, in
175 assert (offsetof (struct dataset, resp) == offsetof (struct datahead, data));
177 + time_t timeout = MAX_TIMEOUT_VALUE;
180 if (he != NULL && errval == EAGAIN)
181 @@ -102,6 +103,9 @@ cache_addgr (struct database_dyn *db, in
182 /* Do not reset the value if we never not reload the record. */
183 dh->nreloads = reload_count - 1;
185 + /* Reload with the same time-to-live value. */
186 + timeout = dh->timeout = t + db->postimeout;
191 @@ -125,7 +129,7 @@ cache_addgr (struct database_dyn *db, in
192 dataset->head.usable = true;
194 /* Compute the timeout time. */
195 - dataset->head.timeout = t + db->negtimeout;
196 + timeout = dataset->head.timeout = t + db->negtimeout;
198 /* This is the reply. */
199 memcpy (&dataset->resp, ¬found, total);
200 @@ -217,7 +221,7 @@ cache_addgr (struct database_dyn *db, in
201 dataset->head.usable = true;
203 /* Compute the timeout time. */
204 - dataset->head.timeout = t + db->postimeout;
205 + timeout = dataset->head.timeout = t + db->postimeout;
207 dataset->resp.version = NSCD_VERSION;
208 dataset->resp.found = 1;
209 @@ -379,6 +383,8 @@ cache_addgr (struct database_dyn *db, in
210 dbg_log (_("short write in %s: %s"), __FUNCTION__,
211 strerror_r (errno, buf, sizeof (buf)));
218 @@ -400,7 +406,7 @@ lookup (int type, union keytype key, str
224 addgrbyX (struct database_dyn *db, int fd, request_header *req,
225 union keytype key, const char *keystr, uid_t uid,
226 struct hashentry *he, struct datahead *dh)
227 @@ -456,10 +462,12 @@ addgrbyX (struct database_dyn *db, int f
228 buffer = (char *) extend_alloca (buffer, buflen, 2 * buflen);
231 - cache_addgr (db, fd, req, keystr, grp, uid, he, dh, errval);
232 + time_t timeout = cache_addgr (db, fd, req, keystr, grp, uid, he, dh, errval);
241 @@ -473,7 +481,7 @@ addgrbyname (struct database_dyn *db, in
247 readdgrbyname (struct database_dyn *db, struct hashentry *he,
250 @@ -484,7 +492,7 @@ readdgrbyname (struct database_dyn *db,
252 union keytype u = { .v = db->data + he->key };
254 - addgrbyX (db, -1, &req, u, db->data + he->key, he->owner, he, dh);
255 + return addgrbyX (db, -1, &req, u, db->data + he->key, he->owner, he, dh);
259 @@ -510,7 +518,7 @@ addgrbygid (struct database_dyn *db, int
265 readdgrbygid (struct database_dyn *db, struct hashentry *he,
268 @@ -527,5 +535,5 @@ readdgrbygid (struct database_dyn *db, s
270 union keytype u = { .g = gid };
272 - addgrbyX (db, -1, &req, u, db->data + he->key, he->owner, he, dh);
273 + return addgrbyX (db, -1, &req, u, db->data + he->key, he->owner, he, dh);
275 Index: glibc-2.12-2-gc4ccff1/nscd/hstcache.c
276 ===================================================================
277 --- glibc-2.12-2-gc4ccff1.orig/nscd/hstcache.c
278 +++ glibc-2.12-2-gc4ccff1/nscd/hstcache.c
279 @@ -91,7 +91,7 @@ static const hst_response_header tryagai
285 cache_addhst (struct database_dyn *db, int fd, request_header *req,
286 const void *key, struct hostent *hst, uid_t owner,
287 struct hashentry *const he, struct datahead *dh, int errval,
288 @@ -111,6 +111,7 @@ cache_addhst (struct database_dyn *db, i
290 assert (offsetof (struct dataset, resp) == offsetof (struct datahead, data));
292 + time_t timeout = MAX_TIMEOUT_VALUE;
295 if (he != NULL && errval == EAGAIN)
296 @@ -121,6 +122,9 @@ cache_addhst (struct database_dyn *db, i
297 if (reload_count != UINT_MAX)
298 /* Do not reset the value if we never not reload the record. */
299 dh->nreloads = reload_count - 1;
301 + /* Reload with the same time-to-live value. */
302 + timeout = dh->timeout = t + dh->ttl;
306 @@ -149,8 +153,8 @@ cache_addhst (struct database_dyn *db, i
307 dataset->head.usable = true;
309 /* Compute the timeout time. */
310 - dataset->head.timeout = t + (ttl == INT32_MAX
311 - ? db->negtimeout : ttl);
312 + dataset->head.ttl = ttl == INT32_MAX ? db->negtimeout : ttl;
313 + timeout = dataset->head.timeout = t + dataset->head.ttl;
315 /* This is the reply. */
316 memcpy (&dataset->resp, resp, total);
317 @@ -214,7 +218,7 @@ cache_addhst (struct database_dyn *db, i
319 if (h_addr_list_cnt == 0)
322 + return MAX_TIMEOUT_VALUE;
324 total += (sizeof (struct dataset)
326 @@ -255,7 +259,8 @@ cache_addhst (struct database_dyn *db, i
327 dataset->head.usable = true;
329 /* Compute the timeout time. */
330 - dataset->head.timeout = t + (ttl == INT32_MAX ? db->postimeout : ttl);
331 + dataset->head.ttl = ttl == INT32_MAX ? db->postimeout : ttl;
332 + timeout = dataset->head.timeout = t + dataset->head.ttl;
334 dataset->resp.version = NSCD_VERSION;
335 dataset->resp.found = 1;
336 @@ -312,6 +317,7 @@ cache_addhst (struct database_dyn *db, i
337 timeout value. Note that the new record has been
338 allocated on the stack and need not be freed. */
339 assert (h_addr_list_cnt == 1);
340 + dh->ttl = dataset->head.ttl;
341 dh->timeout = dataset->head.timeout;
344 @@ -433,6 +439,8 @@ cache_addhst (struct database_dyn *db, i
345 dbg_log (_("short write in %s: %s"), __FUNCTION__,
346 strerror_r (errno, buf, sizeof (buf)));
353 @@ -454,7 +462,7 @@ lookup (int type, void *key, struct host
359 addhstbyX (struct database_dyn *db, int fd, request_header *req,
360 void *key, uid_t uid, struct hashentry *he, struct datahead *dh)
362 @@ -520,11 +528,13 @@ addhstbyX (struct database_dyn *db, int
363 buffer = (char *) extend_alloca (buffer, buflen, 2 * buflen);
366 - cache_addhst (db, fd, req, key, hst, uid, he, dh,
367 - h_errno == TRY_AGAIN ? errval : 0, ttl);
368 + time_t timeout = cache_addhst (db, fd, req, key, hst, uid, he, dh,
369 + h_errno == TRY_AGAIN ? errval : 0, ttl);
378 @@ -536,7 +546,7 @@ addhstbyname (struct database_dyn *db, i
384 readdhstbyname (struct database_dyn *db, struct hashentry *he,
387 @@ -546,7 +556,7 @@ readdhstbyname (struct database_dyn *db,
391 - addhstbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
392 + return addhstbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
396 @@ -558,7 +568,7 @@ addhstbyaddr (struct database_dyn *db, i
402 readdhstbyaddr (struct database_dyn *db, struct hashentry *he,
405 @@ -568,7 +578,7 @@ readdhstbyaddr (struct database_dyn *db,
409 - addhstbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
410 + return addhstbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
414 @@ -580,7 +590,7 @@ addhstbynamev6 (struct database_dyn *db,
420 readdhstbynamev6 (struct database_dyn *db, struct hashentry *he,
423 @@ -590,7 +600,7 @@ readdhstbynamev6 (struct database_dyn *d
427 - addhstbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
428 + return addhstbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
432 @@ -602,7 +612,7 @@ addhstbyaddrv6 (struct database_dyn *db,
438 readdhstbyaddrv6 (struct database_dyn *db, struct hashentry *he,
441 @@ -612,5 +622,5 @@ readdhstbyaddrv6 (struct database_dyn *d
445 - addhstbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
446 + return addhstbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
448 Index: glibc-2.12-2-gc4ccff1/nscd/initgrcache.c
449 ===================================================================
450 --- glibc-2.12-2-gc4ccff1.orig/nscd/initgrcache.c
451 +++ glibc-2.12-2-gc4ccff1/nscd/initgrcache.c
452 @@ -52,7 +52,7 @@ static const initgr_response_header notf
453 #include "../grp/compat-initgroups.c"
458 addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
459 void *key, uid_t uid, struct hashentry *const he,
461 @@ -174,7 +174,9 @@ addinitgroupsX (struct database_dyn *db,
467 + timeout = MAX_TIMEOUT_VALUE;
470 /* Nothing found. Create a negative result record. */
471 @@ -188,6 +190,9 @@ addinitgroupsX (struct database_dyn *db,
472 if (reload_count != UINT_MAX && dh->nreloads == reload_count)
473 /* Do not reset the value if we never not reload the record. */
474 dh->nreloads = reload_count - 1;
476 + /* Reload with the same time-to-live value. */
477 + timeout = dh->timeout = time (NULL) + db->postimeout;
481 @@ -209,7 +214,7 @@ addinitgroupsX (struct database_dyn *db,
482 dataset->head.usable = true;
484 /* Compute the timeout time. */
485 - dataset->head.timeout = time (NULL) + db->negtimeout;
486 + timeout = dataset->head.timeout = time (NULL) + db->negtimeout;
488 /* This is the reply. */
489 memcpy (&dataset->resp, ¬found, total);
490 @@ -273,7 +278,7 @@ addinitgroupsX (struct database_dyn *db,
491 dataset->head.usable = true;
493 /* Compute the timeout time. */
494 - dataset->head.timeout = time (NULL) + db->postimeout;
495 + timeout = dataset->head.timeout = time (NULL) + db->postimeout;
497 dataset->resp.version = NSCD_VERSION;
498 dataset->resp.found = 1;
499 @@ -401,6 +406,8 @@ addinitgroupsX (struct database_dyn *db,
500 dbg_log (_("short write in %s: %s"), __FUNCTION__,
501 strerror_r (errno, buf, sizeof (buf)));
508 @@ -412,7 +419,7 @@ addinitgroups (struct database_dyn *db,
514 readdinitgroups (struct database_dyn *db, struct hashentry *he,
517 @@ -422,5 +429,5 @@ readdinitgroups (struct database_dyn *db
521 - addinitgroupsX (db, -1, &req, db->data + he->key, he->owner, he, dh);
522 + return addinitgroupsX (db, -1, &req, db->data + he->key, he->owner, he, dh);
524 Index: glibc-2.12-2-gc4ccff1/nscd/nscd-client.h
525 ===================================================================
526 --- glibc-2.12-2-gc4ccff1.orig/nscd/nscd-client.h
527 +++ glibc-2.12-2-gc4ccff1/nscd/nscd-client.h
528 @@ -179,6 +179,10 @@ typedef uint32_t ref_t;
529 /* Timestamp type. */
530 typedef uint64_t nscd_time_t;
532 +/* Maximum timestamp. */
533 +#define MAX_TIMEOUT_VALUE \
534 + (sizeof (time_t) == sizeof (long int) ? LONG_MAX : INT_MAX)
536 /* Alignment requirement of the beginning of the data region. */
539 @@ -192,7 +196,8 @@ struct datahead
540 uint8_t notfound; /* Nonzero if data has not been found. */
541 uint8_t nreloads; /* Reloads without use. */
542 uint8_t usable; /* False if the entry must be ignored. */
543 - uint64_t :40; /* Alignment. */
544 + uint8_t unused; /* Unused. */
545 + uint32_t ttl; /* TTL value used. */
547 /* We need to have the following element aligned for the response
548 header data types and their use in the 'struct dataset' types
549 Index: glibc-2.12-2-gc4ccff1/nscd/nscd.h
550 ===================================================================
551 --- glibc-2.12-2-gc4ccff1.orig/nscd/nscd.h
552 +++ glibc-2.12-2-gc4ccff1/nscd/nscd.h
553 @@ -217,20 +217,20 @@ extern void addpwbyname (struct database
554 void *key, uid_t uid);
555 extern void addpwbyuid (struct database_dyn *db, int fd, request_header *req,
556 void *key, uid_t uid);
557 -extern void readdpwbyname (struct database_dyn *db, struct hashentry *he,
558 - struct datahead *dh);
559 -extern void readdpwbyuid (struct database_dyn *db, struct hashentry *he,
560 - struct datahead *dh);
561 +extern time_t readdpwbyname (struct database_dyn *db, struct hashentry *he,
562 + struct datahead *dh);
563 +extern time_t readdpwbyuid (struct database_dyn *db, struct hashentry *he,
564 + struct datahead *dh);
567 extern void addgrbyname (struct database_dyn *db, int fd, request_header *req,
568 void *key, uid_t uid);
569 extern void addgrbygid (struct database_dyn *db, int fd, request_header *req,
570 void *key, uid_t uid);
571 -extern void readdgrbyname (struct database_dyn *db, struct hashentry *he,
572 - struct datahead *dh);
573 -extern void readdgrbygid (struct database_dyn *db, struct hashentry *he,
574 - struct datahead *dh);
575 +extern time_t readdgrbyname (struct database_dyn *db, struct hashentry *he,
576 + struct datahead *dh);
577 +extern time_t readdgrbygid (struct database_dyn *db, struct hashentry *he,
578 + struct datahead *dh);
581 extern void addhstbyname (struct database_dyn *db, int fd, request_header *req,
582 @@ -241,37 +241,37 @@ extern void addhstbynamev6 (struct datab
583 request_header *req, void *key, uid_t uid);
584 extern void addhstbyaddrv6 (struct database_dyn *db, int fd,
585 request_header *req, void *key, uid_t uid);
586 -extern void readdhstbyname (struct database_dyn *db, struct hashentry *he,
587 - struct datahead *dh);
588 -extern void readdhstbyaddr (struct database_dyn *db, struct hashentry *he,
589 - struct datahead *dh);
590 -extern void readdhstbynamev6 (struct database_dyn *db, struct hashentry *he,
591 +extern time_t readdhstbyname (struct database_dyn *db, struct hashentry *he,
592 struct datahead *dh);
593 -extern void readdhstbyaddrv6 (struct database_dyn *db, struct hashentry *he,
594 +extern time_t readdhstbyaddr (struct database_dyn *db, struct hashentry *he,
595 struct datahead *dh);
596 +extern time_t readdhstbynamev6 (struct database_dyn *db, struct hashentry *he,
597 + struct datahead *dh);
598 +extern time_t readdhstbyaddrv6 (struct database_dyn *db, struct hashentry *he,
599 + struct datahead *dh);
602 extern void addhstai (struct database_dyn *db, int fd, request_header *req,
603 void *key, uid_t uid);
604 -extern void readdhstai (struct database_dyn *db, struct hashentry *he,
605 - struct datahead *dh);
606 +extern time_t readdhstai (struct database_dyn *db, struct hashentry *he,
607 + struct datahead *dh);
611 extern void addinitgroups (struct database_dyn *db, int fd,
612 request_header *req, void *key, uid_t uid);
613 -extern void readdinitgroups (struct database_dyn *db, struct hashentry *he,
614 - struct datahead *dh);
615 +extern time_t readdinitgroups (struct database_dyn *db, struct hashentry *he,
616 + struct datahead *dh);
619 extern void addservbyname (struct database_dyn *db, int fd,
620 request_header *req, void *key, uid_t uid);
621 -extern void readdservbyname (struct database_dyn *db, struct hashentry *he,
622 - struct datahead *dh);
623 +extern time_t readdservbyname (struct database_dyn *db, struct hashentry *he,
624 + struct datahead *dh);
625 extern void addservbyport (struct database_dyn *db, int fd,
626 request_header *req, void *key, uid_t uid);
627 -extern void readdservbyport (struct database_dyn *db, struct hashentry *he,
628 - struct datahead *dh);
629 +extern time_t readdservbyport (struct database_dyn *db, struct hashentry *he,
630 + struct datahead *dh);
633 extern void *mempool_alloc (struct database_dyn *db, size_t len,
634 Index: glibc-2.12-2-gc4ccff1/nscd/pwdcache.c
635 ===================================================================
636 --- glibc-2.12-2-gc4ccff1.orig/nscd/pwdcache.c
637 +++ glibc-2.12-2-gc4ccff1/nscd/pwdcache.c
638 @@ -77,7 +77,7 @@ static const pw_response_header notfound
644 cache_addpw (struct database_dyn *db, int fd, request_header *req,
645 const void *key, struct passwd *pwd, uid_t owner,
646 struct hashentry *const he, struct datahead *dh, int errval)
647 @@ -97,6 +97,7 @@ cache_addpw (struct database_dyn *db, in
649 assert (offsetof (struct dataset, resp) == offsetof (struct datahead, data));
651 + time_t timeout = MAX_TIMEOUT_VALUE;
654 if (he != NULL && errval == EAGAIN)
655 @@ -108,6 +109,9 @@ cache_addpw (struct database_dyn *db, in
656 /* Do not reset the value if we never not reload the record. */
657 dh->nreloads = reload_count - 1;
659 + /* Reload with the same time-to-live value. */
660 + timeout = dh->timeout = t + db->postimeout;
665 @@ -132,7 +136,7 @@ cache_addpw (struct database_dyn *db, in
666 dataset->head.usable = true;
668 /* Compute the timeout time. */
669 - dataset->head.timeout = t + db->negtimeout;
670 + timeout = dataset->head.timeout = t + db->negtimeout;
672 /* This is the reply. */
673 memcpy (&dataset->resp, ¬found, total);
674 @@ -212,7 +216,7 @@ cache_addpw (struct database_dyn *db, in
675 dataset->head.usable = true;
677 /* Compute the timeout time. */
678 - dataset->head.timeout = t + db->postimeout;
679 + timeout = dataset->head.timeout = t + db->postimeout;
681 dataset->resp.version = NSCD_VERSION;
682 dataset->resp.found = 1;
683 @@ -293,8 +297,8 @@ cache_addpw (struct database_dyn *db, in
684 assert ((char *) dataset - (char *) db->head
686 <= (sizeof (struct database_pers_head)
687 - + db->head->module * sizeof (ref_t)
688 - + db->head->data_size));
689 + + db->head->module * sizeof (ref_t)
690 + + db->head->data_size));
691 written = sendfileall (fd, db->wr_fd,
692 (char *) &dataset->resp
693 - (char *) db->head, dataset->head.recsize );
694 @@ -374,6 +378,8 @@ cache_addpw (struct database_dyn *db, in
695 dbg_log (_("short write in %s: %s"), __FUNCTION__,
696 strerror_r (errno, buf, sizeof (buf)));
703 @@ -395,7 +401,7 @@ lookup (int type, union keytype key, str
709 addpwbyX (struct database_dyn *db, int fd, request_header *req,
710 union keytype key, const char *keystr, uid_t c_uid,
711 struct hashentry *he, struct datahead *dh)
712 @@ -452,10 +458,13 @@ addpwbyX (struct database_dyn *db, int f
715 /* Add the entry to the cache. */
716 - cache_addpw (db, fd, req, keystr, pwd, c_uid, he, dh, errval);
717 + time_t timeout = cache_addpw (db, fd, req, keystr, pwd, c_uid, he, dh,
727 @@ -469,7 +478,7 @@ addpwbyname (struct database_dyn *db, in
733 readdpwbyname (struct database_dyn *db, struct hashentry *he,
736 @@ -480,7 +489,7 @@ readdpwbyname (struct database_dyn *db,
738 union keytype u = { .v = db->data + he->key };
740 - addpwbyX (db, -1, &req, u, db->data + he->key, he->owner, he, dh);
741 + return addpwbyX (db, -1, &req, u, db->data + he->key, he->owner, he, dh);
745 @@ -506,7 +515,7 @@ addpwbyuid (struct database_dyn *db, int
751 readdpwbyuid (struct database_dyn *db, struct hashentry *he,
754 @@ -523,5 +532,5 @@ readdpwbyuid (struct database_dyn *db, s
756 union keytype u = { .u = uid };
758 - addpwbyX (db, -1, &req, u, db->data + he->key, he->owner, he, dh);
759 + return addpwbyX (db, -1, &req, u, db->data + he->key, he->owner, he, dh);
761 Index: glibc-2.12-2-gc4ccff1/nscd/servicescache.c
762 ===================================================================
763 --- glibc-2.12-2-gc4ccff1.orig/nscd/servicescache.c
764 +++ glibc-2.12-2-gc4ccff1/nscd/servicescache.c
765 @@ -61,7 +61,7 @@ static const serv_response_header notfou
771 cache_addserv (struct database_dyn *db, int fd, request_header *req,
772 const void *key, struct servent *serv, uid_t owner,
773 struct hashentry *const he, struct datahead *dh, int errval)
774 @@ -81,6 +81,7 @@ cache_addserv (struct database_dyn *db,
776 assert (offsetof (struct dataset, resp) == offsetof (struct datahead, data));
778 + time_t timeout = MAX_TIMEOUT_VALUE;
781 if (he != NULL && errval == EAGAIN)
782 @@ -92,6 +93,9 @@ cache_addserv (struct database_dyn *db,
783 /* Do not reset the value if we never not reload the record. */
784 dh->nreloads = reload_count - 1;
786 + /* Reload with the same time-to-live value. */
787 + timeout = dh->timeout = t + db->postimeout;
792 @@ -115,7 +119,7 @@ cache_addserv (struct database_dyn *db,
793 dataset->head.usable = true;
795 /* Compute the timeout time. */
796 - dataset->head.timeout = t + db->negtimeout;
797 + timeout = dataset->head.timeout = t + db->negtimeout;
799 /* This is the reply. */
800 memcpy (&dataset->resp, ¬found, total);
801 @@ -203,7 +207,7 @@ cache_addserv (struct database_dyn *db,
802 dataset->head.usable = true;
804 /* Compute the timeout time. */
805 - dataset->head.timeout = t + db->postimeout;
806 + timeout = dataset->head.timeout = t + db->postimeout;
808 dataset->resp.version = NSCD_VERSION;
809 dataset->resp.found = 1;
810 @@ -328,6 +332,8 @@ cache_addserv (struct database_dyn *db,
811 dbg_log (_("short write in %s: %s"), __FUNCTION__,
812 strerror_r (errno, buf, sizeof (buf)));
819 @@ -354,7 +360,7 @@ lookup (int type, char *key, struct serv
825 addservbyX (struct database_dyn *db, int fd, request_header *req,
826 char *key, uid_t uid, struct hashentry *he, struct datahead *dh)
828 @@ -409,10 +415,12 @@ addservbyX (struct database_dyn *db, int
829 buffer = (char *) extend_alloca (buffer, buflen, 2 * buflen);
832 - cache_addserv (db, fd, req, key, serv, uid, he, dh, errval);
833 + time_t timeout = cache_addserv (db, fd, req, key, serv, uid, he, dh, errval);
842 @@ -424,7 +432,7 @@ addservbyname (struct database_dyn *db,
848 readdservbyname (struct database_dyn *db, struct hashentry *he,
851 @@ -434,7 +442,7 @@ readdservbyname (struct database_dyn *db
855 - addservbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
856 + return addservbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
860 @@ -446,7 +454,7 @@ addservbyport (struct database_dyn *db,
866 readdservbyport (struct database_dyn *db, struct hashentry *he,
869 @@ -456,5 +464,5 @@ readdservbyport (struct database_dyn *db
873 - addservbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
874 + return addservbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);