}
ADD_TRACE(ctx, ptr, size, file, line);
- if (ctx->hi_water != 0U && ctx->inuse > ctx->hi_water &&
- !ctx->is_overmem) {
+ if (ctx->hi_water != 0U && ctx->inuse > ctx->hi_water) {
ctx->is_overmem = ISC_TRUE;
- }
- if (ctx->hi_water != 0U && !ctx->hi_called &&
- ctx->inuse > ctx->hi_water) {
- call_water = ISC_TRUE;
+ if (!ctx->hi_called)
+ call_water = ISC_TRUE;
}
if (ctx->inuse > ctx->maxinuse) {
ctx->maxinuse = ctx->inuse;
}
MCTXUNLOCK(ctx, &ctx->lock);
- if (call_water)
+ if (call_water && (ctx->water != NULL))
(ctx->water)(ctx->water_arg, ISC_MEM_HIWATER);
return (ptr);
* 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->is_overmem &&
- (ctx->inuse < ctx->lo_water || ctx->lo_water == 0U)) {
+ if ((ctx->inuse < ctx->lo_water) || (ctx->lo_water == 0U)) {
ctx->is_overmem = ISC_FALSE;
- }
- if (ctx->hi_called &&
- (ctx->inuse < ctx->lo_water || ctx->lo_water == 0U)) {
- if (ctx->water != NULL)
+ if (ctx->hi_called)
call_water = ISC_TRUE;
}
+
MCTXUNLOCK(ctx, &ctx->lock);
- if (call_water)
+ if (call_water && (ctx->water != NULL))
(ctx->water)(ctx->water_arg, ISC_MEM_LOWATER);
}
}
}
if (!found)
- fprintf(out, "%s", isc_msgcat_get(isc_msgcat, ISC_MSGSET_MEM,
- ISC_MSG_NONE, "\tNone.\n"));
+ fputs(isc_msgcat_get(isc_msgcat, ISC_MSGSET_MEM,
+ ISC_MSG_NONE, "\tNone.\n"), out);
}
}
#endif
REQUIRE(VALID_CONTEXT(ctx));
- if ((ctx->flags & ISC_MEMFLAG_INTERNAL) != 0) {
- MCTXLOCK(ctx, &ctx->lock);
- si = mem_allocateunlocked((isc_mem_t *)ctx, size);
- } else {
- si = mem_allocateunlocked((isc_mem_t *)ctx, size);
- MCTXLOCK(ctx, &ctx->lock);
- if (si != NULL)
- mem_getstats(ctx, si[-1].u.size);
- }
+ MCTXLOCK(ctx, &ctx->lock);
+ si = mem_allocateunlocked((isc_mem_t *)ctx, size);
+ if (((ctx->flags & ISC_MEMFLAG_INTERNAL) == 0) && (si != NULL))
+ mem_getstats(ctx, si[-1].u.size);
#if ISC_MEM_TRACKLINES
ADD_TRACE(ctx, si, si[-1].u.size, file, line);
ctx->water_arg = NULL;
ctx->hi_water = 0;
ctx->lo_water = 0;
- ctx->hi_called = ISC_FALSE;
} else {
if (ctx->hi_called &&
(ctx->water != water || ctx->water_arg != water_arg ||
CHECKMEM(obj);
json_object_object_add(ctxobj, "pools", obj);
+ summary->contextsize += ctx->poolcnt * sizeof(isc_mempool_t);
+
obj = json_object_new_int64(ctx->hi_water);
CHECKMEM(obj);
json_object_object_add(ctxobj, "hiwater", obj);