Add a DEBUG check that panics if pool_init() is called more than
once on the same pool. As discussed on tech-kern a few months ago.
This commit is contained in:
parent
ce21617f93
commit
727facb192
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: subr_pool.c,v 1.115 2006/04/15 04:47:11 christos Exp $ */
|
||||
/* $NetBSD: subr_pool.c,v 1.116 2006/04/15 14:23:11 simonb Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1997, 1999, 2000 The NetBSD Foundation, Inc.
|
||||
@ -38,7 +38,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.115 2006/04/15 04:47:11 christos Exp $");
|
||||
__KERNEL_RCSID(0, "$NetBSD: subr_pool.c,v 1.116 2006/04/15 14:23:11 simonb Exp $");
|
||||
|
||||
#include "opt_pool.h"
|
||||
#include "opt_poollog.h"
|
||||
@ -468,13 +468,27 @@ void
|
||||
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 DEBUG
|
||||
struct pool *pp1;
|
||||
#endif
|
||||
size_t trysize, phsize;
|
||||
int s;
|
||||
int off, slack, s;
|
||||
|
||||
KASSERT((1UL << (CHAR_BIT * sizeof(pool_item_freelist_t))) - 2 >=
|
||||
PHPOOL_FREELIST_NELEM(PHPOOL_MAX - 1));
|
||||
|
||||
#ifdef DEBUG
|
||||
/*
|
||||
* Check that the pool hasn't already been initialised and
|
||||
* added to the list of all pools.
|
||||
*/
|
||||
LIST_FOREACH(pp1, &pool_head, pr_poollist) {
|
||||
if (pp == pp1)
|
||||
panic("pool_init: pool %s already initialised",
|
||||
wchan);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef POOL_DIAGNOSTIC
|
||||
/*
|
||||
* Always log if POOL_DIAGNOSTIC is defined.
|
||||
|
Loading…
Reference in New Issue
Block a user