summaryrefslogtreecommitdiff
path: root/nscd/initgrcache.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-02-05 20:07:27 -0500
committerUlrich Drepper <drepper@gmail.com>2011-02-05 20:07:27 -0500
commita4c7ea7bb8eed9a53c4c50a3b9b9ab324beb1419 (patch)
tree564c0b74f4820c2c77376901c480e33544046b62 /nscd/initgrcache.c
parenta0bf67cca2b7de3a745ab5cf0f9d6e74078d57af (diff)
Schedule nscd cache pruning more accurately fromr re-added values.
Diffstat (limited to 'nscd/initgrcache.c')
-rw-r--r--nscd/initgrcache.c19
1 files changed, 13 insertions, 6 deletions
diff --git a/nscd/initgrcache.c b/nscd/initgrcache.c
index 8195b6609e..8cb6cf197a 100644
--- a/nscd/initgrcache.c
+++ b/nscd/initgrcache.c
@@ -1,5 +1,5 @@
/* Cache handling for host lookup.
- Copyright (C) 2004, 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005, 2006, 2008, 2009, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
@@ -52,7 +52,7 @@ static const initgr_response_header notfound =
#include "../grp/compat-initgroups.c"
-static void
+static time_t
addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
void *key, uid_t uid, struct hashentry *const he,
struct datahead *dh)
@@ -174,7 +174,9 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
ssize_t total;
ssize_t written;
+ time_t timeout;
out:
+ timeout = MAX_TIMEOUT_VALUE;
if (!any_success)
{
/* Nothing found. Create a negative result record. */
@@ -188,6 +190,9 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
if (reload_count != UINT_MAX && dh->nreloads == reload_count)
/* Do not reset the value if we never not reload the record. */
dh->nreloads = reload_count - 1;
+
+ /* Reload with the same time-to-live value. */
+ timeout = dh->timeout = time (NULL) + db->postimeout;
}
else
{
@@ -209,7 +214,7 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
dataset->head.usable = true;
/* Compute the timeout time. */
- dataset->head.timeout = time (NULL) + db->negtimeout;
+ timeout = dataset->head.timeout = time (NULL) + db->negtimeout;
/* This is the reply. */
memcpy (&dataset->resp, &notfound, total);
@@ -273,7 +278,7 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
dataset->head.usable = true;
/* Compute the timeout time. */
- dataset->head.timeout = time (NULL) + db->postimeout;
+ timeout = dataset->head.timeout = time (NULL) + db->postimeout;
dataset->resp.version = NSCD_VERSION;
dataset->resp.found = 1;
@@ -401,6 +406,8 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
dbg_log (_("short write in %s: %s"), __FUNCTION__,
strerror_r (errno, buf, sizeof (buf)));
}
+
+ return timeout;
}
@@ -412,7 +419,7 @@ addinitgroups (struct database_dyn *db, int fd, request_header *req, void *key,
}
-void
+time_t
readdinitgroups (struct database_dyn *db, struct hashentry *he,
struct datahead *dh)
{
@@ -422,5 +429,5 @@ readdinitgroups (struct database_dyn *db, struct hashentry *he,
.key_len = he->len
};
- addinitgroupsX (db, -1, &req, db->data + he->key, he->owner, he, dh);
+ return addinitgroupsX (db, -1, &req, db->data + he->key, he->owner, he, dh);
}