2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

Removed the requirement for isc_mem_setwater() that when the callback function

is not null then hi_water must exceed lo_water and both must be > 0.
Now requires hi_water >= lo_water, and they can both be 0.  Not allowing
them to be equal was just an unnecessary restriction, and letting them be 0
is useful for the case where the context has had non-zero values set, went
over hi_water and called the callback, and then wanted to remove limits
(perhaps because of a reconfiguration).  This allows the callback to
be signaled as ISC_MEM_LOWATER on the next isc_mem_put(), which the caller
might need to terminate any outstanding action that was triggered by
the hi_water.
This commit is contained in:
David Lawrence
2001-06-05 22:14:20 +00:00
parent 92296c744e
commit 65640f401a
2 changed files with 21 additions and 17 deletions

View File

@@ -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
*/
/*

View File

@@ -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 <config.h>
@@ -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) {