diff options
author | Ulrich Drepper <drepper@redhat.com> | 2008-04-19 16:42:41 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2008-04-19 16:42:41 +0000 |
commit | c52137d39101515cacb67a2bcd43b77bd06284e0 (patch) | |
tree | 301583f49438de52f3a7cf54676d958b4158ec8f /nscd/mem.c | |
parent | 87a71b8d67e501d422528b8435e733e8e78a165a (diff) | |
download | glibc-c52137d39101515cacb67a2bcd43b77bd06284e0.tar.gz glibc-c52137d39101515cacb67a2bcd43b77bd06284e0.tar.xz glibc-c52137d39101515cacb67a2bcd43b77bd06284e0.zip |
[BZ #5209, BZ #5381]
2008-04-15 Ulrich Drepper <drepper@redhat.com> [BZ #5209] * sysdeps/unix/sysv/linux/times.c: New file. [BZ #5381] * nscd/nscd.h: Define enum in_flight, mem_in_flight, and mem_in_flight_list variables. Add new parameter to mempool_alloc prototype. * nscd/mem.c (mempool_alloc): Take additional parameter. Initialize appropriate mem_in_flight element. (gc): Take allocations which have not yet been committed to the database into account. * nscd/cache.c (cache_add): Add new parameter to mempool_alloc call. Reset mem_in_flight before returning. * nscd/connections.c (nscd_run_worker): Initialize mem_in_flight and cue it up in mem_in_flight_list. * nscd/aicache.c: Adjust mempool_alloc call. * nscd/grpcache.c: Likewise. * nscd/hstcache.c: Likewise. * nscd/initgrcache.c: Likewise. * nscd/pwdcache.c: Likewise. * nscd/servicescache.c: Likewise. * nscd/Makefile (nscd-flags): Until ld is fixed, use -fpic instead of -fpie. * nscd/connections.c (handle_request): Provide better error message in case SELinux forbids the service. * version.h (VERSION): Bump to 2.8.90.
Diffstat (limited to 'nscd/mem.c')
-rw-r--r-- | nscd/mem.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/nscd/mem.c b/nscd/mem.c index 048e3ddd32..14928d633c 100644 --- a/nscd/mem.c +++ b/nscd/mem.c @@ -1,5 +1,5 @@ /* Cache memory handling. - Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2006, 2008 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper <drepper@redhat.com>, 2004. @@ -197,6 +197,31 @@ 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 ((char *) mrunp->block[idx].blockaddr > db->data); + assert ((char *) mrunp->block[idx].blockaddr + + mrunp->block[0].blocklen <= db->data + db->memsize); + markrange (mark, (char *) mrunp->block[idx].blockaddr - db->data, + 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. */ @@ -503,7 +528,7 @@ gc (struct database_dyn *db) void * -mempool_alloc (struct database_dyn *db, size_t len) +mempool_alloc (struct database_dyn *db, size_t len, enum in_flight idx) { /* Make sure LEN is a multiple of our maximum alignment so we can keep track of used memory is multiples of this alignment value. */ @@ -567,6 +592,12 @@ mempool_alloc (struct database_dyn *db, size_t len) db->head->first_free += len; db->last_alloc_failed = false; + + /* 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].blockaddr = res; } pthread_mutex_unlock (&db->memlock); |