* nscd/nscd.h (mem_in_flight): Replace blockaddr field with

blockoff of type nscd_ssize_t.
	* nscd/mem.c (gc): Simplify markrange call for on-flight blocks.
	(mempoll_alloc): Record block offset and not address.
This commit is contained in:
Ulrich Drepper 2008-05-18 03:57:19 +00:00
parent b21595750e
commit 8884028c8e
3 changed files with 18 additions and 11 deletions

View File

@ -1,5 +1,10 @@
2008-05-17 Ulrich Drepper <drepper@redhat.com> 2008-05-17 Ulrich Drepper <drepper@redhat.com>
* nscd/nscd.h (mem_in_flight): Replace blockaddr field with
blockoff of type nscd_ssize_t.
* nscd/mem.c (gc): Simplify markrange call for on-flight blocks.
(mempoll_alloc): Record block offset and not address.
* nscd/mem.c (gc): Fix test for stack overuse. * nscd/mem.c (gc): Fix test for stack overuse.
* nscd/aicache.c (addhstaiX): Fix a few small problems, cleanups, * nscd/aicache.c (addhstaiX): Fix a few small problems, cleanups,

View File

@ -212,11 +212,12 @@ gc (struct database_dyn *db)
for (enum in_flight idx = IDX_result_data; for (enum in_flight idx = IDX_result_data;
idx < IDX_last && mrunp->block[idx].dbidx == db - dbs; ++idx) idx < IDX_last && mrunp->block[idx].dbidx == db - dbs; ++idx)
{ {
assert ((char *) mrunp->block[idx].blockaddr > db->data); assert (mrunp->block[idx].blockoff >= 0);
assert ((char *) mrunp->block[idx].blockaddr assert (mrunp->block[idx].blocklen < db->memsize);
+ mrunp->block[0].blocklen <= db->data + db->memsize); assert (mrunp->block[idx].blockoff
markrange (mark, (char *) mrunp->block[idx].blockaddr - db->data, + mrunp->block[0].blocklen <= db->memsize);
mrunp->block[idx].blocklen); markrange (mark, mrunp->block[idx].blockoff,
mrunp->block[idx].blocklen);
} }
mrunp = mrunp->next; mrunp = mrunp->next;
@ -589,15 +590,16 @@ mempool_alloc (struct database_dyn *db, size_t len, enum in_flight idx)
} }
else else
{ {
db->head->first_free += len;
db->last_alloc_failed = false;
/* Remember that we have allocated this memory. */ /* Remember that we have allocated this memory. */
assert (idx >= 0 && idx < IDX_last); assert (idx >= 0 && idx < IDX_last);
mem_in_flight.block[idx].dbidx = db - dbs; mem_in_flight.block[idx].dbidx = db - dbs;
mem_in_flight.block[idx].blocklen = len; mem_in_flight.block[idx].blocklen = len;
mem_in_flight.block[idx].blockaddr = res; mem_in_flight.block[idx].blockoff = db->head->first_free;
db->head->first_free += len;
db->last_alloc_failed = false;
} }
pthread_mutex_unlock (&db->memlock); pthread_mutex_unlock (&db->memlock);

View File

@ -197,7 +197,7 @@ extern __thread struct mem_in_flight
{ {
int dbidx; int dbidx;
nscd_ssize_t blocklen; nscd_ssize_t blocklen;
void *blockaddr; nscd_ssize_t blockoff;
} block[IDX_last]; } block[IDX_last];
struct mem_in_flight *next; struct mem_in_flight *next;