aboutsummaryrefslogtreecommitdiff
path: root/nscd/cache.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2007-01-14 05:26:04 +0000
committerUlrich Drepper <drepper@redhat.com>2007-01-14 05:26:04 +0000
commitb21fa963c4194082792a26023f265ebe50ca5c9e (patch)
tree78c2bb40d7a4fdb8b0b9c2c424fba511613e70e8 /nscd/cache.c
parent23691ab23b6e631ae0c5cf58455cca25a0058e22 (diff)
downloadglibc-b21fa963c4194082792a26023f265ebe50ca5c9e.zip
glibc-b21fa963c4194082792a26023f265ebe50ca5c9e.tar.gz
glibc-b21fa963c4194082792a26023f265ebe50ca5c9e.tar.bz2
* nis/nss_nis/nis-service.c (_nss_nis_getservbyname_r): Correct
computation of keylen.
Diffstat (limited to 'nscd/cache.c')
-rw-r--r--nscd/cache.c70
1 files changed, 24 insertions, 46 deletions
diff --git a/nscd/cache.c b/nscd/cache.c
index ef986f3..e63a4f8 100644
--- a/nscd/cache.c
+++ b/nscd/cache.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1998, 1999, 2003-2005, 2006 Free Software Foundation, Inc.
+/* Copyright (c) 1998, 1999, 2003-2006, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
@@ -40,6 +40,25 @@
unsigned int reload_count = DEFAULT_RELOAD_LIMIT;
+static void (*const readdfcts[LASTREQ]) (struct database_dyn *,
+ struct hashentry *,
+ struct datahead *) =
+{
+ [GETPWBYNAME] = readdpwbyname,
+ [GETPWBYUID] = readdpwbyuid,
+ [GETGRBYNAME] = readdgrbyname,
+ [GETGRBYGID] = readdgrbygid,
+ [GETHOSTBYNAME] = readdhstbyname,
+ [GETHOSTBYNAMEv6] = readdhstbynamev6,
+ [GETHOSTBYADDR] = readdhstbyaddr,
+ [GETHOSTBYADDRv6] = readdhstbyaddrv6,
+ [GETAI] = readdhstai,
+ [INITGROUPS] = readdinitgroups,
+ [GETSERVBYNAME] = readdservbyname,
+ [GETSERVBYPORT] = readdservbyport
+};
+
+
/* Search the cache for a matching entry and return it when found. If
this fails search the negative cache and return (void *) -1 if this
search was successful. Otherwise return NULL.
@@ -328,51 +347,10 @@ prune_cache (struct database_dyn *table, time_t now, int fd)
/* Reload the value. We do this only for the
initially used key, not the additionally
added derived value. */
- switch (runp->type)
- {
- case GETPWBYNAME:
- readdpwbyname (table, runp, dh);
- break;
-
- case GETPWBYUID:
- readdpwbyuid (table, runp, dh);
- break;
-
- case GETGRBYNAME:
- readdgrbyname (table, runp, dh);
- break;
-
- case GETGRBYGID:
- readdgrbygid (table, runp, dh);
- break;
-
- case GETHOSTBYNAME:
- readdhstbyname (table, runp, dh);
- break;
-
- case GETHOSTBYNAMEv6:
- readdhstbynamev6 (table, runp, dh);
- break;
-
- case GETHOSTBYADDR:
- readdhstbyaddr (table, runp, dh);
- break;
-
- case GETHOSTBYADDRv6:
- readdhstbyaddrv6 (table, runp, dh);
- break;
-
- case GETAI:
- readdhstai (table, runp, dh);
- break;
-
- case INITGROUPS:
- readdinitgroups (table, runp, dh);
- break;
-
- default:
- assert (! "should never happen");
- }
+ assert (runp->type < LASTREQ
+ && readdfcts[runp->type] != NULL);
+
+ readdfcts[runp->type] (table, runp, dh);
/* If the entry has been replaced, we might need
cleanup. */