summaryrefslogtreecommitdiff
path: root/nscd
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2009-02-18 15:49:44 +0000
committerJakub Jelinek <jakub@redhat.com>2009-02-18 15:49:44 +0000
commitcf22c5c9b3a4a6cc81a269d49d2324b5df084d74 (patch)
treeca7e374c348baf4e6510329f3f271eca4eb5419f /nscd
parent73c5dd45bc405428148ee740cac61a1279fe57d4 (diff)
Updated to fedora-glibc-20090218T1534
Diffstat (limited to 'nscd')
-rw-r--r--nscd/aicache.c47
-rw-r--r--nscd/cache.c14
-rw-r--r--nscd/connections.c15
-rw-r--r--nscd/grpcache.c26
-rw-r--r--nscd/hstcache.c27
-rw-r--r--nscd/initgrcache.c27
-rw-r--r--nscd/mem.c42
-rw-r--r--nscd/nscd.c22
-rw-r--r--nscd/nscd.h30
-rw-r--r--nscd/pwdcache.c38
-rw-r--r--nscd/servicescache.c27
11 files changed, 78 insertions, 237 deletions
diff --git a/nscd/aicache.c b/nscd/aicache.c
index 5ffab76a04..524c0a63af 100644
--- a/nscd/aicache.c
+++ b/nscd/aicache.c
@@ -1,5 +1,5 @@
/* Cache handling for host lookup.
- Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+ Copyright (C) 2004-2008, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
@@ -60,7 +60,8 @@ static const ai_response_header notfound =
static void
addhstaiX (struct database_dyn *db, int fd, request_header *req,
- void *key, uid_t uid, struct hashentry *he, struct datahead *dh)
+ void *key, uid_t uid, struct hashentry *const he,
+ struct datahead *dh)
{
/* Search for the entry matching the key. Please note that we don't
look again in the table whether the dataset is now available. We
@@ -172,13 +173,8 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req,
/* Now we can allocate the data structure. If the TTL of the
entry is reported as zero do not cache the entry at all. */
if (ttl != 0 && he == NULL)
- {
- dataset = (struct dataset *) mempool_alloc (db, total
- + req->key_len,
- IDX_result_data);
- if (dataset == NULL)
- ++db->head->addfailed;
- }
+ dataset = (struct dataset *) mempool_alloc (db, total
+ + req->key_len, 1);
if (dataset == NULL)
{
@@ -300,9 +296,9 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req,
}
else
{
- struct hostent *he = NULL;
+ struct hostent *hstent = NULL;
int herrno;
- struct hostent he_mem;
+ struct hostent hstent_mem;
void *addr;
size_t addrlen;
int addrfamily;
@@ -326,8 +322,8 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req,
while (1)
{
rc = __gethostbyaddr2_r (addr, addrlen, addrfamily,
- &he_mem, tmpbuf, tmpbuflen,
- &he, &herrno, NULL);
+ &hstent_mem, tmpbuf, tmpbuflen,
+ &hstent, &herrno, NULL);
if (rc != ERANGE || herrno != NETDB_INTERNAL)
break;
tmpbuf = extend_alloca (tmpbuf, tmpbuflen,
@@ -336,8 +332,8 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req,
if (rc == 0)
{
- if (he != NULL)
- canon = he->h_name;
+ if (hstent != NULL)
+ canon = hstent->h_name;
else
canon = key;
}
@@ -352,13 +348,8 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req,
/* Now we can allocate the data structure. If the TTL of the
entry is reported as zero do not cache the entry at all. */
if (ttl != 0 && he == NULL)
- {
- dataset = (struct dataset *) mempool_alloc (db, total
- + req->key_len,
- IDX_result_data);
- if (dataset == NULL)
- ++db->head->addfailed;
- }
+ dataset = (struct dataset *) mempool_alloc (db, total
+ + req->key_len, 1);
if (dataset == NULL)
{
@@ -436,7 +427,7 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req,
appropriate memory and copy it. */
struct dataset *newp
= (struct dataset *) mempool_alloc (db, total + req->key_len,
- IDX_result_data);
+ 1);
if (__builtin_expect (newp != NULL, 1))
{
/* Adjust pointer into the memory block. */
@@ -445,8 +436,6 @@ addhstaiX (struct database_dyn *db, int fd, request_header *req,
dataset = memcpy (newp, dataset, total + req->key_len);
alloca_used = false;
}
- else
- ++db->head->addfailed;
/* Mark the old record as obsolete. */
dh->usable = false;
@@ -515,8 +504,7 @@ next_nip:
if (fd != -1)
TEMP_FAILURE_RETRY (send (fd, &notfound, total, MSG_NOSIGNAL));
- dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len,
- IDX_result_data);
+ dataset = mempool_alloc (db, sizeof (struct dataset) + req->key_len, 1);
/* If we cannot permanently store the result, so be it. */
if (dataset != NULL)
{
@@ -535,8 +523,6 @@ next_nip:
/* Copy the key data. */
key_copy = memcpy (dataset->strdata, key, req->key_len);
}
- else
- ++db->head->addfailed;
}
out:
@@ -554,9 +540,6 @@ next_nip:
MS_ASYNC);
}
- /* Now get the lock to safely insert the records. */
- pthread_rwlock_rdlock (&db->lock);
-
(void) cache_add (req->type, key_copy, req->key_len, &dataset->head,
true, db, uid, he == NULL);
diff --git a/nscd/cache.c b/nscd/cache.c
index cd6e6b4440..ab842efc29 100644
--- a/nscd/cache.c
+++ b/nscd/cache.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 1998, 1999, 2003-2007, 2008 Free Software Foundation, Inc.
+/* Copyright (c) 1998, 1999, 2003-2008, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
@@ -155,21 +155,15 @@ cache_add (int type, const void *key, size_t len, struct datahead *packet,
unsigned long int hash = __nis_hash (key, len) % table->head->module;
struct hashentry *newp;
- newp = mempool_alloc (table, sizeof (struct hashentry), IDX_record_data);
+ newp = mempool_alloc (table, sizeof (struct hashentry), 0);
/* If we cannot allocate memory, just do not do anything. */
if (newp == NULL)
{
- ++table->head->addfailed;
-
/* If necessary mark the entry as unusable so that lookups will
not use it. */
if (first)
packet->usable = false;
- /* Mark the in-flight memory as unused. */
- for (enum in_flight idx = 0; idx < IDX_record_data; ++idx)
- mem_in_flight.block[idx].dbidx = -1;
-
return -1;
}
@@ -234,10 +228,6 @@ cache_add (int type, const void *key, size_t len, struct datahead *packet,
pthread_cond_signal (&table->prune_cond);
}
- /* Mark the in-flight memory as unused. */
- for (enum in_flight idx = 0; idx < IDX_last; ++idx)
- mem_in_flight.block[idx].dbidx = -1;
-
return 0;
}
diff --git a/nscd/connections.c b/nscd/connections.c
index 7e3a406185..3d0727f33b 100644
--- a/nscd/connections.c
+++ b/nscd/connections.c
@@ -250,11 +250,6 @@ static int have_accept4;
/* Number of times clients had to wait. */
unsigned long int client_queued;
-/* Data structure for recording in-flight memory allocation. */
-__thread struct mem_in_flight mem_in_flight attribute_tls_model_ie;
-/* Global list of the mem_in_flight variables of all the threads. */
-struct mem_in_flight *mem_in_flight_list;
-
ssize_t
writeall (int fd, const void *buf, size_t len)
@@ -1584,16 +1579,6 @@ nscd_run_worker (void *p)
{
char buf[256];
- /* Initialize the memory-in-flight list. */
- for (enum in_flight idx = 0; idx < IDX_last; ++idx)
- mem_in_flight.block[idx].dbidx = -1;
- /* And queue this threads structure. */
- do
- mem_in_flight.next = mem_in_flight_list;
- while (atomic_compare_and_exchange_bool_acq (&mem_in_flight_list,
- &mem_in_flight,
- mem_in_flight.next) != 0);
-
/* Initial locking. */
pthread_mutex_lock (&readylist_lock);
diff --git a/nscd/grpcache.c b/nscd/grpcache.c
index c49c0e1906..184d53898c 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
diff --git a/nscd/hstcache.c b/nscd/hstcache.c
index 4333917ba0..51e2273960 100644
--- a/nscd/hstcache.c
+++ b/nscd/hstcache.c
@@ -1,5 +1,5 @@
/* Cache handling for host 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.
@@ -80,7 +80,7 @@ static const hst_response_header notfound =
static void
cache_addhst (struct database_dyn *db, int fd, request_header *req,
const void *key, struct hostent *hst, uid_t owner,
- struct hashentry *he, struct datahead *dh, int errval,
+ struct hashentry *const he, struct datahead *dh, int errval,
int32_t ttl)
{
bool all_written = true;
@@ -120,7 +120,7 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req,
all_written = false;
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)
{
@@ -150,9 +150,6 @@ cache_addhst (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);
@@ -162,8 +159,6 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req,
if (dh != NULL)
dh->usable = false;
}
- else
- ++db->head->addfailed;
}
}
else
@@ -221,13 +216,8 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req,
questionable whether it is worthwhile complicating the cache
handling just for handling such a special case. */
if (he == NULL && h_addr_list_cnt == 1)
- {
- dataset = (struct dataset *) mempool_alloc (db,
- total + req->key_len,
- IDX_result_data);
- if (dataset == NULL)
- ++db->head->addfailed;
- }
+ dataset = (struct dataset *) mempool_alloc (db, total + req->key_len,
+ 1);
if (dataset == NULL)
{
@@ -316,7 +306,7 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req,
struct dataset *newp
= (struct dataset *) mempool_alloc (db,
total + req->key_len,
- IDX_result_data);
+ 1);
if (newp != NULL)
{
/* Adjust pointers into the memory block. */
@@ -329,8 +319,6 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req,
dataset = memcpy (newp, dataset, total + req->key_len);
alloca_used = false;
}
- else
- ++db->head->addfailed;
}
/* Mark the old record as obsolete. */
@@ -400,9 +388,6 @@ cache_addhst (struct database_dyn *db, int fd, request_header *req,
addr_list_type = (hst->h_length == NS_INADDRSZ
? GETHOSTBYADDR : GETHOSTBYADDRv6);
- /* Now get the lock to safely insert the records. */
- pthread_rwlock_rdlock (&db->lock);
-
/* NB: the following code is really complicated. It has
seemlingly duplicated code paths which do the same. The
problem is that we always must add the hash table entry
diff --git a/nscd/initgrcache.c b/nscd/initgrcache.c
index c5693c6be5..c33aaf315f 100644
--- a/nscd/initgrcache.c
+++ b/nscd/initgrcache.c
@@ -1,5 +1,5 @@
/* Cache handling for host lookup.
- Copyright (C) 2004, 2005, 2006, 2008 Free Software Foundation, Inc.
+ Copyright (C) 2004, 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@redhat.com>, 2004.
@@ -54,7 +54,7 @@ static const initgr_response_header notfound =
static void
addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
- void *key, uid_t uid, struct hashentry *he,
+ void *key, uid_t uid, struct hashentry *const he,
struct datahead *dh)
{
/* Search for the entry matching the key. Please note that we don't
@@ -198,7 +198,7 @@ addinitgroupsX (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)
{
@@ -227,9 +227,6 @@ addinitgroupsX (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, key_copy, req->key_len,
&dataset->head, true, db, uid, he == NULL);
@@ -239,8 +236,6 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
if (dh != NULL)
dh->usable = false;
}
- else
- ++db->head->addfailed;
}
}
else
@@ -257,13 +252,8 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
dataset = NULL;
if (he == NULL)
- {
- dataset = (struct dataset *) mempool_alloc (db,
- total + req->key_len,
- IDX_result_data);
- if (dataset == NULL)
- ++db->head->addfailed;
- }
+ dataset = (struct dataset *) mempool_alloc (db, total + req->key_len,
+ 1);
if (dataset == NULL)
{
@@ -334,7 +324,7 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
appropriate memory and copy it. */
struct dataset *newp
= (struct dataset *) mempool_alloc (db, total + req->key_len,
- IDX_result_data);
+ 1);
if (newp != NULL)
{
/* Adjust pointer into the memory block. */
@@ -343,8 +333,6 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
dataset = memcpy (newp, dataset, total + req->key_len);
alloca_used = false;
}
- else
- ++db->head->addfailed;
/* Mark the old record as obsolete. */
dh->usable = false;
@@ -398,9 +386,6 @@ addinitgroupsX (struct database_dyn *db, int fd, request_header *req,
req->key_len, MS_ASYNC);
}
- /* Now get the lock to safely insert the records. */
- pthread_rwlock_rdlock (&db->lock);
-
(void) cache_add (INITGROUPS, cp, req->key_len, &dataset->head, true,
db, uid, he == NULL);
diff --git a/nscd/mem.c b/nscd/mem.c
index 7f3ea06f4a..fcea6dbd03 100644
--- a/nscd/mem.c
+++ b/nscd/mem.c
@@ -197,32 +197,6 @@ gc (struct database_dyn *db)
}
assert (cnt == db->head->nentries);
- /* Go through the list of in-flight memory blocks. */
- struct mem_in_flight *mrunp = mem_in_flight_list;
- while (mrunp != NULL)
- {
- /* NB: There can be no race between this test and another thread
- setting the field to the index we are looking for because
- this would require the other thread to also have the memlock
- for the database.
-
- NB2: we do not have to look at latter blocks (higher indices) if
- earlier blocks are not in flight. They are always allocated in
- sequence. */
- for (enum in_flight idx = IDX_result_data;
- idx < IDX_last && mrunp->block[idx].dbidx == db - dbs; ++idx)
- {
- assert (mrunp->block[idx].blockoff >= 0);
- assert (mrunp->block[idx].blocklen < db->memsize);
- assert (mrunp->block[idx].blockoff
- + mrunp->block[0].blocklen <= db->memsize);
- markrange (mark, mrunp->block[idx].blockoff,
- mrunp->block[idx].blocklen);
- }
-
- mrunp = mrunp->next;
- }
-
/* Sort the entries by the addresses of the referenced data. All
the entries pointing to the same DATAHEAD object will have the
same key. Stability of the sorting is unimportant. */
@@ -540,13 +514,16 @@ gc (struct database_dyn *db)
void *
-mempool_alloc (struct database_dyn *db, size_t len, enum in_flight idx)
+mempool_alloc (struct database_dyn *db, size_t len, int data_alloc)
{
/* Make sure LEN is a multiple of our maximum alignment so we can
keep track of used memory is multiples of this alignment value. */
if ((len & BLOCK_ALIGN_M1) != 0)
len += BLOCK_ALIGN - (len & BLOCK_ALIGN_M1);
+ if (data_alloc)
+ pthread_rwlock_rdlock (&db->lock);
+
pthread_mutex_lock (&db->memlock);
assert ((db->head->first_free & BLOCK_ALIGN_M1) == 0);
@@ -589,6 +566,9 @@ mempool_alloc (struct database_dyn *db, size_t len, enum in_flight idx)
}
}
+ if (data_alloc)
+ pthread_rwlock_unlock (&db->lock);
+
if (! db->last_alloc_failed)
{
dbg_log (_("no more memory for database '%s'"), dbnames[db - dbs]);
@@ -596,17 +576,13 @@ mempool_alloc (struct database_dyn *db, size_t len, enum in_flight idx)
db->last_alloc_failed = true;
}
+ ++db->head->addfailed;
+
/* No luck. */
res = NULL;
}
else
{
- /* Remember that we have allocated this memory. */
- assert (idx >= 0 && idx < IDX_last);
- mem_in_flight.block[idx].dbidx = db - dbs;
- mem_in_flight.block[idx].blocklen = len;
- mem_in_flight.block[idx].blockoff = db->head->first_free;
-
db->head->first_free += len;
db->last_alloc_failed = false;
diff --git a/nscd/nscd.c b/nscd/nscd.c
index 1129cf8480..3265ea8973 100644
--- a/nscd/nscd.c
+++ b/nscd/nscd.c
@@ -91,6 +91,9 @@ static int write_pid (const char *file);
static void print_version (FILE *stream, struct argp_state *state);
void (*argp_program_version_hook) (FILE *, struct argp_state *) = print_version;
+/* Function to print some extra text in the help message. */
+static char *more_help (int key, const char *text, void *input);
+
/* Definitions of arguments for argp functions. */
static const struct argp_option options[] =
{
@@ -117,7 +120,7 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state);
/* Data structure to communicate with argp functions. */
static struct argp argp =
{
- options, parse_opt, NULL, doc,
+ options, parse_opt, NULL, doc, NULL, more_help
};
/* True if only statistics are requested. */
@@ -401,6 +404,23 @@ parse_opt (int key, char *arg, struct argp_state *state)
return 0;
}
+/* Print bug-reporting information in the help message. */
+static char *
+more_help (int key, const char *text, void *input)
+{
+ switch (key)
+ {
+ case ARGP_KEY_HELP_EXTRA:
+ /* We print some extra information. */
+ return strdup (gettext ("\
+For bug reporting instructions, please see:\n\
+<http://www.gnu.org/software/libc/bugs.html>.\n"));
+ default:
+ break;
+ }
+ return (char *) text;
+}
+
/* Print the version information. */
static void
print_version (FILE *stream, struct argp_state *state)
diff --git a/nscd/nscd.h b/nscd/nscd.h
index 2d77bab989..3279b85432 100644
--- a/nscd/nscd.h
+++ b/nscd/nscd.h
@@ -1,5 +1,4 @@
-/* Copyright (c) 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007, 2008
- Free Software Foundation, Inc.
+/* Copyright (c) 1998-2001, 2003-2008, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Thorsten Kukuk <kukuk@suse.de>, 1998.
@@ -184,31 +183,6 @@ extern uid_t old_uid;
extern gid_t old_gid;
-/* Memory allocation in flight. Each thread can have a limited number
- of allocation in flight. No need to create dynamic data
- structures. We use fixed indices. */
-enum in_flight
- {
- IDX_result_data = 0,
- /* Keep the IDX_record_data entry last at all times. */
- IDX_record_data = 1,
- IDX_last
- };
-extern __thread struct mem_in_flight
-{
- struct
- {
- int dbidx;
- nscd_ssize_t blocklen;
- nscd_ssize_t blockoff;
- } block[IDX_last];
-
- struct mem_in_flight *next;
-} mem_in_flight attribute_tls_model_ie;
-/* Global list of the mem_in_flight variables of all the threads. */
-extern struct mem_in_flight *mem_in_flight_list;
-
-
/* Prototypes for global functions. */
/* nscd.c */
@@ -301,7 +275,7 @@ extern void readdservbyport (struct database_dyn *db, struct hashentry *he,
/* mem.c */
extern void *mempool_alloc (struct database_dyn *db, size_t len,
- enum in_flight idx);
+ int data_alloc);
extern void gc (struct database_dyn *db);
diff --git a/nscd/pwdcache.c b/nscd/pwdcache.c
index 782b101371..2338e7e1e0 100644
--- a/nscd/pwdcache.c
+++ b/nscd/pwdcache.c
@@ -1,5 +1,5 @@
/* Cache handling for passwd 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.
@@ -80,7 +80,7 @@ static const pw_response_header notfound =
static void
cache_addpw (struct database_dyn *db, int fd, request_header *req,
const void *key, struct passwd *pwd, 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;
@@ -121,7 +121,7 @@ cache_addpw (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)
{
@@ -150,9 +150,6 @@ cache_addpw (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, key_copy, req->key_len,
&dataset->head, true, db, owner, he == NULL);
@@ -162,8 +159,6 @@ cache_addpw (struct database_dyn *db, int fd, request_header *req,
if (dh != NULL)
dh->usable = false;
}
- else
- ++db->head->addfailed;
}
}
else
@@ -197,12 +192,7 @@ cache_addpw (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)
{
@@ -257,19 +247,10 @@ cache_addpw (struct database_dyn *db, int fd, request_header *req,
{
assert (fd == -1);
-#if 0
- if (dataset->head.datasize == dh->allocsize
+ if (dataset->head.allocsize == dh->allocsize
&& dataset->head.recsize == dh->recsize
&& memcmp (&dataset->resp, dh->data,
dh->allocsize - offsetof (struct dataset, resp)) == 0)
-#else
- if (dataset->head.allocsize != dh->allocsize)
- goto nnn;
- if (dataset->head.recsize != dh->recsize)
- goto nnn;
- if(memcmp (&dataset->resp, dh->data,
- dh->allocsize - offsetof (struct dataset, resp)) == 0)
-#endif
{
/* The data has not changed. We will just bump the
timeout value. Note that the new record has been
@@ -279,12 +260,10 @@ cache_addpw (struct database_dyn *db, int fd, request_header *req,
}
else
{
- nnn:;
/* 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 pointer into the memory block. */
@@ -294,8 +273,6 @@ cache_addpw (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;
@@ -349,9 +326,6 @@ cache_addpw (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
diff --git a/nscd/servicescache.c b/nscd/servicescache.c
index 44f12a3c69..dc98d3005a 100644
--- a/nscd/servicescache.c
+++ b/nscd/servicescache.c
@@ -1,5 +1,5 @@
/* Cache handling for services lookup.
- Copyright (C) 2007, 2008 Free Software Foundation, Inc.
+ Copyright (C) 2007, 2008, 2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@drepper.com>, 2007.
@@ -64,7 +64,7 @@ static const serv_response_header notfound =
static void
cache_addserv (struct database_dyn *db, int fd, request_header *req,
const void *key, struct servent *serv, 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;
@@ -104,7 +104,7 @@ cache_addserv (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)
{
@@ -133,9 +133,6 @@ cache_addserv (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);
@@ -145,8 +142,6 @@ cache_addserv (struct database_dyn *db, int fd, request_header *req,
if (dh != NULL)
dh->usable = false;
}
- else
- ++db->head->addfailed;
}
}
else
@@ -187,13 +182,8 @@ cache_addserv (struct database_dyn *db, int fd, request_header *req,
dataset = NULL;
if (he == NULL)
- {
- dataset = (struct dataset *) mempool_alloc (db,
- total + req->key_len,
- IDX_result_data);
- if (dataset == NULL)
- ++db->head->addfailed;
- }
+ dataset = (struct dataset *) mempool_alloc (db, total + req->key_len,
+ 1);
if (dataset == NULL)
{
@@ -262,7 +252,7 @@ cache_addserv (struct database_dyn *db, int fd, request_header *req,
appropriate memory and copy it. */
struct dataset *newp
= (struct dataset *) mempool_alloc (db, total + req->key_len,
- IDX_result_data);
+ 1);
if (newp != NULL)
{
/* Adjust pointers into the memory block. */
@@ -273,8 +263,6 @@ cache_addserv (struct database_dyn *db, int fd, request_header *req,
dataset = memcpy (newp, dataset, total + req->key_len);
alloca_used = false;
}
- else
- ++db->head->addfailed;
/* Mark the old record as obsolete. */
dh->usable = false;
@@ -327,9 +315,6 @@ cache_addserv (struct database_dyn *db, int fd, request_header *req,
+ total + req->key_len, MS_ASYNC);
}
- /* Now get the lock to safely insert the records. */
- pthread_rwlock_rdlock (&db->lock);
-
(void) cache_add (req->type, key_copy, req->key_len,
&dataset->head, true, db, owner, he == NULL);