From 6277537cb346b049172c67f1cdcf25bfa56f6f93 Mon Sep 17 00:00:00 2001 From: green Date: Sat, 30 Dec 2000 16:10:32 +0000 Subject: Fix a tailq conversion bug that resulted in, e.g., nvi crashing upon quitting every time. The way to free a CIRCLEQ was to loop until the current == current->head, but the way to free a TAILQ is to loop until current->head == NULL. In any case, the CORRECT way to do it is a loop of TAILQ_EMPTY() checks and TAILQ_REMOVE()al of TAILQ_FIRST(). This bug wouldn't have happened if the loop wasn't hard-coded... There may be more bugs of this type from the conversion. --- lib/libc/db/mpool/mpool.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/libc/db/mpool') diff --git a/lib/libc/db/mpool/mpool.c b/lib/libc/db/mpool/mpool.c index 59ed4d3..a4ab912 100644 --- a/lib/libc/db/mpool/mpool.c +++ b/lib/libc/db/mpool/mpool.c @@ -271,7 +271,8 @@ mpool_close(mp) BKT *bp; /* Free up any space allocated to the lru pages. */ - while ((bp = TAILQ_FIRST(&mp->lqh)) != (void *)&mp->lqh) { + while (!TAILQ_EMPTY(&mp->lqh)) { + bp = TAILQ_FIRST(&mp->lqh); TAILQ_REMOVE(&mp->lqh, bp, q); free(bp); } -- cgit v1.1