[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[commits] r7925 - in /fsf/trunk/libc: ./ nptl/ nptl/sysdeps/unix/sysv/linux/sh/ nscd/
- To: commits@xxxxxxxxxx
- Subject: [commits] r7925 - in /fsf/trunk/libc: ./ nptl/ nptl/sysdeps/unix/sysv/linux/sh/ nscd/
- From: eglibc@xxxxxxxxxx
- Date: Sat, 14 Feb 2009 08:05:34 -0000
Author: eglibc
Date: Sat Feb 14 00:05:33 2009
New Revision: 7925
Log:
Import glibc-mainline for 2009-02-14
Modified:
fsf/trunk/libc/ChangeLog
fsf/trunk/libc/nptl/ChangeLog
fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S
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/mem.c
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 Sat Feb 14 00:05:33 2009
@@ -1,3 +1,29 @@
+2009-02-13 Ulrich Drepper <drepper@xxxxxxxxxx>
+
+ [BZ #5381]
+ * nscd/nscd.h: Remove definitions and declarations for mem_in_flight.
+ Change mempool_alloc prototype.
+ * nscd/mem.c (gc): Don't handle mem_in_flight.
+ (mempool_alloc): Third parameter now only indicates whether this is the
+ first call (to allocate data) or not. If it is, get db rdlock.
+ Release it on error. Don't handle mem_in_flight.
+ * nscd/aicache.c (addhstaiX): Mark he parameter as const.
+ Adjust third parameter of mempool_alloc calls.
+ Nothing to do here in case mempool_alloc fails.
+ Avoid local variable shadowing parameter. No need to get db rdlock
+ before calling cache_add.
+ * nscd/cache.c (cache_add): Adjust call to mempool_alloc. There is
+ no mem_in_flight array anymore.
+ * nscd/connections.c: Remove definition and handling of mem_in_flight.
+ * nscd/grpcache.c (cache_addgr): Adjust third parameter of
+ mempool_alloc calls. Mark he parameter as const. Nothing to do here
+ in case mempool_alloc fails. No need to get db rdlock before calling
+ cache_add.
+ * nscd/hstcache.c (cache_addhst): Likewise.
+ * nscd/initgrcache.c (addinitgroupsX): Likewise.
+ * nscd/servicescache.c (cache_addserv): Likewise.
+ * nscd/pwdcache.c (cache_addpw): Likewise. Remove some debugging code.
+
2009-02-11 Ulrich Drepper <drepper@xxxxxxxxxx>
* po/lt.po: Update from translation team.
Modified: fsf/trunk/libc/nptl/ChangeLog
==============================================================================
--- fsf/trunk/libc/nptl/ChangeLog (original)
+++ fsf/trunk/libc/nptl/ChangeLog Sat Feb 14 00:05:33 2009
@@ -1,3 +1,8 @@
+2009-02-14 SUGIOKA Toshinobu <sugioka@xxxxxxxxxxxx>
+
+ * sysdeps/unix/sysv/linux/sh/lowlevellock.S: Define
+ LOAD_FUTEX_WAIT_ABS even if (FUTEX_WAIT == 0).
+
2009-01-29 Ulrich Drepper <drepper@xxxxxxxxxx>
* sysdeps/pthread/unwind-forcedunwind.c: Encrypt all function
Modified: fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S
==============================================================================
--- fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S (original)
+++ fsf/trunk/libc/nptl/sysdeps/unix/sysv/linux/sh/lowlevellock.S Sat Feb 14 00:05:33 2009
@@ -103,7 +103,8 @@
and tmp2, reg ; \
mov #FUTEX_WAIT, tmp ; \
or tmp, reg
-# define LOAD_FUTEX_WAIT_ABS(reg,tmp,tmp2) \
+# endif
+# define LOAD_FUTEX_WAIT_ABS(reg,tmp,tmp2) \
stc gbr, tmp ; \
mov.w 99f, tmp2 ; \
add tmp2, tmp ; \
@@ -119,7 +120,6 @@
swap.b tmp2, tmp2; \
or tmp2, tmp; \
or tmp, reg
-# endif
# define LOAD_FUTEX_WAKE(reg,tmp,tmp2) \
stc gbr, tmp ; \
mov.w 99f, tmp2 ; \
Modified: fsf/trunk/libc/nscd/aicache.c
==============================================================================
--- fsf/trunk/libc/nscd/aicache.c (original)
+++ fsf/trunk/libc/nscd/aicache.c Sat Feb 14 00:05:33 2009
@@ -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@xxxxxxxxxx>, 2004.
@@ -60,7 +60,8 @@
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 @@
/* 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 @@
}
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 @@
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 @@
if (rc == 0)
{
- if (he != NULL)
- canon = he->h_name;
+ if (hstent != NULL)
+ canon = hstent->h_name;
else
canon = key;
}
@@ -352,13 +348,8 @@
/* 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 @@
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 @@
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 @@
if (fd != -1)
TEMP_FAILURE_RETRY (send (fd, ¬found, 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 @@
/* Copy the key data. */
key_copy = memcpy (dataset->strdata, key, req->key_len);
}
- else
- ++db->head->addfailed;
}
out:
@@ -554,9 +540,6 @@
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);
Modified: fsf/trunk/libc/nscd/cache.c
==============================================================================
--- fsf/trunk/libc/nscd/cache.c (original)
+++ fsf/trunk/libc/nscd/cache.c Sat Feb 14 00:05:33 2009
@@ -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@xxxxxxxxxx>, 1998.
@@ -155,20 +155,14 @@
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;
}
@@ -233,10 +227,6 @@
if (do_wakeup)
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;
}
Modified: fsf/trunk/libc/nscd/connections.c
==============================================================================
--- fsf/trunk/libc/nscd/connections.c (original)
+++ fsf/trunk/libc/nscd/connections.c Sat Feb 14 00:05:33 2009
@@ -250,11 +250,6 @@
/* 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 @@
{
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);
Modified: fsf/trunk/libc/nscd/grpcache.c
==============================================================================
--- fsf/trunk/libc/nscd/grpcache.c (original)
+++ fsf/trunk/libc/nscd/grpcache.c Sat Feb 14 00:05:33 2009
@@ -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@xxxxxxxxxx>, 1998.
@@ -74,7 +74,7 @@
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 @@
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 @@
+ 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 @@
if (dh != NULL)
dh->usable = false;
}
- else
- ++db->head->addfailed;
}
}
else
@@ -202,12 +197,7 @@
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 @@
/* 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 @@
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 @@
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
Modified: fsf/trunk/libc/nscd/hstcache.c
==============================================================================
--- fsf/trunk/libc/nscd/hstcache.c (original)
+++ fsf/trunk/libc/nscd/hstcache.c Sat Feb 14 00:05:33 2009
@@ -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@xxxxxxxxxx>, 1998.
@@ -80,7 +80,7 @@
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 @@
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 @@
+ 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 @@
if (dh != NULL)
dh->usable = false;
}
- else
- ++db->head->addfailed;
}
}
else
@@ -221,13 +216,8 @@
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 @@
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 @@
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 @@
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
Modified: fsf/trunk/libc/nscd/initgrcache.c
==============================================================================
--- fsf/trunk/libc/nscd/initgrcache.c (original)
+++ fsf/trunk/libc/nscd/initgrcache.c Sat Feb 14 00:05:33 2009
@@ -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@xxxxxxxxxx>, 2004.
@@ -54,7 +54,7 @@
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 @@
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 @@
+ 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 @@
if (dh != NULL)
dh->usable = false;
}
- else
- ++db->head->addfailed;
}
}
else
@@ -257,13 +252,8 @@
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 @@
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 @@
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 @@
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);
Modified: fsf/trunk/libc/nscd/mem.c
==============================================================================
--- fsf/trunk/libc/nscd/mem.c (original)
+++ fsf/trunk/libc/nscd/mem.c Sat Feb 14 00:05:33 2009
@@ -196,32 +196,6 @@
}
}
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
@@ -540,12 +514,15 @@
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);
@@ -589,24 +566,23 @@
}
}
+ if (data_alloc)
+ pthread_rwlock_unlock (&db->lock);
+
if (! db->last_alloc_failed)
{
dbg_log (_("no more memory for database '%s'"), dbnames[db - dbs]);
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;
Modified: fsf/trunk/libc/nscd/nscd.h
==============================================================================
--- fsf/trunk/libc/nscd/nscd.h (original)
+++ fsf/trunk/libc/nscd/nscd.h Sat Feb 14 00:05:33 2009
@@ -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@xxxxxxx>, 1998.
@@ -182,31 +181,6 @@
/* Old user and group ID. */
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. */
@@ -301,7 +275,7 @@
/* 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);
Modified: fsf/trunk/libc/nscd/pwdcache.c
==============================================================================
--- fsf/trunk/libc/nscd/pwdcache.c (original)
+++ fsf/trunk/libc/nscd/pwdcache.c Sat Feb 14 00:05:33 2009
@@ -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@xxxxxxxxxx>, 1998.
@@ -80,7 +80,7 @@
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 @@
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 @@
+ 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 @@
if (dh != NULL)
dh->usable = false;
}
- else
- ++db->head->addfailed;
}
}
else
@@ -197,12 +192,7 @@
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 @@
{
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 @@
}
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 @@
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 @@
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
Modified: fsf/trunk/libc/nscd/servicescache.c
==============================================================================
--- fsf/trunk/libc/nscd/servicescache.c (original)
+++ fsf/trunk/libc/nscd/servicescache.c Sat Feb 14 00:05:33 2009
@@ -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@xxxxxxxxxxx>, 2007.
@@ -64,7 +64,7 @@
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 @@
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 @@
+ 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 @@
if (dh != NULL)
dh->usable = false;
}
- else
- ++db->head->addfailed;
}
}
else
@@ -187,13 +182,8 @@
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 @@
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 @@
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 @@
+ 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);