diff --git a/lib/isc/include/isc/mem.h b/lib/isc/include/isc/mem.h index bcd75fd983..9c5c5f5863 100644 --- a/lib/isc/include/isc/mem.h +++ b/lib/isc/include/isc/mem.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: mem.h,v 1.50 2001/03/05 18:20:24 mayer Exp $ */ +/* $Id: mem.h,v 1.51 2001/06/05 22:14:20 tale Exp $ */ #ifndef ISC_MEM_H #define ISC_MEM_H 1 @@ -248,6 +248,7 @@ isc_mem_inuse(isc_mem_t *mctx); */ void + isc_mem_setwater(isc_mem_t *mctx, isc_mem_water_t water, void *water_arg, size_t hiwater, size_t lowater); /* @@ -256,14 +257,13 @@ isc_mem_setwater(isc_mem_t *mctx, isc_mem_water_t water, void *water_arg, * will be called. When the usage drops below 'lowater', 'water' will * again be called, this time with ISC_MEM_LOWATER. * - * Requires: - * If 'water' is NULL then 'water_arg', 'hi_water' and 'lo_water' are - * ignored and the state is reset. Otherwise, requires + * If 'water' is NULL then 'water_arg', 'hi_water' and 'lo_water' are + * ignored and the state is reset. * - * 'water' to point to a valid function. - * 'hi_water > lo_water' - * 'lo_water != 0' - * 'hi_water != 0' + * Requires: + * + * 'water' is not NULL. + * hi_water >= lo_water */ /* diff --git a/lib/isc/mem.c b/lib/isc/mem.c index c9daf80f50..82ee263071 100644 --- a/lib/isc/mem.c +++ b/lib/isc/mem.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: mem.c,v 1.91 2001/06/04 19:33:25 tale Exp $ */ +/* $Id: mem.c,v 1.92 2001/06/05 22:14:18 tale Exp $ */ #include @@ -1001,9 +1001,18 @@ isc__mem_put(isc_mem_t *ctx, void *ptr, size_t size FLARG) #endif /* ISC_MEM_USE_INTERNAL_MALLOC */ DELETE_TRACE(ctx, ptr, size, file, line); - if (ctx->hi_called && ctx->inuse < ctx->lo_water) { + + /* + * The check against ctx->lo_water == 0 is for the condition + * when the context was pushed over hi_water but then had + * isc_mem_setwater() called with 0 for hi_water and lo_water. + */ + if (ctx->hi_called && + (ctx->inuse < ctx->lo_water || ctx->lo_water == 0)) { ctx->hi_called = ISC_FALSE; - call_water = ISC_TRUE; + + if (ctx->water != NULL) + call_water = ISC_TRUE; } UNLOCK(&ctx->lock); @@ -1272,12 +1281,7 @@ isc_mem_setwater(isc_mem_t *ctx, isc_mem_water_t water, void *water_arg, size_t hiwater, size_t lowater) { REQUIRE(VALID_CONTEXT(ctx)); - - if (water != NULL) { - REQUIRE(hiwater > lowater); - REQUIRE(hiwater > 0); - REQUIRE(lowater > 0); - } + REQUIRE(hiwater >= lowater); LOCK(&ctx->lock); if (water == NULL) {