diff options
Diffstat (limited to 'nscd/grpcache.c')
-rw-r--r-- | nscd/grpcache.c | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/nscd/grpcache.c b/nscd/grpcache.c index c49c0e1..184d538 100644 --- a/nscd/grpcache.c +++ b/nscd/grpcache.c @@ -1,5 +1,5 @@ /* Cache handling for group lookup. - Copyright (C) 1998-2005, 2006, 2007, 2008 Free Software Foundation, Inc. + Copyright (C) 1998-2008, 2009 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998. @@ -74,7 +74,7 @@ static const gr_response_header notfound = static void cache_addgr (struct database_dyn *db, int fd, request_header *req, const void *key, struct group *grp, uid_t owner, - struct hashentry *he, struct datahead *dh, int errval) + struct hashentry *const he, struct datahead *dh, int errval) { ssize_t total; ssize_t written; @@ -114,7 +114,7 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req, MSG_NOSIGNAL)); dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len, - IDX_result_data); + 1); /* If we cannot permanently store the result, so be it. */ if (dataset != NULL) { @@ -143,9 +143,6 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req, + sizeof (struct dataset) + req->key_len, MS_ASYNC); } - /* Now get the lock to safely insert the records. */ - pthread_rwlock_rdlock (&db->lock); - (void) cache_add (req->type, &dataset->strdata, req->key_len, &dataset->head, true, db, owner, he == NULL); @@ -155,8 +152,6 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req, if (dh != NULL) dh->usable = false; } - else - ++db->head->addfailed; } } else @@ -202,12 +197,7 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req, dataset = NULL; if (he == NULL) - { - dataset = (struct dataset *) mempool_alloc (db, total + n, - IDX_result_data); - if (dataset == NULL) - ++db->head->addfailed; - } + dataset = (struct dataset *) mempool_alloc (db, total + n, 1); if (dataset == NULL) { @@ -277,8 +267,7 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req, /* We have to create a new record. Just allocate appropriate memory and copy it. */ struct dataset *newp - = (struct dataset *) mempool_alloc (db, total + n, - IDX_result_data); + = (struct dataset *) mempool_alloc (db, total + n, 1); if (newp != NULL) { /* Adjust pointers into the memory block. */ @@ -289,8 +278,6 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req, dataset = memcpy (newp, dataset, total + n); alloca_used = false; } - else - ++db->head->addfailed; /* Mark the old record as obsolete. */ dh->usable = false; @@ -343,9 +330,6 @@ cache_addgr (struct database_dyn *db, int fd, request_header *req, MS_ASYNC); } - /* Now get the lock to safely insert the records. */ - pthread_rwlock_rdlock (&db->lock); - /* NB: in the following code we always must add the entry marked with FIRST first. Otherwise we end up with dangling "pointers" in case a latter hash entry cannot be |