[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[commits] r12767 - in /fsf/trunk/libc: ./ nscd/
- To: commits@xxxxxxxxxx
- Subject: [commits] r12767 - in /fsf/trunk/libc: ./ nscd/
- From: eglibc@xxxxxxxxxx
- Date: Sun, 06 Feb 2011 08:02:57 -0000
Author: eglibc
Date: Sun Feb 6 00:02:55 2011
New Revision: 12767
Log:
Import glibc-mainline for 2011-02-06
Modified:
fsf/trunk/libc/ChangeLog
fsf/trunk/libc/nscd/aicache.c
fsf/trunk/libc/nscd/cache.c
fsf/trunk/libc/nscd/connections.c
fsf/trunk/libc/nscd/grpcache.c
fsf/trunk/libc/nscd/hstcache.c
fsf/trunk/libc/nscd/initgrcache.c
fsf/trunk/libc/nscd/nscd-client.h
fsf/trunk/libc/nscd/nscd.h
fsf/trunk/libc/nscd/pwdcache.c
fsf/trunk/libc/nscd/servicescache.c
Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Sun Feb 6 00:02:55 2011
@@ -1,3 +1,34 @@
+2011-02-05 Ulrich Drepper <drepper@xxxxxxxxx>
+
+ * nscd/nscd-client.h: Define MAX_TIMEOUT_VALUE.
+ (struct datahead): Reuse 32 bits of the alignment for a TTL field.
+ * nscd/aicache.c (addhstaiX): Return timeout of added value.
+ (readdhstai): Return value of addhstaiX call.
+ * nscd/grpcache.c (cache_addgr): Return timeout of added value.
+ (addgrbyX): Return value returned by cache_addgr.
+ (readdgrbyname): Return value returned by addgrbyX.
+ (readdgrbygid): Likewise.
+ * nscd/pwdcache.c (cache_addpw): Return timeout of added value.
+ (addpwbyX): Return value returned by cache_addpw.
+ (readdpwbyname): Return value returned by addhstbyX.
+ (readdpwbyuid): Likewise.
+ * nscd/servicescache.c (cache_addserv): Return timeout of added value.
+ (addservbyX): Return value returned by cache_addserv.
+ (readdservbyname): Return value returned by addservbyX:
+ (readdservbyport): Likewise.
+ * nscd/hstcache.c (cache_addhst): Return timeout of added value.
+ (addhstbyX): Return value returned by cache_addhst.
+ (readdhstbyname): Return value returned by addhstbyX.
+ (readdhstbyaddr): Likewise.
+ (readdhstbynamev6): Likewise.
+ (readdhstbyaddrv6): Likewise.
+ * nscd/initgrcache.c (addinitgroupsX): Return timeout of added value.
+ (readdinitgroups): Return value returned by addinitgroupsX.
+ * nscd/cache.c (readdfcts): Change return value of functions to time_t.
+ (prune_cache): Keep track of timeout value of re-added entries.
+ * nscd/connections.c (nscd_run_prune): Use MAX_TIMEOUT_VALUE.
+ * nscd/nscd.h: Adjust prototypes of readd* functions.
+
2011-02-04 Roland McGrath <roland@xxxxxxxxxx>
* nis/nis_server.c (nis_servstate): Use the right name for 0.
Modified: fsf/trunk/libc/nscd/aicache.c
==============================================================================
--- fsf/trunk/libc/nscd/aicache.c (original)
+++ fsf/trunk/libc/nscd/aicache.c Sun Feb 6 00:02:55 2011
@@ -1,5 +1,5 @@
/* Cache handling for host lookup.
- Copyright (C) 2004-2008, 2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 2004-2008, 2009, 2010, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 2004.
@@ -58,7 +58,7 @@
};
-static void
+static time_t
addhstaiX (struct database_dyn *db, int fd, request_header *req,
void *key, uid_t uid, struct hashentry *const he,
struct datahead *dh)
@@ -119,6 +119,7 @@
ssize_t total = 0;
char *key_copy = NULL;
bool alloca_used = false;
+ time_t timeout = MAX_TIMEOUT_VALUE;
while (!no_more)
{
@@ -388,8 +389,8 @@
dataset->head.usable = true;
/* Compute the timeout time. */
- dataset->head.timeout = time (NULL) + (ttl == INT32_MAX
- ? db->postimeout : ttl);
+ dataset->head.ttl = ttl == INT32_MAX ? db->postimeout : ttl;
+ timeout = dataset->head.timeout = time (NULL) + dataset->head.ttl;
dataset->resp.version = NSCD_VERSION;
dataset->resp.found = 1;
@@ -421,6 +422,7 @@
timeout value. Note that the new record has been
allocated on the stack and need not be freed. */
dh->timeout = dataset->head.timeout;
+ dh->ttl = dataset->head.ttl;
++dh->nreloads;
}
else
@@ -496,6 +498,9 @@
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) + dh->ttl;
}
else
{
@@ -517,7 +522,8 @@
dataset->head.usable = true;
/* Compute the timeout time. */
- dataset->head.timeout = time (NULL) + db->negtimeout;
+ timeout = dataset->head.timeout = time (NULL) + db->negtimeout;
+ dataset->head.ttl = db->negtimeout;
/* This is the reply. */
memcpy (&dataset->resp, ¬found, total);
@@ -551,6 +557,8 @@
if (dh != NULL)
dh->usable = false;
}
+
+ return timeout;
}
@@ -562,7 +570,7 @@
}
-void
+time_t
readdhstai (struct database_dyn *db, struct hashentry *he, struct datahead *dh)
{
request_header req =
@@ -571,5 +579,5 @@
.key_len = he->len
};
- addhstaiX (db, -1, &req, db->data + he->key, he->owner, he, dh);
+ return addhstaiX (db, -1, &req, db->data + he->key, he->owner, he, dh);
}
Modified: fsf/trunk/libc/nscd/cache.c
==============================================================================
--- fsf/trunk/libc/nscd/cache.c (original)
+++ fsf/trunk/libc/nscd/cache.c Sun Feb 6 00:02:55 2011
@@ -1,4 +1,4 @@
-/* Copyright (c) 1998, 1999, 2003-2008, 2009 Free Software Foundation, Inc.
+/* Copyright (c) 1998, 1999, 2003-2009, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 1998.
@@ -45,9 +45,9 @@
unsigned int reload_count = DEFAULT_RELOAD_LIMIT;
-static void (*const readdfcts[LASTREQ]) (struct database_dyn *,
- struct hashentry *,
- struct datahead *) =
+static time_t (*const readdfcts[LASTREQ]) (struct database_dyn *,
+ struct hashentry *,
+ struct datahead *) =
{
[GETPWBYNAME] = readdpwbyname,
[GETPWBYUID] = readdpwbyuid,
@@ -272,7 +272,7 @@
{
char buf[128];
/* We cannot stat() the file, disable file checking if the
- file does not exist. */
+ file does not exist. */
dbg_log (_("cannot stat() file `%s': %s"),
table->filename, strerror_r (errno, buf, sizeof (buf)));
if (errno == ENOENT)
@@ -389,7 +389,8 @@
assert (runp->type < LASTREQ
&& readdfcts[runp->type] != NULL);
- readdfcts[runp->type] (table, runp, dh);
+ time_t timeout = readdfcts[runp->type] (table, runp, dh);
+ next_timeout = MIN (next_timeout, timeout);
/* If the entry has been replaced, we might need
cleanup. */
Modified: fsf/trunk/libc/nscd/connections.c
==============================================================================
--- fsf/trunk/libc/nscd/connections.c (original)
+++ fsf/trunk/libc/nscd/connections.c Sun Feb 6 00:02:55 2011
@@ -1,5 +1,5 @@
/* Inner loops of cache daemon.
- Copyright (C) 1998-2007, 2008, 2009 Free Software Foundation, Inc.
+ Copyright (C) 1998-2007, 2008, 2009, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 1998.
@@ -1533,10 +1533,7 @@
pruning we want to know about it. Therefore set the
timeout to the maximum. It will be descreased when adding
new entries to the cache, if necessary. */
- if (sizeof (time_t) == sizeof (long int))
- dbs[my_number].wakeup_time = LONG_MAX;
- else
- dbs[my_number].wakeup_time = INT_MAX;
+ dbs[my_number].wakeup_time = MAX_TIMEOUT_VALUE;
/* Unconditionally reset the flag. */
time_t prune_now = dbs[my_number].clear_cache ? LONG_MAX : now;
Modified: fsf/trunk/libc/nscd/grpcache.c
==============================================================================
--- fsf/trunk/libc/nscd/grpcache.c (original)
+++ fsf/trunk/libc/nscd/grpcache.c Sun Feb 6 00:02:55 2011
@@ -1,5 +1,5 @@
/* Cache handling for group lookup.
- Copyright (C) 1998-2008, 2009 Free Software Foundation, Inc.
+ Copyright (C) 1998-2008, 2009, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 1998.
@@ -71,7 +71,7 @@
};
-static void
+static time_t
cache_addgr (struct database_dyn *db, int fd, request_header *req,
const void *key, struct group *grp, uid_t owner,
struct hashentry *const he, struct datahead *dh, int errval)
@@ -91,6 +91,7 @@
assert (offsetof (struct dataset, resp) == offsetof (struct datahead, data));
+ time_t timeout = MAX_TIMEOUT_VALUE;
if (grp == NULL)
{
if (he != NULL && errval == EAGAIN)
@@ -102,6 +103,9 @@
/* 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 = t + db->postimeout;
+
written = total = 0;
}
else
@@ -125,7 +129,7 @@
dataset->head.usable = true;
/* Compute the timeout time. */
- dataset->head.timeout = t + db->negtimeout;
+ timeout = dataset->head.timeout = t + db->negtimeout;
/* This is the reply. */
memcpy (&dataset->resp, ¬found, total);
@@ -217,7 +221,7 @@
dataset->head.usable = true;
/* Compute the timeout time. */
- dataset->head.timeout = t + db->postimeout;
+ timeout = dataset->head.timeout = t + db->postimeout;
dataset->resp.version = NSCD_VERSION;
dataset->resp.found = 1;
@@ -379,6 +383,8 @@
dbg_log (_("short write in %s: %s"), __FUNCTION__,
strerror_r (errno, buf, sizeof (buf)));
}
+
+ return timeout;
}
@@ -400,7 +406,7 @@
}
-static void
+static time_t
addgrbyX (struct database_dyn *db, int fd, request_header *req,
union keytype key, const char *keystr, uid_t uid,
struct hashentry *he, struct datahead *dh)
@@ -456,10 +462,12 @@
buffer = (char *) extend_alloca (buffer, buflen, 2 * buflen);
}
- cache_addgr (db, fd, req, keystr, grp, uid, he, dh, errval);
+ time_t timeout = cache_addgr (db, fd, req, keystr, grp, uid, he, dh, errval);
if (use_malloc)
free (buffer);
+
+ return timeout;
}
@@ -473,7 +481,7 @@
}
-void
+time_t
readdgrbyname (struct database_dyn *db, struct hashentry *he,
struct datahead *dh)
{
@@ -484,7 +492,7 @@
};
union keytype u = { .v = db->data + he->key };
- addgrbyX (db, -1, &req, u, db->data + he->key, he->owner, he, dh);
+ return addgrbyX (db, -1, &req, u, db->data + he->key, he->owner, he, dh);
}
@@ -498,7 +506,7 @@
if (*(char *) key == '\0' || *ep != '\0') /* invalid numeric uid */
{
if (debug_level > 0)
- dbg_log (_("Invalid numeric gid \"%s\"!"), (char *) key);
+ dbg_log (_("Invalid numeric gid \"%s\"!"), (char *) key);
errno = EINVAL;
return;
@@ -510,7 +518,7 @@
}
-void
+time_t
readdgrbygid (struct database_dyn *db, struct hashentry *he,
struct datahead *dh)
{
@@ -527,5 +535,5 @@
};
union keytype u = { .g = gid };
- addgrbyX (db, -1, &req, u, db->data + he->key, he->owner, he, dh);
-}
+ return addgrbyX (db, -1, &req, u, db->data + he->key, he->owner, he, dh);
+}
Modified: fsf/trunk/libc/nscd/hstcache.c
==============================================================================
--- fsf/trunk/libc/nscd/hstcache.c (original)
+++ fsf/trunk/libc/nscd/hstcache.c Sun Feb 6 00:02:55 2011
@@ -91,7 +91,7 @@
};
-static void
+static time_t
cache_addhst (struct database_dyn *db, int fd, request_header *req,
const void *key, struct hostent *hst, uid_t owner,
struct hashentry *const he, struct datahead *dh, int errval,
@@ -111,6 +111,7 @@
assert (offsetof (struct dataset, resp) == offsetof (struct datahead, data));
+ time_t timeout = MAX_TIMEOUT_VALUE;
if (hst == NULL)
{
if (he != NULL && errval == EAGAIN)
@@ -121,6 +122,9 @@
if (reload_count != UINT_MAX)
/* 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 = t + dh->ttl;
}
else
{
@@ -149,8 +153,8 @@
dataset->head.usable = true;
/* Compute the timeout time. */
- dataset->head.timeout = t + (ttl == INT32_MAX
- ? db->negtimeout : ttl);
+ dataset->head.ttl = ttl == INT32_MAX ? db->negtimeout : ttl;
+ timeout = dataset->head.timeout = t + dataset->head.ttl;
/* This is the reply. */
memcpy (&dataset->resp, resp, total);
@@ -214,7 +218,7 @@
if (h_addr_list_cnt == 0)
/* Invalid entry. */
- return;
+ return MAX_TIMEOUT_VALUE;
total += (sizeof (struct dataset)
+ h_name_len
@@ -255,7 +259,8 @@
dataset->head.usable = true;
/* Compute the timeout time. */
- dataset->head.timeout = t + (ttl == INT32_MAX ? db->postimeout : ttl);
+ dataset->head.ttl = ttl == INT32_MAX ? db->postimeout : ttl;
+ timeout = dataset->head.timeout = t + dataset->head.ttl;
dataset->resp.version = NSCD_VERSION;
dataset->resp.found = 1;
@@ -312,6 +317,7 @@
timeout value. Note that the new record has been
allocated on the stack and need not be freed. */
assert (h_addr_list_cnt == 1);
+ dh->ttl = dataset->head.ttl;
dh->timeout = dataset->head.timeout;
++dh->nreloads;
}
@@ -433,6 +439,8 @@
dbg_log (_("short write in %s: %s"), __FUNCTION__,
strerror_r (errno, buf, sizeof (buf)));
}
+
+ return timeout;
}
@@ -454,7 +462,7 @@
}
-static void
+static time_t
addhstbyX (struct database_dyn *db, int fd, request_header *req,
void *key, uid_t uid, struct hashentry *he, struct datahead *dh)
{
@@ -520,11 +528,13 @@
buffer = (char *) extend_alloca (buffer, buflen, 2 * buflen);
}
- cache_addhst (db, fd, req, key, hst, uid, he, dh,
- h_errno == TRY_AGAIN ? errval : 0, ttl);
+ time_t timeout = cache_addhst (db, fd, req, key, hst, uid, he, dh,
+ h_errno == TRY_AGAIN ? errval : 0, ttl);
if (use_malloc)
free (buffer);
+
+ return timeout;
}
@@ -536,7 +546,7 @@
}
-void
+time_t
readdhstbyname (struct database_dyn *db, struct hashentry *he,
struct datahead *dh)
{
@@ -546,7 +556,7 @@
.key_len = he->len
};
- addhstbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
+ return addhstbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
}
@@ -558,7 +568,7 @@
}
-void
+time_t
readdhstbyaddr (struct database_dyn *db, struct hashentry *he,
struct datahead *dh)
{
@@ -568,7 +578,7 @@
.key_len = he->len
};
- addhstbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
+ return addhstbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
}
@@ -580,7 +590,7 @@
}
-void
+time_t
readdhstbynamev6 (struct database_dyn *db, struct hashentry *he,
struct datahead *dh)
{
@@ -590,7 +600,7 @@
.key_len = he->len
};
- addhstbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
+ return addhstbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
}
@@ -602,7 +612,7 @@
}
-void
+time_t
readdhstbyaddrv6 (struct database_dyn *db, struct hashentry *he,
struct datahead *dh)
{
@@ -612,5 +622,5 @@
.key_len = he->len
};
- addhstbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
-}
+ return addhstbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
+}
Modified: fsf/trunk/libc/nscd/initgrcache.c
==============================================================================
--- fsf/trunk/libc/nscd/initgrcache.c (original)
+++ fsf/trunk/libc/nscd/initgrcache.c Sun Feb 6 00:02:55 2011
@@ -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@xxxxxxxxxx>, 2004.
@@ -52,7 +52,7 @@
#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 @@
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 @@
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 @@
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, ¬found, total);
@@ -273,7 +278,7 @@
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 @@
dbg_log (_("short write in %s: %s"), __FUNCTION__,
strerror_r (errno, buf, sizeof (buf)));
}
+
+ return timeout;
}
@@ -412,7 +419,7 @@
}
-void
+time_t
readdinitgroups (struct database_dyn *db, struct hashentry *he,
struct datahead *dh)
{
@@ -422,5 +429,5 @@
.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);
}
Modified: fsf/trunk/libc/nscd/nscd-client.h
==============================================================================
--- fsf/trunk/libc/nscd/nscd-client.h (original)
+++ fsf/trunk/libc/nscd/nscd-client.h Sun Feb 6 00:02:55 2011
@@ -1,4 +1,4 @@
-/* Copyright (c) 1998, 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009
+/* Copyright (c) 1998, 1999, 2000, 2003, 2004, 2005, 2006, 2007, 2009, 2011
Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@xxxxxxx>, 1998.
@@ -179,6 +179,10 @@
/* Timestamp type. */
typedef uint64_t nscd_time_t;
+/* Maximum timestamp. */
+#define MAX_TIMEOUT_VALUE \
+ (sizeof (time_t) == sizeof (long int) ? LONG_MAX : INT_MAX)
+
/* Alignment requirement of the beginning of the data region. */
#define ALIGN 16
@@ -192,7 +196,8 @@
uint8_t notfound; /* Nonzero if data has not been found. */
uint8_t nreloads; /* Reloads without use. */
uint8_t usable; /* False if the entry must be ignored. */
- uint64_t :40; /* Alignment. */
+ uint8_t unused; /* Unused. */
+ uint32_t ttl; /* TTL value used. */
/* We need to have the following element aligned for the response
header data types and their use in the 'struct dataset' types
Modified: fsf/trunk/libc/nscd/nscd.h
==============================================================================
--- fsf/trunk/libc/nscd/nscd.h (original)
+++ fsf/trunk/libc/nscd/nscd.h Sun Feb 6 00:02:55 2011
@@ -1,4 +1,4 @@
-/* Copyright (c) 1998-2001, 2003-2008, 2009 Free Software Foundation, Inc.
+/* Copyright (c) 1998-2001, 2003-2009, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@xxxxxxx>, 1998.
@@ -217,20 +217,20 @@
void *key, uid_t uid);
extern void addpwbyuid (struct database_dyn *db, int fd, request_header *req,
void *key, uid_t uid);
-extern void readdpwbyname (struct database_dyn *db, struct hashentry *he,
- struct datahead *dh);
-extern void readdpwbyuid (struct database_dyn *db, struct hashentry *he,
- struct datahead *dh);
+extern time_t readdpwbyname (struct database_dyn *db, struct hashentry *he,
+ struct datahead *dh);
+extern time_t readdpwbyuid (struct database_dyn *db, struct hashentry *he,
+ struct datahead *dh);
/* grpcache.c */
extern void addgrbyname (struct database_dyn *db, int fd, request_header *req,
void *key, uid_t uid);
extern void addgrbygid (struct database_dyn *db, int fd, request_header *req,
void *key, uid_t uid);
-extern void readdgrbyname (struct database_dyn *db, struct hashentry *he,
- struct datahead *dh);
-extern void readdgrbygid (struct database_dyn *db, struct hashentry *he,
- struct datahead *dh);
+extern time_t readdgrbyname (struct database_dyn *db, struct hashentry *he,
+ struct datahead *dh);
+extern time_t readdgrbygid (struct database_dyn *db, struct hashentry *he,
+ struct datahead *dh);
/* hstcache.c */
extern void addhstbyname (struct database_dyn *db, int fd, request_header *req,
@@ -241,37 +241,37 @@
request_header *req, void *key, uid_t uid);
extern void addhstbyaddrv6 (struct database_dyn *db, int fd,
request_header *req, void *key, uid_t uid);
-extern void readdhstbyname (struct database_dyn *db, struct hashentry *he,
- struct datahead *dh);
-extern void readdhstbyaddr (struct database_dyn *db, struct hashentry *he,
- struct datahead *dh);
-extern void readdhstbynamev6 (struct database_dyn *db, struct hashentry *he,
+extern time_t readdhstbyname (struct database_dyn *db, struct hashentry *he,
struct datahead *dh);
-extern void readdhstbyaddrv6 (struct database_dyn *db, struct hashentry *he,
+extern time_t readdhstbyaddr (struct database_dyn *db, struct hashentry *he,
struct datahead *dh);
+extern time_t readdhstbynamev6 (struct database_dyn *db, struct hashentry *he,
+ struct datahead *dh);
+extern time_t readdhstbyaddrv6 (struct database_dyn *db, struct hashentry *he,
+ struct datahead *dh);
/* aicache.c */
extern void addhstai (struct database_dyn *db, int fd, request_header *req,
void *key, uid_t uid);
-extern void readdhstai (struct database_dyn *db, struct hashentry *he,
- struct datahead *dh);
+extern time_t readdhstai (struct database_dyn *db, struct hashentry *he,
+ struct datahead *dh);
/* initgrcache.c */
extern void addinitgroups (struct database_dyn *db, int fd,
request_header *req, void *key, uid_t uid);
-extern void readdinitgroups (struct database_dyn *db, struct hashentry *he,
- struct datahead *dh);
+extern time_t readdinitgroups (struct database_dyn *db, struct hashentry *he,
+ struct datahead *dh);
/* servicecache.c */
extern void addservbyname (struct database_dyn *db, int fd,
request_header *req, void *key, uid_t uid);
-extern void readdservbyname (struct database_dyn *db, struct hashentry *he,
- struct datahead *dh);
+extern time_t readdservbyname (struct database_dyn *db, struct hashentry *he,
+ struct datahead *dh);
extern void addservbyport (struct database_dyn *db, int fd,
request_header *req, void *key, uid_t uid);
-extern void readdservbyport (struct database_dyn *db, struct hashentry *he,
- struct datahead *dh);
+extern time_t readdservbyport (struct database_dyn *db, struct hashentry *he,
+ struct datahead *dh);
/* mem.c */
extern void *mempool_alloc (struct database_dyn *db, size_t len,
Modified: fsf/trunk/libc/nscd/pwdcache.c
==============================================================================
--- fsf/trunk/libc/nscd/pwdcache.c (original)
+++ fsf/trunk/libc/nscd/pwdcache.c Sun Feb 6 00:02:55 2011
@@ -1,5 +1,5 @@
/* Cache handling for passwd lookup.
- Copyright (C) 1998-2008, 2009 Free Software Foundation, Inc.
+ Copyright (C) 1998-2008, 2009, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@xxxxxxxxxx>, 1998.
@@ -77,7 +77,7 @@
};
-static void
+static time_t
cache_addpw (struct database_dyn *db, int fd, request_header *req,
const void *key, struct passwd *pwd, uid_t owner,
struct hashentry *const he, struct datahead *dh, int errval)
@@ -97,6 +97,7 @@
assert (offsetof (struct dataset, resp) == offsetof (struct datahead, data));
+ time_t timeout = MAX_TIMEOUT_VALUE;
if (pwd == NULL)
{
if (he != NULL && errval == EAGAIN)
@@ -108,6 +109,9 @@
/* 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 = t + db->postimeout;
+
written = total = 0;
}
else
@@ -132,7 +136,7 @@
dataset->head.usable = true;
/* Compute the timeout time. */
- dataset->head.timeout = t + db->negtimeout;
+ timeout = dataset->head.timeout = t + db->negtimeout;
/* This is the reply. */
memcpy (&dataset->resp, ¬found, total);
@@ -212,7 +216,7 @@
dataset->head.usable = true;
/* Compute the timeout time. */
- dataset->head.timeout = t + db->postimeout;
+ timeout = dataset->head.timeout = t + db->postimeout;
dataset->resp.version = NSCD_VERSION;
dataset->resp.found = 1;
@@ -293,8 +297,8 @@
assert ((char *) dataset - (char *) db->head
+ total
<= (sizeof (struct database_pers_head)
- + db->head->module * sizeof (ref_t)
- + db->head->data_size));
+ + db->head->module * sizeof (ref_t)
+ + db->head->data_size));
written = sendfileall (fd, db->wr_fd,
(char *) &dataset->resp
- (char *) db->head, dataset->head.recsize );
@@ -374,6 +378,8 @@
dbg_log (_("short write in %s: %s"), __FUNCTION__,
strerror_r (errno, buf, sizeof (buf)));
}
+
+ return timeout;
}
@@ -395,7 +401,7 @@
}
-static void
+static time_t
addpwbyX (struct database_dyn *db, int fd, request_header *req,
union keytype key, const char *keystr, uid_t c_uid,
struct hashentry *he, struct datahead *dh)
@@ -452,10 +458,13 @@
}
/* Add the entry to the cache. */
- cache_addpw (db, fd, req, keystr, pwd, c_uid, he, dh, errval);
+ time_t timeout = cache_addpw (db, fd, req, keystr, pwd, c_uid, he, dh,
+ errval);
if (use_malloc)
free (buffer);
+
+ return timeout;
}
@@ -469,7 +478,7 @@
}
-void
+time_t
readdpwbyname (struct database_dyn *db, struct hashentry *he,
struct datahead *dh)
{
@@ -480,7 +489,7 @@
};
union keytype u = { .v = db->data + he->key };
- addpwbyX (db, -1, &req, u, db->data + he->key, he->owner, he, dh);
+ return addpwbyX (db, -1, &req, u, db->data + he->key, he->owner, he, dh);
}
@@ -494,7 +503,7 @@
if (*(char *) key == '\0' || *ep != '\0') /* invalid numeric uid */
{
if (debug_level > 0)
- dbg_log (_("Invalid numeric uid \"%s\"!"), (char *) key);
+ dbg_log (_("Invalid numeric uid \"%s\"!"), (char *) key);
errno = EINVAL;
return;
@@ -506,7 +515,7 @@
}
-void
+time_t
readdpwbyuid (struct database_dyn *db, struct hashentry *he,
struct datahead *dh)
{
@@ -523,5 +532,5 @@
};
union keytype u = { .u = uid };
- addpwbyX (db, -1, &req, u, db->data + he->key, he->owner, he, dh);
-}
+ return addpwbyX (db, -1, &req, u, db->data + he->key, he->owner, he, dh);
+}
Modified: fsf/trunk/libc/nscd/servicescache.c
==============================================================================
--- fsf/trunk/libc/nscd/servicescache.c (original)
+++ fsf/trunk/libc/nscd/servicescache.c Sun Feb 6 00:02:55 2011
@@ -1,5 +1,5 @@
/* Cache handling for services lookup.
- Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2008, 2009, 2011 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@xxxxxxxxxxx>, 2007.
@@ -61,7 +61,7 @@
};
-static void
+static time_t
cache_addserv (struct database_dyn *db, int fd, request_header *req,
const void *key, struct servent *serv, uid_t owner,
struct hashentry *const he, struct datahead *dh, int errval)
@@ -81,6 +81,7 @@
assert (offsetof (struct dataset, resp) == offsetof (struct datahead, data));
+ time_t timeout = MAX_TIMEOUT_VALUE;
if (serv == NULL)
{
if (he != NULL && errval == EAGAIN)
@@ -92,6 +93,9 @@
/* 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 = t + db->postimeout;
+
written = total = 0;
}
else
@@ -115,7 +119,7 @@
dataset->head.usable = true;
/* Compute the timeout time. */
- dataset->head.timeout = t + db->negtimeout;
+ timeout = dataset->head.timeout = t + db->negtimeout;
/* This is the reply. */
memcpy (&dataset->resp, ¬found, total);
@@ -203,7 +207,7 @@
dataset->head.usable = true;
/* Compute the timeout time. */
- dataset->head.timeout = t + db->postimeout;
+ timeout = dataset->head.timeout = t + db->postimeout;
dataset->resp.version = NSCD_VERSION;
dataset->resp.found = 1;
@@ -328,6 +332,8 @@
dbg_log (_("short write in %s: %s"), __FUNCTION__,
strerror_r (errno, buf, sizeof (buf)));
}
+
+ return timeout;
}
@@ -354,7 +360,7 @@
}
-static void
+static time_t
addservbyX (struct database_dyn *db, int fd, request_header *req,
char *key, uid_t uid, struct hashentry *he, struct datahead *dh)
{
@@ -409,10 +415,12 @@
buffer = (char *) extend_alloca (buffer, buflen, 2 * buflen);
}
- cache_addserv (db, fd, req, key, serv, uid, he, dh, errval);
+ time_t timeout = cache_addserv (db, fd, req, key, serv, uid, he, dh, errval);
if (use_malloc)
free (buffer);
+
+ return timeout;
}
@@ -424,7 +432,7 @@
}
-void
+time_t
readdservbyname (struct database_dyn *db, struct hashentry *he,
struct datahead *dh)
{
@@ -434,7 +442,7 @@
.key_len = he->len
};
- addservbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
+ return addservbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
}
@@ -446,7 +454,7 @@
}
-void
+time_t
readdservbyport (struct database_dyn *db, struct hashentry *he,
struct datahead *dh)
{
@@ -456,5 +464,5 @@
.key_len = he->len
};
- addservbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
-}
+ return addservbyX (db, -1, &req, db->data + he->key, he->owner, he, dh);
+}