mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-03 08:05:21 +00:00
Fix a possible race in updating stats counters (#38826)
and do some other isc mem cleanups.
This commit is contained in:
3
CHANGES
3
CHANGES
@@ -1,3 +1,6 @@
|
|||||||
|
4094. [bug] Fix a possible race in updating stats counters.
|
||||||
|
[RT #38826]
|
||||||
|
|
||||||
4083. [cleanup] Print the number of CPUs and UDP listeners
|
4083. [cleanup] Print the number of CPUs and UDP listeners
|
||||||
consistently in the log and in "rndc status"
|
consistently in the log and in "rndc status"
|
||||||
output; indicate whether threads are supported
|
output; indicate whether threads are supported
|
||||||
|
@@ -1262,13 +1262,10 @@ isc___mem_get(isc_mem_t *ctx0, size_t size FLARG) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ADD_TRACE(ctx, ptr, size, file, line);
|
ADD_TRACE(ctx, ptr, size, file, line);
|
||||||
if (ctx->hi_water != 0U && ctx->inuse > ctx->hi_water &&
|
if (ctx->hi_water != 0U && ctx->inuse > ctx->hi_water) {
|
||||||
!ctx->is_overmem) {
|
|
||||||
ctx->is_overmem = ISC_TRUE;
|
ctx->is_overmem = ISC_TRUE;
|
||||||
}
|
if (!ctx->hi_called)
|
||||||
if (ctx->hi_water != 0U && !ctx->hi_called &&
|
call_water = ISC_TRUE;
|
||||||
ctx->inuse > ctx->hi_water) {
|
|
||||||
call_water = ISC_TRUE;
|
|
||||||
}
|
}
|
||||||
if (ctx->inuse > ctx->maxinuse) {
|
if (ctx->inuse > ctx->maxinuse) {
|
||||||
ctx->maxinuse = ctx->inuse;
|
ctx->maxinuse = ctx->inuse;
|
||||||
@@ -1279,7 +1276,7 @@ isc___mem_get(isc_mem_t *ctx0, size_t size FLARG) {
|
|||||||
}
|
}
|
||||||
MCTXUNLOCK(ctx, &ctx->lock);
|
MCTXUNLOCK(ctx, &ctx->lock);
|
||||||
|
|
||||||
if (call_water)
|
if (call_water && (ctx->water != NULL))
|
||||||
(ctx->water)(ctx->water_arg, ISC_MEM_HIWATER);
|
(ctx->water)(ctx->water_arg, ISC_MEM_HIWATER);
|
||||||
|
|
||||||
return (ptr);
|
return (ptr);
|
||||||
@@ -1323,18 +1320,15 @@ isc___mem_put(isc_mem_t *ctx0, void *ptr, size_t size FLARG) {
|
|||||||
* when the context was pushed over hi_water but then had
|
* when the context was pushed over hi_water but then had
|
||||||
* isc_mem_setwater() called with 0 for hi_water and lo_water.
|
* isc_mem_setwater() called with 0 for hi_water and lo_water.
|
||||||
*/
|
*/
|
||||||
if (ctx->is_overmem &&
|
if ((ctx->inuse < ctx->lo_water) || (ctx->lo_water == 0U)) {
|
||||||
(ctx->inuse < ctx->lo_water || ctx->lo_water == 0U)) {
|
|
||||||
ctx->is_overmem = ISC_FALSE;
|
ctx->is_overmem = ISC_FALSE;
|
||||||
}
|
if (ctx->hi_called)
|
||||||
if (ctx->hi_called &&
|
|
||||||
(ctx->inuse < ctx->lo_water || ctx->lo_water == 0U)) {
|
|
||||||
if (ctx->water != NULL)
|
|
||||||
call_water = ISC_TRUE;
|
call_water = ISC_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
MCTXUNLOCK(ctx, &ctx->lock);
|
MCTXUNLOCK(ctx, &ctx->lock);
|
||||||
|
|
||||||
if (call_water)
|
if (call_water && (ctx->water != NULL))
|
||||||
(ctx->water)(ctx->water_arg, ISC_MEM_LOWATER);
|
(ctx->water)(ctx->water_arg, ISC_MEM_LOWATER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1387,8 +1381,8 @@ print_active(isc__mem_t *mctx, FILE *out) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!found)
|
if (!found)
|
||||||
fprintf(out, "%s", isc_msgcat_get(isc_msgcat, ISC_MSGSET_MEM,
|
fputs(isc_msgcat_get(isc_msgcat, ISC_MSGSET_MEM,
|
||||||
ISC_MSG_NONE, "\tNone.\n"));
|
ISC_MSG_NONE, "\tNone.\n"), out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -1510,15 +1504,10 @@ isc___mem_allocate(isc_mem_t *ctx0, size_t size FLARG) {
|
|||||||
|
|
||||||
REQUIRE(VALID_CONTEXT(ctx));
|
REQUIRE(VALID_CONTEXT(ctx));
|
||||||
|
|
||||||
if ((ctx->flags & ISC_MEMFLAG_INTERNAL) != 0) {
|
MCTXLOCK(ctx, &ctx->lock);
|
||||||
MCTXLOCK(ctx, &ctx->lock);
|
si = mem_allocateunlocked((isc_mem_t *)ctx, size);
|
||||||
si = mem_allocateunlocked((isc_mem_t *)ctx, size);
|
if (((ctx->flags & ISC_MEMFLAG_INTERNAL) == 0) && (si != NULL))
|
||||||
} else {
|
mem_getstats(ctx, si[-1].u.size);
|
||||||
si = mem_allocateunlocked((isc_mem_t *)ctx, size);
|
|
||||||
MCTXLOCK(ctx, &ctx->lock);
|
|
||||||
if (si != NULL)
|
|
||||||
mem_getstats(ctx, si[-1].u.size);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if ISC_MEM_TRACKLINES
|
#if ISC_MEM_TRACKLINES
|
||||||
ADD_TRACE(ctx, si, si[-1].u.size, file, line);
|
ADD_TRACE(ctx, si, si[-1].u.size, file, line);
|
||||||
@@ -1773,7 +1762,6 @@ isc__mem_setwater(isc_mem_t *ctx0, isc_mem_water_t water, void *water_arg,
|
|||||||
ctx->water_arg = NULL;
|
ctx->water_arg = NULL;
|
||||||
ctx->hi_water = 0;
|
ctx->hi_water = 0;
|
||||||
ctx->lo_water = 0;
|
ctx->lo_water = 0;
|
||||||
ctx->hi_called = ISC_FALSE;
|
|
||||||
} else {
|
} else {
|
||||||
if (ctx->hi_called &&
|
if (ctx->hi_called &&
|
||||||
(ctx->water != water || ctx->water_arg != water_arg ||
|
(ctx->water != water || ctx->water_arg != water_arg ||
|
||||||
@@ -2596,6 +2584,8 @@ json_renderctx(isc__mem_t *ctx, summarystat_t *summary, json_object *array) {
|
|||||||
CHECKMEM(obj);
|
CHECKMEM(obj);
|
||||||
json_object_object_add(ctxobj, "pools", obj);
|
json_object_object_add(ctxobj, "pools", obj);
|
||||||
|
|
||||||
|
summary->contextsize += ctx->poolcnt * sizeof(isc_mempool_t);
|
||||||
|
|
||||||
obj = json_object_new_int64(ctx->hi_water);
|
obj = json_object_new_int64(ctx->hi_water);
|
||||||
CHECKMEM(obj);
|
CHECKMEM(obj);
|
||||||
json_object_object_add(ctxobj, "hiwater", obj);
|
json_object_object_add(ctxobj, "hiwater", obj);
|
||||||
|
Reference in New Issue
Block a user