aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@gmail.com>2011-07-01 23:02:09 -0400
committerUlrich Drepper <drepper@gmail.com>2011-07-01 23:02:09 -0400
commit99231d9abe0fd74c7957d25b08c1d1ede4cae5a0 (patch)
tree6dc0e8933810858078f847cd60b9c592f6660e6c
parent445b4a53ea9d6c457c5f4ac1538102d8be0a5d89 (diff)
downloadglibc-99231d9abe0fd74c7957d25b08c1d1ede4cae5a0.tar
glibc-99231d9abe0fd74c7957d25b08c1d1ede4cae5a0.tar.gz
glibc-99231d9abe0fd74c7957d25b08c1d1ede4cae5a0.tar.bz2
glibc-99231d9abe0fd74c7957d25b08c1d1ede4cae5a0.zip
nscd cleanups
Cleanup and optimize last patch. Add timeout fixes also to the services cache.
-rw-r--r--ChangeLog9
-rw-r--r--nscd/aicache.c5
-rw-r--r--nscd/hstcache.c5
-rw-r--r--nscd/initgrcache.c7
-rw-r--r--nscd/pwdcache.c5
-rw-r--r--nscd/servicescache.c11
6 files changed, 30 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index a4cd52e5d0..802b5692d8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-07-01 Ulrich Drepper <drepper@gmail.com>
+
+ * nscd/pwdcache.c (cache_addpw): Cleanup. Add branch prediction.
+ * nscd/initgrcache.c (addinitgroupsX): Likewise.
+ * nscd/hstcache.c (cache_addhst): Likewise.
+ * nscd/grpcache.c (cache_addgr): Likewise.
+ * nscd/aicache.c (addhstaiX): Likewise
+ * nscd/servicescache.c (cache_addserv): Handle zero negtimeout.
+
2011-07-01 Thorsten Kukuk <kukuk@suse.de>
* nscd/pwdcache.c (cache_addpw): Handle zero negtimeout.
diff --git a/nscd/aicache.c b/nscd/aicache.c
index b1369214ea..8d100f8d31 100644
--- a/nscd/aicache.c
+++ b/nscd/aicache.c
@@ -512,14 +512,15 @@ next_nip:
TEMP_FAILURE_RETRY (send (fd, &notfound, total, MSG_NOSIGNAL));
/* If we cannot permanently store the result, so be it. */
- if (db->negtimeout == 0)
+ if (__builtin_expect (db->negtimeout == 0, 0))
{
/* Mark the old entry as obsolete. */
if (dh != NULL)
dh->usable = false;
dataset = NULL;
}
- else if ((dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len, 1)) != NULL)
+ else if ((dataset = mempool_alloc (db, (sizeof (struct dataset)
+ + req->key_len), 1)) != NULL)
{
dataset->head.allocsize = sizeof (struct dataset) + req->key_len;
dataset->head.recsize = total;
diff --git a/nscd/hstcache.c b/nscd/hstcache.c
index 1f09c0b975..4d68ade98c 100644
--- a/nscd/hstcache.c
+++ b/nscd/hstcache.c
@@ -142,13 +142,14 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req,
all_written = false;
/* If we cannot permanently store the result, so be it. */
- if (db->negtimeout == 0)
+ if (__builtin_expect (db->negtimeout == 0, 0))
{
/* Mark the old entry as obsolete. */
if (dh != NULL)
dh->usable = false;
}
- else if ((dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len, 1)) != NULL)
+ else if ((dataset = mempool_alloc (db, (sizeof (struct dataset)
+ + req->key_len), 1)) != NULL)
{
dataset->head.allocsize = sizeof (struct dataset) + req->key_len;
dataset->head.recsize = total;
diff --git a/nscd/initgrcache.c b/nscd/initgrcache.c
index 7fd564d0bc..4ac9942aeb 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, 2011 Free Software Foundation, Inc.
+ Copyright (C) 2004-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.
@@ -203,13 +203,14 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
MSG_NOSIGNAL));
/* If we cannot permanently store the result, so be it. */
- if (db->negtimeout == 0)
+ if (__builtin_expect (db->negtimeout == 0, 0))
{
/* Mark the old entry as obsolete. */
if (dh != NULL)
dh->usable = false;
}
- else if ((dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len, 1)) != NULL)
+ else if ((dataset = mempool_alloc (db, (sizeof (struct dataset)
+ + req->key_len), 1)) != NULL)
{
dataset->head.allocsize = sizeof (struct dataset) + req->key_len;
dataset->head.recsize = total;
diff --git a/nscd/pwdcache.c b/nscd/pwdcache.c
index 94e1c52793..49e130c1f0 100644
--- a/nscd/pwdcache.c
+++ b/nscd/pwdcache.c
@@ -125,13 +125,14 @@ cache_addpw (struct database_dyn *db, int fd, request_header *req,
MSG_NOSIGNAL));
/* If we cannot permanently store the result, so be it. */
- if (db->negtimeout == 0)
+ if (__builtin_expect (db->negtimeout == 0, 0))
{
/* Mark the old entry as obsolete. */
if (dh != NULL)
dh->usable = false;
}
- else if ((dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len, 1)) != NULL)
+ else if ((dataset = mempool_alloc (db, (sizeof (struct dataset)
+ + req->key_len), 1)) != NULL)
{
dataset->head.allocsize = sizeof (struct dataset) + req->key_len;
dataset->head.recsize = total;
diff --git a/nscd/servicescache.c b/nscd/servicescache.c
index b0a2977935..ec5a367db8 100644
--- a/nscd/servicescache.c
+++ b/nscd/servicescache.c
@@ -108,10 +108,15 @@ cache_addserv (struct database_dyn *db, int fd, request_header *req,
written = TEMP_FAILURE_RETRY (send (fd, &notfound, total,
MSG_NOSIGNAL));
- dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len,
- 1);
/* If we cannot permanently store the result, so be it. */
- if (dataset != NULL)
+ if (__builtin_expect (db->negtimeout == 0, 0))
+ {
+ /* Mark the old entry as obsolete. */
+ if (dh != NULL)
+ dh->usable = false;
+ }
+ else if ((dataset = mempool_alloc (db, (sizeof (struct dataset)
+ + req->key_len), 1)) != NULL)
{
dataset->head.allocsize = sizeof (struct dataset) + req->key_len;
dataset->head.recsize = total;