summaryrefslogtreecommitdiff
path: root/sys/kern/subr_pool.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/kern/subr_pool.c')
-rw-r--r--sys/kern/subr_pool.c38
1 files changed, 25 insertions, 13 deletions
diff --git a/sys/kern/subr_pool.c b/sys/kern/subr_pool.c
index c0942d2b7f3..607e9ea513d 100644
--- a/sys/kern/subr_pool.c
+++ b/sys/kern/subr_pool.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: subr_pool.c,v 1.118 2013/04/06 13:41:11 deraadt Exp $ */
+/* $OpenBSD: subr_pool.c,v 1.119 2013/04/17 17:44:03 tedu Exp $ */
/* $NetBSD: subr_pool.c,v 1.61 2001/09/26 07:14:56 chs Exp $ */
/*-
@@ -244,6 +244,14 @@ pool_init(struct pool *pp, size_t size, u_int align, u_int ioff, int flags,
const char *wchan, struct pool_allocator *palloc)
{
int off, slack;
+#ifdef DIAGNOSTIC
+ struct pool *iter;
+
+ SIMPLEQ_FOREACH(iter, &pool_head, pr_poollist) {
+ if (iter == pp)
+ panic("init pool already on list");
+ }
+#endif
#ifdef MALLOC_DEBUG
if ((flags & PR_DEBUG) && (ioff != 0 || align != 0))
@@ -417,17 +425,6 @@ pool_destroy(struct pool *pp)
struct pool_item_header *ph;
struct pool *prev, *iter;
-#ifdef DIAGNOSTIC
- if (pp->pr_nout != 0)
- panic("pool_destroy: pool busy: still out: %u", pp->pr_nout);
-#endif
-
- /* Remove all pages */
- while ((ph = LIST_FIRST(&pp->pr_emptypages)) != NULL)
- pr_rmpage(pp, ph, NULL);
- KASSERT(LIST_EMPTY(&pp->pr_fullpages));
- KASSERT(LIST_EMPTY(&pp->pr_partpages));
-
/* Remove from global pool list */
if (pp == SIMPLEQ_FIRST(&pool_head))
SIMPLEQ_REMOVE_HEAD(&pool_head, pr_poollist);
@@ -437,11 +434,26 @@ pool_destroy(struct pool *pp)
if (iter == pp) {
SIMPLEQ_REMOVE_AFTER(&pool_head, prev,
pr_poollist);
- break;
+ goto removed;
}
prev = iter;
}
+#ifdef DIAGNOSTIC
+ panic("destroyed pool not on list");
+#endif
}
+removed:
+#ifdef DIAGNOSTIC
+ if (pp->pr_nout != 0)
+ panic("pool_destroy: pool busy: still out: %u", pp->pr_nout);
+#endif
+
+ /* Remove all pages */
+ while ((ph = LIST_FIRST(&pp->pr_emptypages)) != NULL)
+ pr_rmpage(pp, ph, NULL);
+ KASSERT(LIST_EMPTY(&pp->pr_fullpages));
+ KASSERT(LIST_EMPTY(&pp->pr_partpages));
+
}
struct pool_item_header *