mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-22 01:59:26 +00:00
Change the 'isc_g_mctx' to be always available
This required couple of internal changes to the isc_mem_debugging. The isc_mem_debugging is now internal to isc_mem unit and there are three new functions: 1. isc_mem_setdebugging() can change the debugging setting for an individual memory context. This is need for the memory contexts used for OpenSSL, libxml and libuv accounting as recording and tracing memory is broken there. 2. isc_mem_debugon() / isc_mem_debugoff() can be used to change default memory debugging flags as well as debugging flags for isc_g_mctx. Additionally, the memory debugging is inconsistent across the code-base. For now, we are keeping the existing flags, but three new environment variables have been added 'ISC_MEM_DEBUGRECORD', 'ISC_MEM_DEBUGTRACE' and 'ISC_MEM_DEBUGUSAGE' to set the global debugging flags at any program using the memory contexts.
This commit is contained in:
parent
74726b3313
commit
f7e5c1db38
@ -106,10 +106,6 @@ add(char *key, int value) {
|
||||
isc_result_t result;
|
||||
isc_symvalue_t symvalue;
|
||||
|
||||
if (isc_g_mctx == NULL) {
|
||||
isc_mem_create("check-tool", &isc_g_mctx);
|
||||
}
|
||||
|
||||
if (symtab == NULL) {
|
||||
isc_symtab_create(isc_g_mctx, freekey, isc_g_mctx, false,
|
||||
&symtab);
|
||||
|
@ -599,15 +599,15 @@ main(int argc, char **argv) {
|
||||
case 'm':
|
||||
if (strcasecmp(isc_commandline_argument, "record") == 0)
|
||||
{
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
|
||||
isc_mem_debugon(ISC_MEM_DEBUGRECORD);
|
||||
}
|
||||
if (strcasecmp(isc_commandline_argument, "trace") == 0)
|
||||
{
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGTRACE;
|
||||
isc_mem_debugon(ISC_MEM_DEBUGTRACE);
|
||||
}
|
||||
if (strcasecmp(isc_commandline_argument, "usage") == 0)
|
||||
{
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGUSAGE;
|
||||
isc_mem_debugon(ISC_MEM_DEBUGUSAGE);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -616,8 +616,6 @@ main(int argc, char **argv) {
|
||||
}
|
||||
isc_commandline_reset = true;
|
||||
|
||||
isc_mem_create("default", &isc_g_mctx);
|
||||
|
||||
while ((c = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != EOF) {
|
||||
switch (c) {
|
||||
case 'a':
|
||||
@ -688,7 +686,6 @@ main(int argc, char **argv) {
|
||||
}
|
||||
FALLTHROUGH;
|
||||
case 'h':
|
||||
isc_mem_detach(&isc_g_mctx);
|
||||
usage();
|
||||
|
||||
default:
|
||||
@ -711,7 +708,6 @@ main(int argc, char **argv) {
|
||||
}
|
||||
|
||||
if (isc_commandline_index + 1 < argc) {
|
||||
isc_mem_detach(&isc_g_mctx);
|
||||
usage();
|
||||
}
|
||||
if (argv[isc_commandline_index] != NULL) {
|
||||
@ -752,9 +748,5 @@ cleanup:
|
||||
cfg_parser_destroy(&parser);
|
||||
}
|
||||
|
||||
if (isc_g_mctx != NULL) {
|
||||
isc_mem_detach(&isc_g_mctx);
|
||||
}
|
||||
|
||||
return result == ISC_R_SUCCESS ? 0 : 1;
|
||||
}
|
||||
|
@ -109,11 +109,6 @@ main(int argc, char **argv) {
|
||||
FILE *errout = stdout;
|
||||
char *endp;
|
||||
|
||||
/*
|
||||
* Uncomment the following line if memory debugging is needed:
|
||||
* isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
|
||||
*/
|
||||
|
||||
outputstyle = &dns_master_style_full;
|
||||
|
||||
isc_commandline_init(argc, argv);
|
||||
@ -518,7 +513,6 @@ main(int argc, char **argv) {
|
||||
usage();
|
||||
}
|
||||
|
||||
isc_mem_create("default", &isc_g_mctx);
|
||||
if (!quiet) {
|
||||
RUNTIME_CHECK(setup_logging(errout) == ISC_R_SUCCESS);
|
||||
}
|
||||
@ -560,7 +554,6 @@ main(int argc, char **argv) {
|
||||
fprintf(errout, "OK\n");
|
||||
}
|
||||
destroy();
|
||||
isc_mem_detach(&isc_g_mctx);
|
||||
|
||||
return (result == ISC_R_SUCCESS) ? 0 : 1;
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ main(int argc, char **argv) {
|
||||
keyname = isc_commandline_argument;
|
||||
break;
|
||||
case 'M':
|
||||
isc_mem_debugging = ISC_MEM_DEBUGTRACE;
|
||||
isc_mem_debugon(ISC_MEM_DEBUGTRACE);
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
@ -218,7 +218,6 @@ main(int argc, char **argv) {
|
||||
}
|
||||
algname = dst_hmac_algorithm_totext(alg);
|
||||
|
||||
isc_mem_create("default", &isc_g_mctx);
|
||||
isc_buffer_init(&key_txtbuffer, &key_txtsecret, sizeof(key_txtsecret));
|
||||
|
||||
generate_key(isc_g_mctx, alg, keysize, &key_txtbuffer);
|
||||
@ -282,7 +281,5 @@ options {\n\
|
||||
isc_mem_stats(isc_g_mctx, stderr);
|
||||
}
|
||||
|
||||
isc_mem_detach(&isc_g_mctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ main(int argc, char **argv) {
|
||||
}
|
||||
break;
|
||||
case 'M':
|
||||
isc_mem_debugging = ISC_MEM_DEBUGTRACE;
|
||||
isc_mem_debugon(ISC_MEM_DEBUGTRACE);
|
||||
break;
|
||||
case 'm':
|
||||
show_final_mem = true;
|
||||
@ -194,8 +194,6 @@ main(int argc, char **argv) {
|
||||
/* Use canonical algorithm name */
|
||||
algname = dst_hmac_algorithm_totext(alg);
|
||||
|
||||
isc_mem_create("default", &isc_g_mctx);
|
||||
|
||||
if (keyname == NULL) {
|
||||
const char *suffix = NULL;
|
||||
|
||||
@ -278,7 +276,5 @@ nsupdate -k <keyfile>\n");
|
||||
isc_mem_stats(isc_g_mctx, stderr);
|
||||
}
|
||||
|
||||
isc_mem_detach(&isc_g_mctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1599,8 +1599,8 @@ preparse_args(int argc, char **argv) {
|
||||
}
|
||||
break;
|
||||
case 'm':
|
||||
isc_mem_debugging = ISC_MEM_DEBUGTRACE |
|
||||
ISC_MEM_DEBUGRECORD;
|
||||
isc_mem_debugon(ISC_MEM_DEBUGTRACE |
|
||||
ISC_MEM_DEBUGRECORD);
|
||||
break;
|
||||
case '4':
|
||||
if (ipv6only) {
|
||||
|
@ -2960,8 +2960,8 @@ preparse_args(int argc, char **argv) {
|
||||
break;
|
||||
case 'm':
|
||||
memdebugging = true;
|
||||
isc_mem_debugging = ISC_MEM_DEBUGTRACE |
|
||||
ISC_MEM_DEBUGRECORD;
|
||||
isc_mem_debugon(ISC_MEM_DEBUGTRACE |
|
||||
ISC_MEM_DEBUGRECORD);
|
||||
break;
|
||||
case 'r':
|
||||
/*
|
||||
|
@ -577,15 +577,15 @@ pre_parse_args(int argc, char **argv) {
|
||||
memdebugging = true;
|
||||
if (strcasecmp("trace", isc_commandline_argument) == 0)
|
||||
{
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGTRACE;
|
||||
isc_mem_debugon(ISC_MEM_DEBUGTRACE);
|
||||
} else if (strcasecmp("record",
|
||||
isc_commandline_argument) == 0)
|
||||
{
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
|
||||
isc_mem_debugon(ISC_MEM_DEBUGRECORD);
|
||||
} else if (strcasecmp("usage",
|
||||
isc_commandline_argument) == 0)
|
||||
{
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGUSAGE;
|
||||
isc_mem_debugon(ISC_MEM_DEBUGUSAGE);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1052,12 +1052,9 @@ cleanup(void) {
|
||||
free_keytable(&new_key_tbl);
|
||||
}
|
||||
free_all_sets();
|
||||
if (isc_g_mctx != NULL) {
|
||||
if (print_mem_stats && verbose > 10) {
|
||||
isc_mem_stats(isc_g_mctx, stdout);
|
||||
}
|
||||
isc_mem_detach(&isc_g_mctx);
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
@ -1075,8 +1072,6 @@ main(int argc, char *argv[]) {
|
||||
|
||||
isc_commandline_init(argc, argv);
|
||||
|
||||
isc_mem_create("default", &isc_g_mctx);
|
||||
|
||||
isc_commandline_errprint = false;
|
||||
|
||||
#define OPTIONS "a:c:Dd:f:i:ms:T:uv:V"
|
||||
@ -1112,8 +1107,8 @@ main(int argc, char *argv[]) {
|
||||
}
|
||||
break;
|
||||
case 'm':
|
||||
isc_mem_debugging = ISC_MEM_DEBUGTRACE |
|
||||
ISC_MEM_DEBUGRECORD;
|
||||
isc_mem_debugon(ISC_MEM_DEBUGTRACE |
|
||||
ISC_MEM_DEBUGRECORD);
|
||||
break;
|
||||
case 's':
|
||||
startstr = isc_commandline_argument;
|
||||
|
@ -383,8 +383,6 @@ main(int argc, char **argv) {
|
||||
|
||||
isc_commandline_init(argc, argv);
|
||||
|
||||
isc_mem_create("default", &isc_g_mctx);
|
||||
|
||||
isc_commandline_errprint = false;
|
||||
|
||||
#define OPTIONS "12Aa:Cc:d:Ff:K:sT:v:whV"
|
||||
@ -547,7 +545,6 @@ main(int argc, char **argv) {
|
||||
if (verbose > 10) {
|
||||
isc_mem_stats(isc_g_mctx, stdout);
|
||||
}
|
||||
isc_mem_detach(&isc_g_mctx);
|
||||
|
||||
fflush(stdout);
|
||||
if (ferror(stdout)) {
|
||||
|
@ -309,8 +309,6 @@ main(int argc, char **argv) {
|
||||
|
||||
isc_commandline_init(argc, argv);
|
||||
|
||||
isc_mem_create("default", &isc_g_mctx);
|
||||
|
||||
isc_commandline_errprint = false;
|
||||
|
||||
#define CMDLINE_FLAGS "D:f:hK:L:P:v:V"
|
||||
@ -454,7 +452,6 @@ main(int argc, char **argv) {
|
||||
if (verbose > 10) {
|
||||
isc_mem_stats(isc_g_mctx, stdout);
|
||||
}
|
||||
isc_mem_detach(&isc_g_mctx);
|
||||
|
||||
fflush(stdout);
|
||||
if (ferror(stdout)) {
|
||||
|
@ -149,8 +149,6 @@ main(int argc, char **argv) {
|
||||
|
||||
isc_commandline_init(argc, argv);
|
||||
|
||||
isc_mem_create("default", &isc_g_mctx);
|
||||
|
||||
isc_commandline_errprint = false;
|
||||
|
||||
#define CMDLINE_FLAGS "3A:a:Cc:D:E:Ff:GhI:i:kK:L:l:M:n:P:p:R:S:t:v:Vy"
|
||||
@ -699,7 +697,6 @@ main(int argc, char **argv) {
|
||||
isc_mem_stats(isc_g_mctx, stdout);
|
||||
}
|
||||
isc_mem_free(isc_g_mctx, label);
|
||||
isc_mem_detach(&isc_g_mctx);
|
||||
|
||||
if (freeit != NULL) {
|
||||
free(freeit);
|
||||
|
@ -820,15 +820,15 @@ main(int argc, char **argv) {
|
||||
case 'm':
|
||||
if (strcasecmp(isc_commandline_argument, "record") == 0)
|
||||
{
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
|
||||
isc_mem_debugon(ISC_MEM_DEBUGRECORD);
|
||||
}
|
||||
if (strcasecmp(isc_commandline_argument, "trace") == 0)
|
||||
{
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGTRACE;
|
||||
isc_mem_debugon(ISC_MEM_DEBUGTRACE);
|
||||
}
|
||||
if (strcasecmp(isc_commandline_argument, "usage") == 0)
|
||||
{
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGUSAGE;
|
||||
isc_mem_debugon(ISC_MEM_DEBUGUSAGE);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -837,8 +837,6 @@ main(int argc, char **argv) {
|
||||
}
|
||||
isc_commandline_reset = true;
|
||||
|
||||
isc_mem_create("default", &isc_g_mctx);
|
||||
|
||||
while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) {
|
||||
switch (ch) {
|
||||
case '3':
|
||||
@ -1209,7 +1207,6 @@ main(int argc, char **argv) {
|
||||
if (verbose > 10) {
|
||||
isc_mem_stats(isc_g_mctx, stdout);
|
||||
}
|
||||
isc_mem_detach(&isc_g_mctx);
|
||||
|
||||
if (freeit != NULL) {
|
||||
free(freeit);
|
||||
|
@ -1330,8 +1330,6 @@ main(int argc, char *argv[]) {
|
||||
|
||||
isc_commandline_init(argc, argv);
|
||||
|
||||
isc_mem_create("default", &isc_g_mctx);
|
||||
|
||||
isc_commandline_errprint = false;
|
||||
|
||||
#define OPTIONS "E:e:Ff:hi:K:k:l:ov:V"
|
||||
|
@ -81,8 +81,6 @@ main(int argc, char **argv) {
|
||||
usage();
|
||||
}
|
||||
|
||||
isc_mem_create("default", &isc_g_mctx);
|
||||
|
||||
isc_commandline_errprint = false;
|
||||
|
||||
while ((ch = isc_commandline_parse(argc, argv, "E:fK:rRhv:V")) != -1) {
|
||||
@ -251,7 +249,6 @@ cleanup:
|
||||
if (dir != NULL) {
|
||||
isc_mem_free(isc_g_mctx, dir);
|
||||
}
|
||||
isc_mem_detach(&isc_g_mctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -243,8 +243,6 @@ main(int argc, char **argv) {
|
||||
usage();
|
||||
}
|
||||
|
||||
isc_mem_create("default", &isc_g_mctx);
|
||||
|
||||
setup_logging();
|
||||
|
||||
isc_commandline_errprint = false;
|
||||
@ -951,7 +949,6 @@ main(int argc, char **argv) {
|
||||
isc_mem_stats(isc_g_mctx, stdout);
|
||||
}
|
||||
isc_mem_free(isc_g_mctx, directory);
|
||||
isc_mem_detach(&isc_g_mctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -3297,15 +3297,15 @@ main(int argc, char *argv[]) {
|
||||
case 'm':
|
||||
if (strcasecmp(isc_commandline_argument, "record") == 0)
|
||||
{
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
|
||||
isc_mem_debugon(ISC_MEM_DEBUGRECORD);
|
||||
}
|
||||
if (strcasecmp(isc_commandline_argument, "trace") == 0)
|
||||
{
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGTRACE;
|
||||
isc_mem_debugon(ISC_MEM_DEBUGTRACE);
|
||||
}
|
||||
if (strcasecmp(isc_commandline_argument, "usage") == 0)
|
||||
{
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGUSAGE;
|
||||
isc_mem_debugon(ISC_MEM_DEBUGUSAGE);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -184,15 +184,15 @@ main(int argc, char *argv[]) {
|
||||
case 'm':
|
||||
if (strcasecmp(isc_commandline_argument, "record") == 0)
|
||||
{
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
|
||||
isc_mem_debugon(ISC_MEM_DEBUGRECORD);
|
||||
}
|
||||
if (strcasecmp(isc_commandline_argument, "trace") == 0)
|
||||
{
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGTRACE;
|
||||
isc_mem_debugon(ISC_MEM_DEBUGTRACE);
|
||||
}
|
||||
if (strcasecmp(isc_commandline_argument, "usage") == 0)
|
||||
{
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGUSAGE;
|
||||
isc_mem_debugon(ISC_MEM_DEBUGUSAGE);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -201,8 +201,6 @@ main(int argc, char *argv[]) {
|
||||
}
|
||||
isc_commandline_reset = true;
|
||||
|
||||
isc_mem_create("default", &isc_g_mctx);
|
||||
|
||||
isc_commandline_errprint = false;
|
||||
|
||||
while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) {
|
||||
@ -332,7 +330,6 @@ main(int argc, char *argv[]) {
|
||||
if (verbose > 10) {
|
||||
isc_mem_stats(isc_g_mctx, stdout);
|
||||
}
|
||||
isc_mem_detach(&isc_g_mctx);
|
||||
|
||||
return result == ISC_R_SUCCESS ? 0 : 1;
|
||||
}
|
||||
|
@ -361,6 +361,8 @@ parse_int(char *arg, const char *desc) {
|
||||
return tmp;
|
||||
}
|
||||
|
||||
static unsigned int mem_debugging = 0;
|
||||
|
||||
static struct flag_def {
|
||||
const char *name;
|
||||
unsigned int value;
|
||||
@ -860,7 +862,8 @@ parse_command_line(int argc, char *argv[]) {
|
||||
break;
|
||||
case 'm':
|
||||
set_flags(isc_commandline_argument, mem_debug_flags,
|
||||
&isc_mem_debugging);
|
||||
&mem_debugging);
|
||||
isc_mem_debugon(mem_debugging);
|
||||
break;
|
||||
case 'N': /* Deprecated. */
|
||||
case 'n':
|
||||
|
@ -8918,7 +8918,7 @@ apply_configuration(cfg_parser_t *configparser, cfg_obj_t *config,
|
||||
named_g_memstatistics = cfg_obj_asboolean(obj);
|
||||
} else {
|
||||
named_g_memstatistics =
|
||||
((isc_mem_debugging & ISC_MEM_DEBUGRECORD) != 0);
|
||||
((isc_mem_debugon(0) & ISC_MEM_DEBUGRECORD) != 0);
|
||||
}
|
||||
|
||||
obj = NULL;
|
||||
|
@ -1002,8 +1002,8 @@ pre_parse_args(int argc, char **argv) {
|
||||
debugging = true;
|
||||
ddebugging = true;
|
||||
memdebugging = true;
|
||||
isc_mem_debugging = ISC_MEM_DEBUGTRACE |
|
||||
ISC_MEM_DEBUGRECORD;
|
||||
isc_mem_debugon(ISC_MEM_DEBUGTRACE |
|
||||
ISC_MEM_DEBUGRECORD);
|
||||
break;
|
||||
|
||||
case '4':
|
||||
|
@ -869,7 +869,7 @@ main(int argc, char **argv) {
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
isc_mem_debugging = ISC_MEM_DEBUGTRACE;
|
||||
isc_mem_debugon(ISC_MEM_DEBUGTRACE);
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
|
@ -104,8 +104,6 @@ main(int argc, char **argv) {
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
isc_mem_create(argv[0], &isc_g_mctx);
|
||||
|
||||
logconfig = isc_logconfig_get();
|
||||
isc_log_settag(logconfig, "bigkey");
|
||||
|
||||
@ -137,7 +135,6 @@ main(int argc, char **argv) {
|
||||
printf("%s\n", filename);
|
||||
dst_key_free(&key);
|
||||
|
||||
isc_mem_detach(&isc_g_mctx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -120,15 +120,15 @@ main(int argc, char *argv[]) {
|
||||
case 'm':
|
||||
if (strcasecmp(isc_commandline_argument, "record") == 0)
|
||||
{
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
|
||||
isc_mem_debugon(ISC_MEM_DEBUGRECORD);
|
||||
}
|
||||
if (strcasecmp(isc_commandline_argument, "trace") == 0)
|
||||
{
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGTRACE;
|
||||
isc_mem_debugon(ISC_MEM_DEBUGTRACE);
|
||||
}
|
||||
if (strcasecmp(isc_commandline_argument, "usage") == 0)
|
||||
{
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGUSAGE;
|
||||
isc_mem_debugon(ISC_MEM_DEBUGUSAGE);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -137,8 +137,6 @@ main(int argc, char *argv[]) {
|
||||
}
|
||||
isc_commandline_reset = true;
|
||||
|
||||
isc_mem_create(argv[0], &isc_g_mctx);
|
||||
|
||||
while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) {
|
||||
switch (ch) {
|
||||
case 'b':
|
||||
@ -258,7 +256,6 @@ main(int argc, char *argv[]) {
|
||||
if (printmemstats) {
|
||||
isc_mem_stats(isc_g_mctx, stdout);
|
||||
}
|
||||
isc_mem_detach(&isc_g_mctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -55,7 +55,6 @@
|
||||
|
||||
#include "dnstap.pb-c.h"
|
||||
|
||||
bool memrecord = false;
|
||||
bool printmessage = false;
|
||||
bool hexmessage = false;
|
||||
bool yaml = false;
|
||||
@ -347,8 +346,7 @@ main(int argc, char *argv[]) {
|
||||
while ((ch = isc_commandline_parse(argc, argv, "mptxy")) != -1) {
|
||||
switch (ch) {
|
||||
case 'm':
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
|
||||
memrecord = true;
|
||||
isc_mem_debugon(ISC_MEM_DEBUGRECORD);
|
||||
break;
|
||||
case 'p':
|
||||
printmessage = true;
|
||||
@ -375,8 +373,6 @@ main(int argc, char *argv[]) {
|
||||
fatal("no file specified");
|
||||
}
|
||||
|
||||
isc_mem_create("default", &isc_g_mctx);
|
||||
|
||||
CHECKM(dns_dt_open(argv[0], dns_dtmode_file, isc_g_mctx, &handle),
|
||||
"dns_dt_openfile");
|
||||
|
||||
@ -425,7 +421,6 @@ cleanup:
|
||||
if (message != NULL) {
|
||||
dns_message_detach(&message);
|
||||
}
|
||||
isc_mem_detach(&isc_g_mctx);
|
||||
|
||||
exit(rv);
|
||||
}
|
||||
|
@ -1818,8 +1818,8 @@ preparse_args(int argc, char **argv) {
|
||||
while (strpbrk(option, single_dash_opts) == &option[0]) {
|
||||
switch (option[0]) {
|
||||
case 'm':
|
||||
isc_mem_debugging = ISC_MEM_DEBUGTRACE |
|
||||
ISC_MEM_DEBUGRECORD;
|
||||
isc_mem_debugon(ISC_MEM_DEBUGTRACE |
|
||||
ISC_MEM_DEBUGRECORD);
|
||||
break;
|
||||
case '4':
|
||||
if (ipv6only) {
|
||||
|
@ -91,7 +91,6 @@ main(int argc, char **argv) {
|
||||
}
|
||||
file = argv[0];
|
||||
|
||||
isc_mem_create("default", &isc_g_mctx);
|
||||
setup_logging(stderr);
|
||||
|
||||
if (upgrade) {
|
||||
@ -110,6 +109,6 @@ main(int argc, char **argv) {
|
||||
fprintf(stderr, "%s\n", isc_result_totext(result));
|
||||
}
|
||||
}
|
||||
isc_mem_detach(&isc_g_mctx);
|
||||
|
||||
return result != ISC_R_SUCCESS ? 1 : 0;
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ main(int argc, char **argv) {
|
||||
usage(0);
|
||||
break;
|
||||
case 'm':
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
|
||||
isc_mem_debugon(ISC_MEM_DEBUGRECORD);
|
||||
break;
|
||||
default:
|
||||
usage(1);
|
||||
@ -151,8 +151,6 @@ main(int argc, char **argv) {
|
||||
journal = (const char *)jbuf;
|
||||
}
|
||||
|
||||
isc_mem_create("default", &isc_g_mctx);
|
||||
|
||||
logconfig = isc_logconfig_get();
|
||||
isc_log_createandusechannel(
|
||||
logconfig, "default_stderr", ISC_LOG_TOFILEDESC,
|
||||
@ -218,9 +216,5 @@ cleanup:
|
||||
dns_db_detach(&olddb);
|
||||
}
|
||||
|
||||
if (isc_g_mctx != NULL) {
|
||||
isc_mem_detach(&isc_g_mctx);
|
||||
}
|
||||
|
||||
return (result != ISC_R_SUCCESS) ? 1 : 0;
|
||||
}
|
||||
|
@ -59,9 +59,6 @@ cleanup(void) {
|
||||
isc_lex_close(lex);
|
||||
isc_lex_destroy(&lex);
|
||||
}
|
||||
if (isc_g_mctx != NULL) {
|
||||
isc_mem_detach(&isc_g_mctx);
|
||||
}
|
||||
}
|
||||
|
||||
ISC_NORETURN static void
|
||||
@ -169,7 +166,6 @@ main(int argc, char *argv[]) {
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
isc_mem_create("default", &isc_g_mctx);
|
||||
isc_lex_create(isc_g_mctx, 256, &lex);
|
||||
|
||||
/*
|
||||
|
@ -253,6 +253,7 @@ isc__crypto_initialize(void) {
|
||||
uint64_t opts = OPENSSL_INIT_LOAD_CONFIG;
|
||||
|
||||
isc_mem_create("OpenSSL", &isc__crypto_mctx);
|
||||
isc_mem_setdebugging(isc__crypto_mctx, 0);
|
||||
isc_mem_setdestroycheck(isc__crypto_mctx, false);
|
||||
|
||||
#if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x30000000L
|
||||
|
@ -35,7 +35,6 @@
|
||||
#define ISC_MEM_TRACKLINES 0
|
||||
#endif /* ifndef ISC_MEM_TRACKLINES */
|
||||
|
||||
extern unsigned int isc_mem_debugging;
|
||||
extern unsigned int isc_mem_defaultflags;
|
||||
|
||||
/*@{*/
|
||||
@ -45,14 +44,10 @@ extern unsigned int isc_mem_defaultflags;
|
||||
#define ISC_MEM_DEBUGALL \
|
||||
(ISC_MEM_DEBUGTRACE | ISC_MEM_DEBUGRECORD | ISC_MEM_DEBUGUSAGE)
|
||||
/*!<
|
||||
* The variable isc_mem_debugging holds a set of flags for
|
||||
* turning certain memory debugging options on or off at
|
||||
* runtime. It is initialized to the value ISC_MEM_DEGBUGGING,
|
||||
* which is 0 by default but may be overridden at compile time.
|
||||
* The following flags can be specified:
|
||||
* The following memory debugging options can be specified:
|
||||
*
|
||||
* \li #ISC_MEM_DEBUGTRACE
|
||||
* Log each allocation and free to isc_lctx.
|
||||
* Log each allocation and free.
|
||||
*
|
||||
* \li #ISC_MEM_DEBUGRECORD
|
||||
* Remember each allocation, and match them up on free.
|
||||
@ -61,6 +56,15 @@ extern unsigned int isc_mem_defaultflags;
|
||||
* \li #ISC_MEM_DEBUGUSAGE
|
||||
* Every time the memory usage is greater (lower) than hi_water
|
||||
* (lo_water) mark, print the current inuse memory.
|
||||
*
|
||||
* These flags are set in the static variable mem_debugging.
|
||||
* When a new memory context is created, its debugging flags
|
||||
* are set to the current value of mem_debugging.
|
||||
*
|
||||
* By default, no flags are set. This can be overridden by changing
|
||||
* ISC_MEM_DEBUGGING in mem.c. The flags can be activated at runtime by
|
||||
* setting environment variables (for example, "ISC_MEM_DEBUGRECORD=1")
|
||||
* or by calling isc_mem_debugon() (see below).
|
||||
*/
|
||||
/*@}*/
|
||||
|
||||
@ -217,7 +221,6 @@ extern volatile void *isc__mem_malloc;
|
||||
#endif
|
||||
void
|
||||
isc__mem_create(const char *name, isc_mem_t **_ISC_MEM_FLARG);
|
||||
|
||||
/*!<
|
||||
* \brief Create a memory context.
|
||||
*
|
||||
@ -225,6 +228,33 @@ isc__mem_create(const char *name, isc_mem_t **_ISC_MEM_FLARG);
|
||||
* mctxp != NULL && *mctxp == NULL */
|
||||
/*@}*/
|
||||
|
||||
unsigned int
|
||||
isc_mem_debugon(unsigned int debugging);
|
||||
unsigned int
|
||||
isc_mem_debugoff(unsigned int debugging);
|
||||
/*!<
|
||||
* Set or clear debugging the flags for the main memory context
|
||||
* (isc_g_mctx), and the default debugging flags for all memory
|
||||
* contexts yet to be created (mem_debugging).
|
||||
*
|
||||
* Note: These are bitwise operations. To clear the existing flags
|
||||
* before setting new ones, use isc_mem_debugoff(ISC_MEM_DEBUGALL).
|
||||
*
|
||||
* Returns:
|
||||
* \li the previous value of the debugging flags
|
||||
*/
|
||||
|
||||
void
|
||||
isc_mem_setdebugging(isc_mem_t *ctx, unsigned int debugging);
|
||||
/*!<
|
||||
* Set the debugging flags for a single memory context.
|
||||
*
|
||||
* Note: This is an assignemnt, not a bitwise operation.
|
||||
*
|
||||
* Requires:
|
||||
* \li 'ctx' valid memory context without active allocation.
|
||||
*/
|
||||
|
||||
#if ISC_MEM_TRACE
|
||||
#define isc_mem_ref(ptr) isc_mem__ref(ptr, __func__, __FILE__, __LINE__)
|
||||
#define isc_mem_unref(ptr) isc_mem__unref(ptr, __func__, __FILE__, __LINE__)
|
||||
|
@ -1552,6 +1552,7 @@ isc__log_initialize(void) {
|
||||
isc_mem_t *mctx = NULL;
|
||||
|
||||
isc_mem_create("log", &mctx);
|
||||
isc_mem_setdebugging(mctx, 0);
|
||||
|
||||
isc__lctx = isc_mem_get(mctx, sizeof(*isc__lctx));
|
||||
*isc__lctx = (isc_log_t){
|
||||
|
@ -19,7 +19,6 @@
|
||||
|
||||
void
|
||||
isc_managers_create(uint32_t workers) {
|
||||
isc_mem_create("default", &isc_g_mctx);
|
||||
isc_loopmgr_create(isc_g_mctx, workers);
|
||||
isc_netmgr_create(isc_g_mctx);
|
||||
isc_rwlock_setworkers(workers);
|
||||
@ -32,5 +31,4 @@ isc_managers_destroy(void) {
|
||||
*/
|
||||
isc_netmgr_destroy();
|
||||
isc_loopmgr_destroy();
|
||||
isc_mem_detach(&isc_g_mctx);
|
||||
}
|
||||
|
@ -35,6 +35,7 @@
|
||||
#include <isc/types.h>
|
||||
#include <isc/urcu.h>
|
||||
#include <isc/util.h>
|
||||
#include <isc/uv.h>
|
||||
|
||||
#ifdef HAVE_LIBXML2
|
||||
#include <libxml/xmlwriter.h>
|
||||
@ -64,7 +65,8 @@
|
||||
#ifndef ISC_MEM_DEBUGGING
|
||||
#define ISC_MEM_DEBUGGING 0
|
||||
#endif /* ifndef ISC_MEM_DEBUGGING */
|
||||
unsigned int isc_mem_debugging = ISC_MEM_DEBUGGING;
|
||||
|
||||
static unsigned int mem_debugging = ISC_MEM_DEBUGGING;
|
||||
unsigned int isc_mem_defaultflags = ISC_MEMFLAG_DEFAULT;
|
||||
|
||||
volatile void *isc__mem_malloc = mallocx;
|
||||
@ -384,6 +386,23 @@ mem_putstats(isc_mem_t *ctx, size_t size) {
|
||||
* Private.
|
||||
*/
|
||||
|
||||
static bool
|
||||
debugging_enabled(const char *name) {
|
||||
char env_buf[256];
|
||||
size_t env_size = sizeof(env_buf);
|
||||
|
||||
int r = uv_os_getenv(name, env_buf, &env_size);
|
||||
switch (r) {
|
||||
case 0:
|
||||
return true;
|
||||
case UV_ENOENT:
|
||||
return false;
|
||||
default:
|
||||
UV_RUNTIME_CHECK(uv_os_getenv, r);
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
isc__mem_initialize(void) {
|
||||
/*
|
||||
@ -395,6 +414,20 @@ isc__mem_initialize(void) {
|
||||
|
||||
isc_mutex_init(&contextslock);
|
||||
ISC_LIST_INIT(contexts);
|
||||
|
||||
if (debugging_enabled("ISC_MEM_DEBUGTRACE")) {
|
||||
mem_debugging |= ISC_MEM_DEBUGTRACE;
|
||||
}
|
||||
|
||||
if (debugging_enabled("ISC_MEM_DEBUGRECORD")) {
|
||||
mem_debugging |= ISC_MEM_DEBUGRECORD;
|
||||
}
|
||||
|
||||
if (debugging_enabled("ISC_MEM_DEBUGUSAGE")) {
|
||||
mem_debugging |= ISC_MEM_DEBUGUSAGE;
|
||||
}
|
||||
|
||||
isc_mem_create("default", &isc_g_mctx);
|
||||
}
|
||||
|
||||
void
|
||||
@ -403,6 +436,8 @@ isc__mem_shutdown(void) {
|
||||
|
||||
rcu_barrier();
|
||||
|
||||
isc_mem_detach(&isc_g_mctx);
|
||||
|
||||
isc__mem_checkdestroyed();
|
||||
|
||||
LOCK(&contextslock);
|
||||
@ -414,6 +449,40 @@ isc__mem_shutdown(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
isc_mem_setdebugging(isc_mem_t *ctx, unsigned int debugging) {
|
||||
REQUIRE(VALID_CONTEXT(ctx));
|
||||
REQUIRE(isc_mem_inuse(ctx) == 0);
|
||||
|
||||
ctx->debugging = debugging;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
isc_mem_debugon(unsigned int debugging) {
|
||||
unsigned int old_mem_debugging = mem_debugging;
|
||||
|
||||
if (debugging != 0) {
|
||||
mem_debugging |= debugging;
|
||||
|
||||
isc_mem_setdebugging(isc_g_mctx, mem_debugging);
|
||||
}
|
||||
|
||||
return old_mem_debugging;
|
||||
}
|
||||
|
||||
unsigned int
|
||||
isc_mem_debugoff(unsigned int debugging) {
|
||||
unsigned int old_mem_debugging = mem_debugging;
|
||||
|
||||
if (debugging != 0) {
|
||||
mem_debugging &= ~debugging;
|
||||
|
||||
isc_mem_setdebugging(isc_g_mctx, mem_debugging);
|
||||
}
|
||||
|
||||
return old_mem_debugging;
|
||||
}
|
||||
|
||||
static void
|
||||
mem_create(const char *name, isc_mem_t **ctxp, unsigned int debugging,
|
||||
unsigned int flags, unsigned int jemalloc_flags) {
|
||||
@ -845,7 +914,7 @@ isc_mem_isovermem(isc_mem_t *ctx) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ((isc_mem_debugging & ISC_MEM_DEBUGUSAGE) != 0) {
|
||||
if ((ctx->debugging & ISC_MEM_DEBUGUSAGE) != 0) {
|
||||
fprintf(stderr,
|
||||
"overmem %s mctx %p inuse %zu hi_water %zu\n",
|
||||
ctx->name, ctx, inuse, hiwater);
|
||||
@ -865,7 +934,7 @@ isc_mem_isovermem(isc_mem_t *ctx) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((isc_mem_debugging & ISC_MEM_DEBUGUSAGE) != 0) {
|
||||
if ((ctx->debugging & ISC_MEM_DEBUGUSAGE) != 0) {
|
||||
fprintf(stderr,
|
||||
"overmem %s mctx %p inuse %zu lo_water %zu\n",
|
||||
ctx->name, ctx, inuse, lowater);
|
||||
@ -1158,7 +1227,7 @@ isc__mem_checkdestroyed(void) {
|
||||
LOCK(&contextslock);
|
||||
if (!ISC_LIST_EMPTY(contexts)) {
|
||||
#if ISC_MEM_TRACKLINES
|
||||
if ((isc_mem_debugging & TRACE_OR_RECORD) != 0) {
|
||||
if ((mem_debugging & TRACE_OR_RECORD) != 0) {
|
||||
print_contexts(file);
|
||||
}
|
||||
#endif /* if ISC_MEM_TRACKLINES */
|
||||
@ -1378,9 +1447,9 @@ error:
|
||||
|
||||
void
|
||||
isc__mem_create(const char *name, isc_mem_t **mctxp FLARG) {
|
||||
mem_create(name, mctxp, isc_mem_debugging, isc_mem_defaultflags, 0);
|
||||
mem_create(name, mctxp, mem_debugging, isc_mem_defaultflags, 0);
|
||||
#if ISC_MEM_TRACKLINES
|
||||
if ((isc_mem_debugging & ISC_MEM_DEBUGTRACE) != 0) {
|
||||
if ((mem_debugging & ISC_MEM_DEBUGTRACE) != 0) {
|
||||
fprintf(stderr, "create mctx %p func %s file %s line %u\n",
|
||||
*mctxp, func, file, line);
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ static struct call_rcu_data *isc__thread_call_rcu_data = NULL;
|
||||
|
||||
/*
|
||||
* We can't use isc_mem API here, because it's called too early and the
|
||||
* isc_mem_debugging flags can be changed later causing mismatch between flags
|
||||
* memory debugging flags can be changed later causing mismatch between flags
|
||||
* used for isc_mem_get() and isc_mem_put().
|
||||
*/
|
||||
|
||||
|
@ -133,6 +133,7 @@ isc__uv_initialize(void) {
|
||||
#if UV_VERSION_HEX >= UV_VERSION(1, 38, 0)
|
||||
int r;
|
||||
isc_mem_create("uv", &isc__uv_mctx);
|
||||
isc_mem_setdebugging(isc__uv_mctx, 0);
|
||||
isc_mem_setdestroycheck(isc__uv_mctx, false);
|
||||
|
||||
r = uv_replace_allocator(isc__uv_malloc, isc__uv_realloc,
|
||||
|
@ -53,6 +53,7 @@ isc__xml_initialize(void) {
|
||||
#ifdef HAVE_LIBXML2
|
||||
#ifndef LIBXML_HAS_DEPRECATED_MEMORY_ALLOCATION_FUNCTIONS
|
||||
isc_mem_create("libxml2", &isc__xml_mctx);
|
||||
isc_mem_setdebugging(isc__xml_mctx, 0);
|
||||
isc_mem_setdestroycheck(isc__xml_mctx, false);
|
||||
|
||||
RUNTIME_CHECK(xmlMemSetup(isc__xml_free, isc__xml_malloc,
|
||||
|
@ -42,9 +42,6 @@ main(void) {
|
||||
isc_result_t result;
|
||||
isc_buffer_t buf;
|
||||
|
||||
isc_mem_t *mctx = NULL;
|
||||
isc_mem_create("test", &mctx);
|
||||
|
||||
static dns_fixedname_t fixedname[65536];
|
||||
unsigned int count = 0;
|
||||
|
||||
@ -76,14 +73,14 @@ main(void) {
|
||||
dns_compress_t cctx;
|
||||
|
||||
isc_buffer_init(&buf, wire, sizeof(wire));
|
||||
dns_compress_init(&cctx, mctx, 0);
|
||||
dns_compress_init(&cctx, isc_g_mctx, 0);
|
||||
|
||||
for (unsigned int i = 0; i < count; i++) {
|
||||
dns_name_t *name = dns_fixedname_name(&fixedname[i]);
|
||||
result = dns_name_towire(name, &cctx, &buf);
|
||||
if (result == ISC_R_NOSPACE) {
|
||||
dns_compress_invalidate(&cctx);
|
||||
dns_compress_init(&cctx, mctx, 0);
|
||||
dns_compress_init(&cctx, isc_g_mctx, 0);
|
||||
isc_buffer_init(&buf, wire, sizeof(wire));
|
||||
} else {
|
||||
CHECKRESULT(result, "dns_name_towire");
|
||||
@ -100,7 +97,5 @@ main(void) {
|
||||
|
||||
printf("names %u\n", count);
|
||||
|
||||
isc_mem_detach(&mctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -422,8 +422,6 @@ main(int argc, char *argv[]) {
|
||||
|
||||
isc_rwlock_init(&rwl);
|
||||
|
||||
isc_mem_create("test", &isc_g_mctx);
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr,
|
||||
"usage: load-names <filename.csv> <nthreads>\n");
|
||||
@ -493,18 +491,16 @@ main(int argc, char *argv[]) {
|
||||
"---------- | ---------- | ---------- |\n");
|
||||
|
||||
for (struct fun *fun = fun_list; fun->name != NULL; fun++) {
|
||||
isc_mem_t *mem = NULL;
|
||||
void *map = NULL;
|
||||
|
||||
isc_mem_create("test", &mem);
|
||||
map = fun->new(mem);
|
||||
map = fun->new(isc_g_mctx);
|
||||
|
||||
size_t nitems = lines / (nthreads + 1);
|
||||
|
||||
isc_barrier_init(&barrier, nthreads);
|
||||
|
||||
isc_time_t t0 = isc_time_now_hires();
|
||||
size_t m0 = isc_mem_inuse(mem);
|
||||
size_t m0 = isc_mem_inuse(isc_g_mctx);
|
||||
|
||||
for (size_t i = 0; i < nthreads; i++) {
|
||||
threads[i] = (struct thread_s){
|
||||
@ -526,13 +522,13 @@ main(int argc, char *argv[]) {
|
||||
d1 += threads[i].d1;
|
||||
}
|
||||
|
||||
size_t m1 = isc_mem_inuse(mem);
|
||||
size_t m1 = isc_mem_inuse(isc_g_mctx);
|
||||
|
||||
rcu_barrier();
|
||||
|
||||
isc_time_t t1 = isc_time_now_hires();
|
||||
uint64_t d3 = isc_time_microdiff(&t1, &t0);
|
||||
size_t m2 = isc_mem_inuse(mem);
|
||||
size_t m2 = isc_mem_inuse(isc_g_mctx);
|
||||
|
||||
printf("%10s | %10zu | %10.4f | %10.4f | %10.4f | "
|
||||
"%10.4f | %10.4f |\n",
|
||||
|
@ -162,8 +162,6 @@ main(int argc, char *argv[]) {
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
isc_mem_create("test", &isc_g_mctx);
|
||||
|
||||
filename = argv[0];
|
||||
result = isc_file_getsize(filename, &fileoff);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
|
@ -197,8 +197,6 @@ main(int argc, char **argv) {
|
||||
usage();
|
||||
}
|
||||
|
||||
isc_mem_create("test", &isc_g_mctx);
|
||||
|
||||
dns_qp_create(isc_g_mctx, &methods, NULL, &qp);
|
||||
|
||||
start = isc_time_monotonic();
|
||||
|
@ -854,8 +854,6 @@ setup_tickers(isc_mem_t *mctx) {
|
||||
|
||||
int
|
||||
main(void) {
|
||||
isc_mem_t *mctx = NULL;
|
||||
|
||||
setlinebuf(stdout);
|
||||
|
||||
uint32_t nloops;
|
||||
@ -868,20 +866,18 @@ main(void) {
|
||||
}
|
||||
INSIST(nloops > 1);
|
||||
|
||||
isc_mem_create("test", &mctx);
|
||||
isc_mem_setdestroycheck(mctx, true);
|
||||
isc_mem_setdestroycheck(isc_g_mctx, true);
|
||||
init_logging();
|
||||
init_items(mctx);
|
||||
init_items(isc_g_mctx);
|
||||
|
||||
isc_loopmgr_create(mctx, nloops);
|
||||
setup_tickers(mctx);
|
||||
isc_loopmgr_create(isc_g_mctx, nloops);
|
||||
setup_tickers(isc_g_mctx);
|
||||
isc_loop_setup(isc_loop_main(), startup, NULL);
|
||||
isc_loopmgr_run();
|
||||
isc_loopmgr_destroy();
|
||||
|
||||
isc_mem_free(mctx, item);
|
||||
isc_mem_free(isc_g_mctx, item);
|
||||
isc_mem_checkdestroyed(stdout);
|
||||
isc_mem_detach(&mctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -182,7 +182,6 @@ ISC_RUN_TEST_IMPL(isc_mem_inuse) {
|
||||
ssize_t diff;
|
||||
void *ptr;
|
||||
|
||||
mctx = NULL;
|
||||
isc_mem_create("test", &mctx);
|
||||
|
||||
before = isc_mem_inuse(mctx);
|
||||
@ -334,18 +333,19 @@ ISC_RUN_TEST_IMPL(isc_mem_noflags) {
|
||||
char buf[4096], *p;
|
||||
FILE *f;
|
||||
void *ptr;
|
||||
unsigned int debugging;
|
||||
|
||||
result = isc_stdio_open("mem.output", "w", &f);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
isc_mem_debugging = 0;
|
||||
debugging = isc_mem_debugoff(ISC_MEM_DEBUGALL);
|
||||
isc_mem_create("test", &mctx);
|
||||
ptr = isc_mem_get(mctx, 2048);
|
||||
assert_non_null(ptr);
|
||||
isc__mem_printactive(mctx, f);
|
||||
isc_mem_put(mctx, ptr, 2048);
|
||||
isc_mem_detach(&mctx);
|
||||
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
||||
isc_mem_debugon(debugging);
|
||||
isc_stdio_close(f);
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
@ -354,7 +354,7 @@ ISC_RUN_TEST_IMPL(isc_mem_noflags) {
|
||||
result = isc_stdio_read(buf, sizeof(buf), 1, f, NULL);
|
||||
assert_int_equal(result, ISC_R_EOF);
|
||||
isc_stdio_close(f);
|
||||
isc_file_remove("mem.output");
|
||||
// isc_file_remove("mem.output");
|
||||
|
||||
buf[sizeof(buf) - 1] = 0;
|
||||
|
||||
@ -433,19 +433,22 @@ ISC_RUN_TEST_IMPL(isc_mem_traceflag) {
|
||||
char buf[4096], *p;
|
||||
FILE *f;
|
||||
void *ptr;
|
||||
unsigned int debugging;
|
||||
|
||||
/* redirect stderr so we can check trace output */
|
||||
f = freopen("mem.output", "w", stderr);
|
||||
assert_non_null(f);
|
||||
|
||||
isc_mem_debugging = ISC_MEM_DEBUGRECORD | ISC_MEM_DEBUGTRACE;
|
||||
debugging = isc_mem_debugoff(ISC_MEM_DEBUGALL);
|
||||
isc_mem_debugon(ISC_MEM_DEBUGRECORD | ISC_MEM_DEBUGTRACE);
|
||||
isc_mem_create("test", &mctx);
|
||||
ptr = isc_mem_get(mctx, 2048);
|
||||
assert_non_null(ptr);
|
||||
isc__mem_printactive(mctx, f);
|
||||
isc_mem_put(mctx, ptr, 2048);
|
||||
isc_mem_detach(&mctx);
|
||||
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
||||
isc_mem_debugoff(ISC_MEM_DEBUGALL);
|
||||
isc_mem_debugon(debugging);
|
||||
isc_stdio_close(f);
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
@ -67,16 +67,13 @@ setup_workers(void **state ISC_ATTR_UNUSED) {
|
||||
|
||||
int
|
||||
setup_mctx(void **state ISC_ATTR_UNUSED) {
|
||||
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
|
||||
isc_mem_create("test", &isc_g_mctx);
|
||||
isc_mem_debugon(ISC_MEM_DEBUGRECORD);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
teardown_mctx(void **state ISC_ATTR_UNUSED) {
|
||||
isc_mem_detach(&isc_g_mctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user