mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-03 08:05:21 +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:
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* 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
|
#ifndef ISC_MEM_H
|
||||||
#define ISC_MEM_H 1
|
#define ISC_MEM_H 1
|
||||||
@@ -248,6 +248,7 @@ isc_mem_inuse(isc_mem_t *mctx);
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
||||||
isc_mem_setwater(isc_mem_t *mctx, isc_mem_water_t water, void *water_arg,
|
isc_mem_setwater(isc_mem_t *mctx, isc_mem_water_t water, void *water_arg,
|
||||||
size_t hiwater, size_t lowater);
|
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
|
* will be called. When the usage drops below 'lowater', 'water' will
|
||||||
* again be called, this time with ISC_MEM_LOWATER.
|
* again be called, this time with ISC_MEM_LOWATER.
|
||||||
*
|
*
|
||||||
* Requires:
|
|
||||||
* If 'water' is NULL then 'water_arg', 'hi_water' and 'lo_water' are
|
* If 'water' is NULL then 'water_arg', 'hi_water' and 'lo_water' are
|
||||||
* ignored and the state is reset. Otherwise, requires
|
* ignored and the state is reset.
|
||||||
*
|
*
|
||||||
* 'water' to point to a valid function.
|
* Requires:
|
||||||
* 'hi_water > lo_water'
|
*
|
||||||
* 'lo_water != 0'
|
* 'water' is not NULL.
|
||||||
* 'hi_water != 0'
|
* hi_water >= lo_water
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* 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>
|
#include <config.h>
|
||||||
|
|
||||||
@@ -1001,8 +1001,17 @@ isc__mem_put(isc_mem_t *ctx, void *ptr, size_t size FLARG)
|
|||||||
#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
|
#endif /* ISC_MEM_USE_INTERNAL_MALLOC */
|
||||||
|
|
||||||
DELETE_TRACE(ctx, ptr, size, file, line);
|
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;
|
ctx->hi_called = ISC_FALSE;
|
||||||
|
|
||||||
|
if (ctx->water != NULL)
|
||||||
call_water = ISC_TRUE;
|
call_water = ISC_TRUE;
|
||||||
}
|
}
|
||||||
UNLOCK(&ctx->lock);
|
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)
|
size_t hiwater, size_t lowater)
|
||||||
{
|
{
|
||||||
REQUIRE(VALID_CONTEXT(ctx));
|
REQUIRE(VALID_CONTEXT(ctx));
|
||||||
|
REQUIRE(hiwater >= lowater);
|
||||||
if (water != NULL) {
|
|
||||||
REQUIRE(hiwater > lowater);
|
|
||||||
REQUIRE(hiwater > 0);
|
|
||||||
REQUIRE(lowater > 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
LOCK(&ctx->lock);
|
LOCK(&ctx->lock);
|
||||||
if (water == NULL) {
|
if (water == NULL) {
|
||||||
|
Reference in New Issue
Block a user