From 95cad50c053fda877e2a640d7301c31704b4c889 Mon Sep 17 00:00:00 2001 From: Not Zed Date: Wed, 15 Aug 2001 14:41:57 +0000 Subject: Use a next pointer so we keep the list intact as we scan it. 2001-08-16 Not Zed * ibex_block.c (ibex_use): Use a next pointer so we keep the list intact as we scan it. svn path=/trunk/; revision=12049 --- libibex/ChangeLog | 5 +++++ libibex/ibex_block.c | 8 +++++--- libibex/testindex.c | 3 ++- 3 files changed, 12 insertions(+), 4 deletions(-) (limited to 'libibex') diff --git a/libibex/ChangeLog b/libibex/ChangeLog index 7691a94e5c..a47320019f 100644 --- a/libibex/ChangeLog +++ b/libibex/ChangeLog @@ -1,3 +1,8 @@ +2001-08-16 Not Zed + + * ibex_block.c (ibex_use): Use a next pointer so we keep the list + intact as we scan it. + 2001-08-15 Not Zed * ibex_block.c (ibex_use): New function to limit use of fd's. diff --git a/libibex/ibex_block.c b/libibex/ibex_block.c index ea326949ae..23b225cbc6 100644 --- a/libibex/ibex_block.c +++ b/libibex/ibex_block.c @@ -33,7 +33,7 @@ int ibex_opened; /* count of actually opened ibexe's */ /* TODO: return errors? */ static void ibex_use(ibex *ib) { - ibex *wb; + ibex *wb, *wn; /* always lock list then ibex */ IBEX_LIST_LOCK(ib); @@ -66,8 +66,8 @@ static void ibex_use(ibex *ib) we can't do this first for locking issues */ if (ibex_opened > IBEX_OPEN_THRESHOLD) { wb = (ibex *)ibex_list.head; - while (wb->next) { - wb = wb->next; + wn = wb->next; + while (wn) { IBEX_LOCK(wb); if (wb->usecount == 0 && wb->blocks != NULL) { o(printf("Forcing close of obex '%s', total = %d\n", wb->name, ibex_opened-1)); @@ -80,6 +80,8 @@ static void ibex_use(ibex *ib) break; } IBEX_UNLOCK(wb); + wb = wn; + wn = wn->next; } } diff --git a/libibex/testindex.c b/libibex/testindex.c index acfa892360..064ff1b7ac 100644 --- a/libibex/testindex.c +++ b/libibex/testindex.c @@ -223,7 +223,7 @@ int main(int argc, char **argv) /* random name */ name = words->pdata[word % words->len]; - if (j%1000 == 0) { + if (j%1000 == 0 && j>0) { IBEX_LOCK(ib); word_index_mem_dump_info(ib->words); IBEX_UNLOCK(ib); @@ -284,6 +284,7 @@ int main(int argc, char **argv) ibex_close(ib); ib = ibex_open("test.ibex", O_RDWR|O_CREAT, 0600); + ibex_contains_name(ib, name); IBEX_LOCK(ib); word_index_mem_dump_info(ib->words); IBEX_UNLOCK(ib); -- cgit v1.2.3