mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-22 18:19:42 +00:00
chg: dev: Set name for all the isc_mem context from isc_mem_create()
Instead of giving the memory context names with an explicit call to isc_mem_setname(), add the name to isc_mem_create() call to have all the memory contexts an unconditional name. Merge branch 'ondrej/ondrej-isc_mem_create-with-name' into 'main' See merge request isc-projects/bind9!10426
This commit is contained in:
commit
ccf7a7dd7e
@ -108,7 +108,7 @@ add(char *key, int value) {
|
|||||||
isc_symvalue_t symvalue;
|
isc_symvalue_t symvalue;
|
||||||
|
|
||||||
if (sym_mctx == NULL) {
|
if (sym_mctx == NULL) {
|
||||||
isc_mem_create(&sym_mctx);
|
isc_mem_create("check-tool", &sym_mctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (symtab == NULL) {
|
if (symtab == NULL) {
|
||||||
|
@ -619,7 +619,7 @@ main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
isc_commandline_reset = true;
|
isc_commandline_reset = true;
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create(argv[0], &mctx);
|
||||||
|
|
||||||
while ((c = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != EOF) {
|
while ((c = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != EOF) {
|
||||||
switch (c) {
|
switch (c) {
|
||||||
|
@ -535,7 +535,7 @@ main(int argc, char **argv) {
|
|||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create(argv[0], &mctx);
|
||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
RUNTIME_CHECK(setup_logging(errout) == ISC_R_SUCCESS);
|
RUNTIME_CHECK(setup_logging(errout) == ISC_R_SUCCESS);
|
||||||
}
|
}
|
||||||
|
@ -108,6 +108,7 @@ main(int argc, char **argv) {
|
|||||||
bool keyonly = false;
|
bool keyonly = false;
|
||||||
bool quiet = false;
|
bool quiet = false;
|
||||||
int len;
|
int len;
|
||||||
|
const char *name = argv[0];
|
||||||
|
|
||||||
keydef = keyfile = RNDC_KEYFILE;
|
keydef = keyfile = RNDC_KEYFILE;
|
||||||
|
|
||||||
@ -226,7 +227,7 @@ main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
algname = dst_hmac_algorithm_totext(alg);
|
algname = dst_hmac_algorithm_totext(alg);
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create(name, &mctx);
|
||||||
isc_buffer_init(&key_txtbuffer, &key_txtsecret, sizeof(key_txtsecret));
|
isc_buffer_init(&key_txtbuffer, &key_txtsecret, sizeof(key_txtsecret));
|
||||||
|
|
||||||
generate_key(mctx, alg, keysize, &key_txtbuffer);
|
generate_key(mctx, alg, keysize, &key_txtbuffer);
|
||||||
|
@ -212,7 +212,7 @@ main(int argc, char **argv) {
|
|||||||
/* Use canonical algorithm name */
|
/* Use canonical algorithm name */
|
||||||
algname = dst_hmac_algorithm_totext(alg);
|
algname = dst_hmac_algorithm_totext(alg);
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create(argv[0], &mctx);
|
||||||
|
|
||||||
if (keyname == NULL) {
|
if (keyname == NULL) {
|
||||||
const char *suffix = NULL;
|
const char *suffix = NULL;
|
||||||
|
@ -1352,7 +1352,6 @@ setup_libs(void) {
|
|||||||
ISC_LOGMODULE_DEFAULT);
|
ISC_LOGMODULE_DEFAULT);
|
||||||
isc_log_setdebuglevel(0);
|
isc_log_setdebuglevel(0);
|
||||||
|
|
||||||
isc_mem_setname(mctx, "dig");
|
|
||||||
mainloop = isc_loop_main(loopmgr);
|
mainloop = isc_loop_main(loopmgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1080,7 +1080,7 @@ main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
setfatalcallback(cleanup);
|
setfatalcallback(cleanup);
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create(argv[0], &mctx);
|
||||||
|
|
||||||
isc_commandline_errprint = false;
|
isc_commandline_errprint = false;
|
||||||
|
|
||||||
|
@ -376,7 +376,7 @@ main(int argc, char **argv) {
|
|||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create(argv[0], &mctx);
|
||||||
|
|
||||||
isc_commandline_errprint = false;
|
isc_commandline_errprint = false;
|
||||||
|
|
||||||
|
@ -308,7 +308,7 @@ main(int argc, char **argv) {
|
|||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create(argv[0], &mctx);
|
||||||
|
|
||||||
isc_commandline_errprint = false;
|
isc_commandline_errprint = false;
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ main(int argc, char **argv) {
|
|||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create(argv[0], &mctx);
|
||||||
|
|
||||||
isc_commandline_errprint = false;
|
isc_commandline_errprint = false;
|
||||||
|
|
||||||
|
@ -812,7 +812,7 @@ main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
isc_commandline_reset = true;
|
isc_commandline_reset = true;
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create(argv[0], &mctx);
|
||||||
|
|
||||||
while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) {
|
while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
|
@ -1326,7 +1326,7 @@ main(int argc, char *argv[]) {
|
|||||||
.now = isc_stdtime_now(),
|
.now = isc_stdtime_now(),
|
||||||
};
|
};
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create(argv[0], &mctx);
|
||||||
|
|
||||||
isc_commandline_errprint = false;
|
isc_commandline_errprint = false;
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ main(int argc, char **argv) {
|
|||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create(argv[0], &mctx);
|
||||||
|
|
||||||
isc_commandline_errprint = false;
|
isc_commandline_errprint = false;
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ main(int argc, char **argv) {
|
|||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create(argv[0], &mctx);
|
||||||
|
|
||||||
setup_logging();
|
setup_logging();
|
||||||
|
|
||||||
|
@ -202,7 +202,7 @@ main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
isc_commandline_reset = true;
|
isc_commandline_reset = true;
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create(argv[0], &mctx);
|
||||||
|
|
||||||
isc_commandline_errprint = false;
|
isc_commandline_errprint = false;
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ dlopen_dlz_create(const char *dlzname, unsigned int argc, char *argv[],
|
|||||||
return ISC_R_FAILURE;
|
return ISC_R_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create("dlz", &mctx);
|
||||||
cd = isc_mem_get(mctx, sizeof(*cd));
|
cd = isc_mem_get(mctx, sizeof(*cd));
|
||||||
*cd = (dlopen_data_t){
|
*cd = (dlopen_data_t){
|
||||||
.mctx = mctx,
|
.mctx = mctx,
|
||||||
|
@ -608,7 +608,7 @@ printversion(bool verbose) {
|
|||||||
#if defined(HAVE_GEOIP2)
|
#if defined(HAVE_GEOIP2)
|
||||||
#define RTC(x) RUNTIME_CHECK((x) == ISC_R_SUCCESS)
|
#define RTC(x) RUNTIME_CHECK((x) == ISC_R_SUCCESS)
|
||||||
isc_mem_t *mctx = NULL;
|
isc_mem_t *mctx = NULL;
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create("geoip", &mctx);
|
||||||
RTC(cfg_parser_create(mctx, &parser));
|
RTC(cfg_parser_create(mctx, &parser));
|
||||||
RTC(named_config_parsedefaults(parser, &config));
|
RTC(named_config_parsedefaults(parser, &config));
|
||||||
RTC(cfg_map_get(config, "options", &defaults));
|
RTC(cfg_map_get(config, "options", &defaults));
|
||||||
@ -1453,7 +1453,6 @@ main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setup();
|
setup();
|
||||||
isc_mem_setname(named_g_mctx, "main");
|
|
||||||
INSIST(named_g_server != NULL);
|
INSIST(named_g_server != NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -76,7 +76,7 @@ main(int argc, char **argv) {
|
|||||||
journal = argv[4];
|
journal = argv[4];
|
||||||
|
|
||||||
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
|
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create(argv[0], &mctx);
|
||||||
|
|
||||||
logconfig = isc_logconfig_get();
|
logconfig = isc_logconfig_get();
|
||||||
isc_log_createandusechannel(
|
isc_log_createandusechannel(
|
||||||
|
@ -105,7 +105,7 @@ main(int argc, char **argv) {
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create(argv[0], &mctx);
|
||||||
|
|
||||||
dns_log_init();
|
dns_log_init();
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ main(int argc, char *argv[]) {
|
|||||||
}
|
}
|
||||||
isc_commandline_reset = true;
|
isc_commandline_reset = true;
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create(argv[0], &mctx);
|
||||||
|
|
||||||
while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) {
|
while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
|
@ -375,7 +375,7 @@ main(int argc, char *argv[]) {
|
|||||||
fatal("no file specified");
|
fatal("no file specified");
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create(argv[0], &mctx);
|
||||||
|
|
||||||
CHECKM(dns_dt_open(argv[0], dns_dtmode_file, mctx, &handle),
|
CHECKM(dns_dt_open(argv[0], dns_dtmode_file, mctx, &handle),
|
||||||
"dns_dt_openfile");
|
"dns_dt_openfile");
|
||||||
|
@ -93,7 +93,7 @@ main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
file = argv[0];
|
file = argv[0];
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create(argv[0], &mctx);
|
||||||
setup_logging(stderr);
|
setup_logging(stderr);
|
||||||
|
|
||||||
if (upgrade) {
|
if (upgrade) {
|
||||||
|
@ -170,7 +170,7 @@ main(int argc, char *argv[]) {
|
|||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create(argv[0], &mctx);
|
||||||
isc_lex_create(mctx, 256, &lex);
|
isc_lex_create(mctx, 256, &lex);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -449,7 +449,7 @@ memory has not been freed when BIND shuts down.
|
|||||||
To create a basic memory context, use:
|
To create a basic memory context, use:
|
||||||
|
|
||||||
isc_mem_t *mctx = NULL;
|
isc_mem_t *mctx = NULL;
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create("name", &mctx);
|
||||||
|
|
||||||
When holding a persistent reference to a memory context it is advisable to
|
When holding a persistent reference to a memory context it is advisable to
|
||||||
increment its reference counter using `isc_mem_attach()`. Do not just
|
increment its reference counter using `isc_mem_attach()`. Do not just
|
||||||
|
@ -61,7 +61,7 @@ main(int argc, char **argv) {
|
|||||||
unsigned int zonetype = 0;
|
unsigned int zonetype = 0;
|
||||||
unsigned int pflags = 0;
|
unsigned int pflags = 0;
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create("misc", &mctx);
|
||||||
|
|
||||||
setup_logging();
|
setup_logging();
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|||||||
dns_rdatacallbacks_init(&callbacks);
|
dns_rdatacallbacks_init(&callbacks);
|
||||||
dns_db_t *db = NULL;
|
dns_db_t *db = NULL;
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create("fuzz", &mctx);
|
||||||
result = dns_db_create(mctx, ZONEDB_DEFAULT, dns_rootname,
|
result = dns_db_create(mctx, ZONEDB_DEFAULT, dns_rootname,
|
||||||
dns_dbtype_zone, dns_rdataclass_in, 0, NULL,
|
dns_dbtype_zone, dns_rdataclass_in, 0, NULL,
|
||||||
&db);
|
&db);
|
||||||
|
@ -169,7 +169,7 @@ LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED) {
|
|||||||
fputs(c3, fd);
|
fputs(c3, fd);
|
||||||
fclose(fd);
|
fclose(fd);
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create("fuzz", &mctx);
|
||||||
|
|
||||||
isc_loopmgr_create(mctx, 1, &loopmgr);
|
isc_loopmgr_create(mctx, 1, &loopmgr);
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ static uint8_t render_buf[64 * 1024 - 1];
|
|||||||
|
|
||||||
int
|
int
|
||||||
LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED) {
|
LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED) {
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create("fuzz", &mctx);
|
||||||
output = isc_mem_get(mctx, output_len);
|
output = isc_mem_get(mctx, output_len);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -122,7 +122,7 @@ LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
|||||||
TRACE("------------------------------------------------");
|
TRACE("------------------------------------------------");
|
||||||
|
|
||||||
isc_mem_t *mctx = NULL;
|
isc_mem_t *mctx = NULL;
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create("fuzz", &mctx);
|
||||||
isc_mem_setdestroycheck(mctx, true);
|
isc_mem_setdestroycheck(mctx, true);
|
||||||
|
|
||||||
dns_qp_t *qp = NULL;
|
dns_qp_t *qp = NULL;
|
||||||
|
@ -46,7 +46,7 @@ isc_lexspecials_t specials = { ['('] = 1, [')'] = 1, ['"'] = 1 };
|
|||||||
int
|
int
|
||||||
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
|
||||||
isc_mem_t *mctx = NULL;
|
isc_mem_t *mctx = NULL;
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create("fuzz", &mctx);
|
||||||
|
|
||||||
isc_lex_t *lex = NULL;
|
isc_lex_t *lex = NULL;
|
||||||
isc_token_t token;
|
isc_token_t token;
|
||||||
|
@ -45,7 +45,7 @@ int
|
|||||||
LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED) {
|
LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED) {
|
||||||
isc_lexspecials_t specials;
|
isc_lexspecials_t specials;
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create("fuzz", &mctx);
|
||||||
isc_lex_create(mctx, 64, &lex);
|
isc_lex_create(mctx, 64, &lex);
|
||||||
|
|
||||||
memset(specials, 0, sizeof(specials));
|
memset(specials, 0, sizeof(specials));
|
||||||
|
@ -35,7 +35,7 @@ static isc_lex_t *lex = NULL;
|
|||||||
|
|
||||||
int
|
int
|
||||||
LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED) {
|
LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED) {
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create("fuzz", &mctx);
|
||||||
isc_lex_create(mctx, 1024, &lex);
|
isc_lex_create(mctx, 1024, &lex);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -28,7 +28,7 @@ static isc_lex_t *lex = NULL;
|
|||||||
|
|
||||||
int
|
int
|
||||||
LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED) {
|
LLVMFuzzerInitialize(int *argc ISC_ATTR_UNUSED, char ***argv ISC_ATTR_UNUSED) {
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create("fuzz", &mctx);
|
||||||
isc_lex_create(mctx, 1024, &lex);
|
isc_lex_create(mctx, 1024, &lex);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -1732,8 +1732,7 @@ dns_adb_create(isc_mem_t *mem, dns_view_t *view, dns_adb_t **newadb) {
|
|||||||
dns_resolver_attach(view->resolver, &adb->res);
|
dns_resolver_attach(view->resolver, &adb->res);
|
||||||
isc_mem_attach(mem, &adb->mctx);
|
isc_mem_attach(mem, &adb->mctx);
|
||||||
|
|
||||||
isc_mem_create(&adb->hmctx);
|
isc_mem_create("ADB_dynamic", &adb->hmctx);
|
||||||
isc_mem_setname(adb->hmctx, "ADB_dynamic");
|
|
||||||
|
|
||||||
isc_hashmap_create(adb->hmctx, ADB_HASH_BITS, &adb->names);
|
isc_hashmap_create(adb->hmctx, ADB_HASH_BITS, &adb->names);
|
||||||
isc_rwlock_init(&adb->names_lock);
|
isc_rwlock_init(&adb->names_lock);
|
||||||
|
@ -100,8 +100,7 @@ cache_create_db(dns_cache_t *cache, dns_db_t **dbp, isc_mem_t **tmctxp,
|
|||||||
* This will be the cache memory context, which is subject
|
* This will be the cache memory context, which is subject
|
||||||
* to cleaning when the configured memory limits are exceeded.
|
* to cleaning when the configured memory limits are exceeded.
|
||||||
*/
|
*/
|
||||||
isc_mem_create(&tmctx);
|
isc_mem_create("cache", &tmctx);
|
||||||
isc_mem_setname(tmctx, "cache");
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This will be passed to RBTDB to use for heaps. This is separate
|
* This will be passed to RBTDB to use for heaps. This is separate
|
||||||
@ -109,8 +108,7 @@ cache_create_db(dns_cache_t *cache, dns_db_t **dbp, isc_mem_t **tmctxp,
|
|||||||
* heavy load and could otherwise cause the cache to be cleaned too
|
* heavy load and could otherwise cause the cache to be cleaned too
|
||||||
* aggressively.
|
* aggressively.
|
||||||
*/
|
*/
|
||||||
isc_mem_create(&hmctx);
|
isc_mem_create("cache_heap", &hmctx);
|
||||||
isc_mem_setname(hmctx, "cache_heap");
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For databases of type "qpcache" or "rbt" (which are the
|
* For databases of type "qpcache" or "rbt" (which are the
|
||||||
|
@ -190,8 +190,7 @@ static isc_mem_t *dst__mctx = NULL;
|
|||||||
|
|
||||||
void
|
void
|
||||||
dst__lib_initialize(void) {
|
dst__lib_initialize(void) {
|
||||||
isc_mem_create(&dst__mctx);
|
isc_mem_create("dst", &dst__mctx);
|
||||||
isc_mem_setname(dst__mctx, "dst");
|
|
||||||
|
|
||||||
dst__hmacmd5_init(&dst_t_func[DST_ALG_HMACMD5]);
|
dst__hmacmd5_init(&dst_t_func[DST_ALG_HMACMD5]);
|
||||||
dst__hmacsha1_init(&dst_t_func[DST_ALG_HMACSHA1]);
|
dst__hmacsha1_init(&dst_t_func[DST_ALG_HMACSHA1]);
|
||||||
|
@ -5070,15 +5070,15 @@ dns_message_createpools(isc_mem_t *mctx, isc_mempool_t **namepoolp,
|
|||||||
REQUIRE(namepoolp != NULL && *namepoolp == NULL);
|
REQUIRE(namepoolp != NULL && *namepoolp == NULL);
|
||||||
REQUIRE(rdspoolp != NULL && *rdspoolp == NULL);
|
REQUIRE(rdspoolp != NULL && *rdspoolp == NULL);
|
||||||
|
|
||||||
isc_mempool_create(mctx, sizeof(dns_fixedname_t), namepoolp);
|
isc_mempool_create(mctx, sizeof(dns_fixedname_t), "dns_fixedname_pool",
|
||||||
|
namepoolp);
|
||||||
isc_mempool_setfillcount(*namepoolp, NAME_FILLCOUNT);
|
isc_mempool_setfillcount(*namepoolp, NAME_FILLCOUNT);
|
||||||
isc_mempool_setfreemax(*namepoolp, NAME_FREEMAX);
|
isc_mempool_setfreemax(*namepoolp, NAME_FREEMAX);
|
||||||
isc_mempool_setname(*namepoolp, "dns_fixedname_pool");
|
|
||||||
|
|
||||||
isc_mempool_create(mctx, sizeof(dns_rdataset_t), rdspoolp);
|
isc_mempool_create(mctx, sizeof(dns_rdataset_t), "dns_rdataset_pool",
|
||||||
|
rdspoolp);
|
||||||
isc_mempool_setfillcount(*rdspoolp, RDATASET_FILLCOUNT);
|
isc_mempool_setfillcount(*rdspoolp, RDATASET_FILLCOUNT);
|
||||||
isc_mempool_setfreemax(*rdspoolp, RDATASET_FREEMAX);
|
isc_mempool_setfreemax(*rdspoolp, RDATASET_FREEMAX);
|
||||||
isc_mempool_setname(*rdspoolp, "dns_rdataset_pool");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -536,8 +536,7 @@ dns_view_createresolver(dns_view_t *view, isc_nm_t *netmgr,
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create("ADB", &mctx);
|
||||||
isc_mem_setname(mctx, "ADB");
|
|
||||||
dns_adb_create(mctx, view, &view->adb);
|
dns_adb_create(mctx, view, &view->adb);
|
||||||
isc_mem_detach(&mctx);
|
isc_mem_detach(&mctx);
|
||||||
|
|
||||||
|
@ -19052,8 +19052,7 @@ dns_zonemgr_create(isc_mem_t *mctx, isc_nm_t *netmgr, dns_zonemgr_t **zmgrp) {
|
|||||||
zmgr->mctxpool = isc_mem_cget(zmgr->mctx, zmgr->workers,
|
zmgr->mctxpool = isc_mem_cget(zmgr->mctx, zmgr->workers,
|
||||||
sizeof(zmgr->mctxpool[0]));
|
sizeof(zmgr->mctxpool[0]));
|
||||||
for (size_t i = 0; i < zmgr->workers; i++) {
|
for (size_t i = 0; i < zmgr->workers; i++) {
|
||||||
isc_mem_create(&zmgr->mctxpool[i]);
|
isc_mem_create("zonemgr-mctxpool", &zmgr->mctxpool[i]);
|
||||||
isc_mem_setname(zmgr->mctxpool[i], "zonemgr-mctxpool");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Key file I/O locks. */
|
/* Key file I/O locks. */
|
||||||
|
@ -252,8 +252,7 @@ void
|
|||||||
isc__crypto_initialize(void) {
|
isc__crypto_initialize(void) {
|
||||||
uint64_t opts = OPENSSL_INIT_LOAD_CONFIG;
|
uint64_t opts = OPENSSL_INIT_LOAD_CONFIG;
|
||||||
|
|
||||||
isc_mem_create(&isc__crypto_mctx);
|
isc_mem_create("OpenSSL", &isc__crypto_mctx);
|
||||||
isc_mem_setname(isc__crypto_mctx, "OpenSSL");
|
|
||||||
isc_mem_setdestroycheck(isc__crypto_mctx, false);
|
isc_mem_setdestroycheck(isc__crypto_mctx, false);
|
||||||
|
|
||||||
#if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x30000000L
|
#if !defined(LIBRESSL_VERSION_NUMBER) && OPENSSL_VERSION_NUMBER >= 0x30000000L
|
||||||
|
@ -200,17 +200,17 @@ mallocx(size_t size, int flags);
|
|||||||
|
|
||||||
extern volatile void *isc__mem_malloc;
|
extern volatile void *isc__mem_malloc;
|
||||||
|
|
||||||
#define isc_mem_create(cp) \
|
#define isc_mem_create(name, cp) \
|
||||||
{ \
|
{ \
|
||||||
isc__mem_create((cp)_ISC_MEM_FILELINE); \
|
isc__mem_create((name), (cp)_ISC_MEM_FILELINE); \
|
||||||
isc__mem_malloc = mallocx; \
|
isc__mem_malloc = mallocx; \
|
||||||
ISC_INSIST(CMM_ACCESS_ONCE(isc__mem_malloc) != NULL); \
|
ISC_INSIST(CMM_ACCESS_ONCE(isc__mem_malloc) != NULL); \
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
#define isc_mem_create(cp) isc__mem_create((cp)_ISC_MEM_FILELINE)
|
#define isc_mem_create(name, cp) isc__mem_create((name), (cp)_ISC_MEM_FILELINE)
|
||||||
#endif
|
#endif
|
||||||
void
|
void
|
||||||
isc__mem_create(isc_mem_t **_ISC_MEM_FLARG);
|
isc__mem_create(const char *name, isc_mem_t **_ISC_MEM_FLARG);
|
||||||
|
|
||||||
/*!<
|
/*!<
|
||||||
* \brief Create a memory context.
|
* \brief Create a memory context.
|
||||||
@ -219,9 +219,10 @@ isc__mem_create(isc_mem_t **_ISC_MEM_FLARG);
|
|||||||
* mctxp != NULL && *mctxp == NULL */
|
* mctxp != NULL && *mctxp == NULL */
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
||||||
#define isc_mem_create_arena(cp) isc__mem_create_arena((cp)_ISC_MEM_FILELINE)
|
#define isc_mem_create_arena(name, cp) \
|
||||||
|
isc__mem_create_arena((name), (cp)_ISC_MEM_FILELINE)
|
||||||
void
|
void
|
||||||
isc__mem_create_arena(isc_mem_t **_ISC_MEM_FLARG);
|
isc__mem_create_arena(const char *name, isc_mem_t **_ISC_MEM_FLARG);
|
||||||
/*!<
|
/*!<
|
||||||
* \brief Create a memory context that routs all its operations to a
|
* \brief Create a memory context that routs all its operations to a
|
||||||
* dedicated jemalloc arena (when available). When jemalloc is not
|
* dedicated jemalloc arena (when available). When jemalloc is not
|
||||||
@ -325,20 +326,6 @@ isc_mem_references(isc_mem_t *ctx);
|
|||||||
* Return the current reference count.
|
* Return the current reference count.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
|
||||||
isc_mem_setname(isc_mem_t *ctx, const char *name);
|
|
||||||
/*%<
|
|
||||||
* Name 'ctx'.
|
|
||||||
*
|
|
||||||
* Notes:
|
|
||||||
*
|
|
||||||
*\li Only the first 15 characters of 'name' will be copied.
|
|
||||||
*
|
|
||||||
* Requires:
|
|
||||||
*
|
|
||||||
*\li 'ctx' is a valid ctx.
|
|
||||||
*/
|
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
isc_mem_getname(isc_mem_t *ctx);
|
isc_mem_getname(isc_mem_t *ctx);
|
||||||
/*%<
|
/*%<
|
||||||
@ -373,11 +360,11 @@ isc_mem_renderjson(void *memobj0);
|
|||||||
* Memory pools
|
* Memory pools
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define isc_mempool_create(c, s, mp) \
|
#define isc_mempool_create(c, s, n, mp) \
|
||||||
isc__mempool_create((c), (s), (mp)_ISC_MEM_FILELINE)
|
isc__mempool_create((c), (s), (n), (mp)_ISC_MEM_FILELINE)
|
||||||
void
|
void
|
||||||
isc__mempool_create(isc_mem_t *restrict mctx, const size_t element_size,
|
isc__mempool_create(isc_mem_t *restrict mctx, const size_t element_size,
|
||||||
isc_mempool_t **mpctxp _ISC_MEM_FLARG);
|
const char *name, isc_mempool_t **mpctxp _ISC_MEM_FLARG);
|
||||||
/*%<
|
/*%<
|
||||||
* Create a memory pool.
|
* Create a memory pool.
|
||||||
*
|
*
|
||||||
@ -402,17 +389,6 @@ isc__mempool_destroy(isc_mempool_t **restrict mpctxp _ISC_MEM_FLARG);
|
|||||||
*\li The pool has no un"put" allocations outstanding
|
*\li The pool has no un"put" allocations outstanding
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void
|
|
||||||
isc_mempool_setname(isc_mempool_t *restrict mpctx, const char *name);
|
|
||||||
/*%<
|
|
||||||
* Associate a name with a memory pool. At most 15 characters may be
|
|
||||||
*used.
|
|
||||||
*
|
|
||||||
* Requires:
|
|
||||||
*\li mpctx is a valid pool.
|
|
||||||
*\li name != NULL;
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The following functions get/set various parameters. Note that due to
|
* The following functions get/set various parameters. Note that due to
|
||||||
* the unlocked nature of pools these are potentially random values
|
* the unlocked nature of pools these are potentially random values
|
||||||
|
@ -1551,7 +1551,7 @@ isc__log_initialize(void) {
|
|||||||
|
|
||||||
isc_mem_t *mctx = NULL;
|
isc_mem_t *mctx = NULL;
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create("log", &mctx);
|
||||||
|
|
||||||
isc__lctx = isc_mem_get(mctx, sizeof(*isc__lctx));
|
isc__lctx = isc_mem_get(mctx, sizeof(*isc__lctx));
|
||||||
*isc__lctx = (isc_log_t){
|
*isc__lctx = (isc_log_t){
|
||||||
|
@ -226,10 +226,7 @@ loop_init(isc_loop_t *loop, isc_loopmgr_t *loopmgr, uint32_t tid,
|
|||||||
UV_RUNTIME_CHECK(uv_prepare_init, r);
|
UV_RUNTIME_CHECK(uv_prepare_init, r);
|
||||||
uv_handle_set_data(&loop->quiescent, loop);
|
uv_handle_set_data(&loop->quiescent, loop);
|
||||||
|
|
||||||
char name[16];
|
isc_mem_create(kind, &loop->mctx);
|
||||||
snprintf(name, sizeof(name), "%s-%08" PRIx32, kind, tid);
|
|
||||||
isc_mem_create(&loop->mctx);
|
|
||||||
isc_mem_setname(loop->mctx, name);
|
|
||||||
|
|
||||||
isc_refcount_init(&loop->references, 1);
|
isc_refcount_init(&loop->references, 1);
|
||||||
|
|
||||||
|
@ -20,9 +20,8 @@ void
|
|||||||
isc_managers_create(isc_mem_t **mctxp, uint32_t workers,
|
isc_managers_create(isc_mem_t **mctxp, uint32_t workers,
|
||||||
isc_loopmgr_t **loopmgrp, isc_nm_t **netmgrp) {
|
isc_loopmgr_t **loopmgrp, isc_nm_t **netmgrp) {
|
||||||
REQUIRE(mctxp != NULL && *mctxp == NULL);
|
REQUIRE(mctxp != NULL && *mctxp == NULL);
|
||||||
isc_mem_create(mctxp);
|
isc_mem_create("managers", mctxp);
|
||||||
INSIST(*mctxp != NULL);
|
INSIST(*mctxp != NULL);
|
||||||
isc_mem_setname(*mctxp, "managers");
|
|
||||||
|
|
||||||
REQUIRE(loopmgrp != NULL && *loopmgrp == NULL);
|
REQUIRE(loopmgrp != NULL && *loopmgrp == NULL);
|
||||||
isc_loopmgr_create(*mctxp, workers, loopmgrp);
|
isc_loopmgr_create(*mctxp, workers, loopmgrp);
|
||||||
|
@ -123,7 +123,7 @@ struct isc_mem {
|
|||||||
isc_mutex_t lock;
|
isc_mutex_t lock;
|
||||||
bool checkfree;
|
bool checkfree;
|
||||||
isc_refcount_t references;
|
isc_refcount_t references;
|
||||||
char name[16];
|
char *name;
|
||||||
atomic_size_t inuse;
|
atomic_size_t inuse;
|
||||||
atomic_bool hi_called;
|
atomic_bool hi_called;
|
||||||
atomic_bool is_overmem;
|
atomic_bool is_overmem;
|
||||||
@ -157,7 +157,7 @@ struct isc_mempool {
|
|||||||
/*%< Stats only. */
|
/*%< Stats only. */
|
||||||
size_t gets; /*%< # of requests to this pool */
|
size_t gets; /*%< # of requests to this pool */
|
||||||
/*%< Debugging only. */
|
/*%< Debugging only. */
|
||||||
char name[16]; /*%< printed name in stats reports */
|
char *name; /*%< printed name in stats reports */
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -450,11 +450,12 @@ isc__mem_shutdown(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
mem_create(isc_mem_t **ctxp, unsigned int debugging, unsigned int flags,
|
mem_create(const char *name, isc_mem_t **ctxp, unsigned int debugging,
|
||||||
unsigned int jemalloc_flags) {
|
unsigned int flags, unsigned int jemalloc_flags) {
|
||||||
isc_mem_t *ctx = NULL;
|
isc_mem_t *ctx = NULL;
|
||||||
|
|
||||||
REQUIRE(ctxp != NULL && *ctxp == NULL);
|
REQUIRE(ctxp != NULL && *ctxp == NULL);
|
||||||
|
REQUIRE(name != NULL);
|
||||||
|
|
||||||
ctx = mallocx(sizeof(*ctx), jemalloc_flags);
|
ctx = mallocx(sizeof(*ctx), jemalloc_flags);
|
||||||
INSIST(ctx != NULL);
|
INSIST(ctx != NULL);
|
||||||
@ -466,6 +467,7 @@ mem_create(isc_mem_t **ctxp, unsigned int debugging, unsigned int flags,
|
|||||||
.jemalloc_flags = jemalloc_flags,
|
.jemalloc_flags = jemalloc_flags,
|
||||||
.jemalloc_arena = ISC_MEM_ILLEGAL_ARENA,
|
.jemalloc_arena = ISC_MEM_ILLEGAL_ARENA,
|
||||||
.checkfree = true,
|
.checkfree = true,
|
||||||
|
.name = strdup(name),
|
||||||
};
|
};
|
||||||
|
|
||||||
isc_mutex_init(&ctx->lock);
|
isc_mutex_init(&ctx->lock);
|
||||||
@ -542,6 +544,8 @@ mem_destroy(isc_mem_t *ctx) {
|
|||||||
}
|
}
|
||||||
#endif /* if ISC_MEM_TRACKLINES */
|
#endif /* if ISC_MEM_TRACKLINES */
|
||||||
|
|
||||||
|
free(ctx->name);
|
||||||
|
|
||||||
isc_mutex_destroy(&ctx->lock);
|
isc_mutex_destroy(&ctx->lock);
|
||||||
|
|
||||||
if (ctx->checkfree) {
|
if (ctx->checkfree) {
|
||||||
@ -900,15 +904,6 @@ isc_mem_isovermem(isc_mem_t *ctx) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
isc_mem_setname(isc_mem_t *ctx, const char *name) {
|
|
||||||
REQUIRE(VALID_CONTEXT(ctx));
|
|
||||||
|
|
||||||
LOCK(&ctx->lock);
|
|
||||||
strlcpy(ctx->name, name, sizeof(ctx->name));
|
|
||||||
UNLOCK(&ctx->lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
const char *
|
const char *
|
||||||
isc_mem_getname(isc_mem_t *ctx) {
|
isc_mem_getname(isc_mem_t *ctx) {
|
||||||
REQUIRE(VALID_CONTEXT(ctx));
|
REQUIRE(VALID_CONTEXT(ctx));
|
||||||
@ -926,13 +921,14 @@ isc_mem_getname(isc_mem_t *ctx) {
|
|||||||
|
|
||||||
void
|
void
|
||||||
isc__mempool_create(isc_mem_t *restrict mctx, const size_t element_size,
|
isc__mempool_create(isc_mem_t *restrict mctx, const size_t element_size,
|
||||||
isc_mempool_t **restrict mpctxp FLARG) {
|
const char *name, isc_mempool_t **restrict mpctxp FLARG) {
|
||||||
isc_mempool_t *restrict mpctx = NULL;
|
isc_mempool_t *restrict mpctx = NULL;
|
||||||
size_t size = element_size;
|
size_t size = element_size;
|
||||||
|
|
||||||
REQUIRE(VALID_CONTEXT(mctx));
|
REQUIRE(VALID_CONTEXT(mctx));
|
||||||
REQUIRE(size > 0U);
|
REQUIRE(size > 0U);
|
||||||
REQUIRE(mpctxp != NULL && *mpctxp == NULL);
|
REQUIRE(mpctxp != NULL && *mpctxp == NULL);
|
||||||
|
REQUIRE(name != NULL);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Mempools are stored as a linked list of element.
|
* Mempools are stored as a linked list of element.
|
||||||
@ -951,6 +947,7 @@ isc__mempool_create(isc_mem_t *restrict mctx, const size_t element_size,
|
|||||||
.size = size,
|
.size = size,
|
||||||
.freemax = 1,
|
.freemax = 1,
|
||||||
.fillcount = 1,
|
.fillcount = 1,
|
||||||
|
.name = strdup(name),
|
||||||
};
|
};
|
||||||
|
|
||||||
#if ISC_MEM_TRACKLINES
|
#if ISC_MEM_TRACKLINES
|
||||||
@ -972,14 +969,6 @@ isc__mempool_create(isc_mem_t *restrict mctx, const size_t element_size,
|
|||||||
MCTXUNLOCK(mctx);
|
MCTXUNLOCK(mctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
isc_mempool_setname(isc_mempool_t *restrict mpctx, const char *name) {
|
|
||||||
REQUIRE(VALID_MEMPOOL(mpctx));
|
|
||||||
REQUIRE(name != NULL);
|
|
||||||
|
|
||||||
strlcpy(mpctx->name, name, sizeof(mpctx->name));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
isc__mempool_destroy(isc_mempool_t **restrict mpctxp FLARG) {
|
isc__mempool_destroy(isc_mempool_t **restrict mpctxp FLARG) {
|
||||||
isc_mempool_t *restrict mpctx = NULL;
|
isc_mempool_t *restrict mpctx = NULL;
|
||||||
@ -1029,6 +1018,8 @@ isc__mempool_destroy(isc_mempool_t **restrict mpctxp FLARG) {
|
|||||||
mctx->poolcnt--;
|
mctx->poolcnt--;
|
||||||
MCTXUNLOCK(mctx);
|
MCTXUNLOCK(mctx);
|
||||||
|
|
||||||
|
free(mpctx->name);
|
||||||
|
|
||||||
mpctx->magic = 0;
|
mpctx->magic = 0;
|
||||||
|
|
||||||
isc_mem_putanddetach(&mpctx->mctx, mpctx, sizeof(isc_mempool_t));
|
isc_mem_putanddetach(&mpctx->mctx, mpctx, sizeof(isc_mempool_t));
|
||||||
@ -1415,8 +1406,8 @@ error:
|
|||||||
#endif /* HAVE_JSON_C */
|
#endif /* HAVE_JSON_C */
|
||||||
|
|
||||||
void
|
void
|
||||||
isc__mem_create(isc_mem_t **mctxp FLARG) {
|
isc__mem_create(const char *name, isc_mem_t **mctxp FLARG) {
|
||||||
mem_create(mctxp, isc_mem_debugging, isc_mem_defaultflags, 0);
|
mem_create(name, mctxp, isc_mem_debugging, isc_mem_defaultflags, 0);
|
||||||
#if ISC_MEM_TRACKLINES
|
#if ISC_MEM_TRACKLINES
|
||||||
if ((isc_mem_debugging & ISC_MEM_DEBUGTRACE) != 0) {
|
if ((isc_mem_debugging & ISC_MEM_DEBUGTRACE) != 0) {
|
||||||
fprintf(stderr, "create mctx %p func %s file %s line %u\n",
|
fprintf(stderr, "create mctx %p func %s file %s line %u\n",
|
||||||
@ -1426,7 +1417,7 @@ isc__mem_create(isc_mem_t **mctxp FLARG) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
isc__mem_create_arena(isc_mem_t **mctxp FLARG) {
|
isc__mem_create_arena(const char *name, isc_mem_t **mctxp FLARG) {
|
||||||
unsigned int arena_no = ISC_MEM_ILLEGAL_ARENA;
|
unsigned int arena_no = ISC_MEM_ILLEGAL_ARENA;
|
||||||
|
|
||||||
RUNTIME_CHECK(mem_jemalloc_arena_create(&arena_no));
|
RUNTIME_CHECK(mem_jemalloc_arena_create(&arena_no));
|
||||||
@ -1438,7 +1429,7 @@ isc__mem_create_arena(isc_mem_t **mctxp FLARG) {
|
|||||||
*
|
*
|
||||||
* https://github.com/jemalloc/jemalloc/issues/2483#issuecomment-1698173849
|
* https://github.com/jemalloc/jemalloc/issues/2483#issuecomment-1698173849
|
||||||
*/
|
*/
|
||||||
mem_create(mctxp, isc_mem_debugging, isc_mem_defaultflags,
|
mem_create(name, mctxp, isc_mem_debugging, isc_mem_defaultflags,
|
||||||
arena_no == ISC_MEM_ILLEGAL_ARENA
|
arena_no == ISC_MEM_ILLEGAL_ARENA
|
||||||
? 0
|
? 0
|
||||||
: MALLOCX_ARENA(arena_no) | MALLOCX_TCACHE_NONE);
|
: MALLOCX_ARENA(arena_no) | MALLOCX_TCACHE_NONE);
|
||||||
|
@ -223,12 +223,12 @@ isc_netmgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, isc_nm_t **netmgrp) {
|
|||||||
isc_mem_attach(loop->mctx, &worker->mctx);
|
isc_mem_attach(loop->mctx, &worker->mctx);
|
||||||
|
|
||||||
isc_mempool_create(worker->mctx, sizeof(isc_nmsocket_t),
|
isc_mempool_create(worker->mctx, sizeof(isc_nmsocket_t),
|
||||||
&worker->nmsocket_pool);
|
"nmsocket_pool", &worker->nmsocket_pool);
|
||||||
isc_mempool_setfreemax(worker->nmsocket_pool,
|
isc_mempool_setfreemax(worker->nmsocket_pool,
|
||||||
ISC_NM_NMSOCKET_MAX);
|
ISC_NM_NMSOCKET_MAX);
|
||||||
|
|
||||||
isc_mempool_create(worker->mctx, sizeof(isc__nm_uvreq_t),
|
isc_mempool_create(worker->mctx, sizeof(isc__nm_uvreq_t),
|
||||||
&worker->uvreq_pool);
|
"uvreq_pool", &worker->uvreq_pool);
|
||||||
isc_mempool_setfreemax(worker->uvreq_pool, ISC_NM_UVREQS_MAX);
|
isc_mempool_setfreemax(worker->uvreq_pool, ISC_NM_UVREQS_MAX);
|
||||||
|
|
||||||
isc_loop_attach(loop, &worker->loop);
|
isc_loop_attach(loop, &worker->loop);
|
||||||
|
@ -132,8 +132,7 @@ void
|
|||||||
isc__uv_initialize(void) {
|
isc__uv_initialize(void) {
|
||||||
#if UV_VERSION_HEX >= UV_VERSION(1, 38, 0)
|
#if UV_VERSION_HEX >= UV_VERSION(1, 38, 0)
|
||||||
int r;
|
int r;
|
||||||
isc_mem_create(&isc__uv_mctx);
|
isc_mem_create("uv", &isc__uv_mctx);
|
||||||
isc_mem_setname(isc__uv_mctx, "uv");
|
|
||||||
isc_mem_setdestroycheck(isc__uv_mctx, false);
|
isc_mem_setdestroycheck(isc__uv_mctx, false);
|
||||||
|
|
||||||
r = uv_replace_allocator(isc__uv_malloc, isc__uv_realloc,
|
r = uv_replace_allocator(isc__uv_malloc, isc__uv_realloc,
|
||||||
|
@ -52,8 +52,7 @@ void
|
|||||||
isc__xml_initialize(void) {
|
isc__xml_initialize(void) {
|
||||||
#ifdef HAVE_LIBXML2
|
#ifdef HAVE_LIBXML2
|
||||||
#ifndef LIBXML_HAS_DEPRECATED_MEMORY_ALLOCATION_FUNCTIONS
|
#ifndef LIBXML_HAS_DEPRECATED_MEMORY_ALLOCATION_FUNCTIONS
|
||||||
isc_mem_create(&isc__xml_mctx);
|
isc_mem_create("libxml2", &isc__xml_mctx);
|
||||||
isc_mem_setname(isc__xml_mctx, "libxml2");
|
|
||||||
isc_mem_setdestroycheck(isc__xml_mctx, false);
|
isc_mem_setdestroycheck(isc__xml_mctx, false);
|
||||||
|
|
||||||
RUNTIME_CHECK(xmlMemSetup(isc__xml_free, isc__xml_malloc,
|
RUNTIME_CHECK(xmlMemSetup(isc__xml_free, isc__xml_malloc,
|
||||||
|
@ -2645,8 +2645,7 @@ ns_clientmgr_create(ns_server_t *sctx, isc_loopmgr_t *loopmgr,
|
|||||||
ns_clientmgr_t *manager = NULL;
|
ns_clientmgr_t *manager = NULL;
|
||||||
isc_mem_t *mctx = NULL;
|
isc_mem_t *mctx = NULL;
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create("clientmgr", &mctx);
|
||||||
isc_mem_setname(mctx, "clientmgr");
|
|
||||||
|
|
||||||
manager = isc_mem_get(mctx, sizeof(*manager));
|
manager = isc_mem_get(mctx, sizeof(*manager));
|
||||||
*manager = (ns_clientmgr_t){
|
*manager = (ns_clientmgr_t){
|
||||||
|
@ -43,7 +43,7 @@ main(void) {
|
|||||||
isc_buffer_t buf;
|
isc_buffer_t buf;
|
||||||
|
|
||||||
isc_mem_t *mctx = NULL;
|
isc_mem_t *mctx = NULL;
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create("test", &mctx);
|
||||||
|
|
||||||
static dns_fixedname_t fixedname[65536];
|
static dns_fixedname_t fixedname[65536];
|
||||||
unsigned int count = 0;
|
unsigned int count = 0;
|
||||||
|
@ -420,7 +420,7 @@ main(int argc, char *argv[]) {
|
|||||||
|
|
||||||
isc_rwlock_init(&rwl);
|
isc_rwlock_init(&rwl);
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create("test", &mctx);
|
||||||
|
|
||||||
if (argc != 2) {
|
if (argc != 2) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
@ -494,7 +494,7 @@ main(int argc, char *argv[]) {
|
|||||||
isc_mem_t *mem = NULL;
|
isc_mem_t *mem = NULL;
|
||||||
void *map = NULL;
|
void *map = NULL;
|
||||||
|
|
||||||
isc_mem_create(&mem);
|
isc_mem_create("test", &mem);
|
||||||
map = fun->new(mem);
|
map = fun->new(mem);
|
||||||
|
|
||||||
size_t nitems = lines / (nthreads + 1);
|
size_t nitems = lines / (nthreads + 1);
|
||||||
|
@ -161,7 +161,7 @@ main(int argc, char *argv[]) {
|
|||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create("test", &mctx);
|
||||||
|
|
||||||
filename = argv[0];
|
filename = argv[0];
|
||||||
result = isc_file_getsize(filename, &fileoff);
|
result = isc_file_getsize(filename, &fileoff);
|
||||||
|
@ -197,7 +197,7 @@ main(int argc, char **argv) {
|
|||||||
usage();
|
usage();
|
||||||
}
|
}
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create("test", &mctx);
|
||||||
|
|
||||||
dns_qp_create(mctx, &methods, NULL, &qp);
|
dns_qp_create(mctx, &methods, NULL, &qp);
|
||||||
|
|
||||||
|
@ -876,7 +876,7 @@ main(void) {
|
|||||||
}
|
}
|
||||||
INSIST(nloops > 1);
|
INSIST(nloops > 1);
|
||||||
|
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create("test", &mctx);
|
||||||
isc_mem_setdestroycheck(mctx, true);
|
isc_mem_setdestroycheck(mctx, true);
|
||||||
init_logging();
|
init_logging();
|
||||||
init_items(mctx);
|
init_items(mctx);
|
||||||
|
@ -132,7 +132,7 @@ ISC_LOOP_TEST_IMPL(overmempurge_bigrdata) {
|
|||||||
isc_stdtime_t now = isc_stdtime_now();
|
isc_stdtime_t now = isc_stdtime_now();
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
isc_mem_create(&mctx2);
|
isc_mem_create("test", &mctx2);
|
||||||
|
|
||||||
result = dns_db_create(mctx2, CACHEDB_DEFAULT, dns_rootname,
|
result = dns_db_create(mctx2, CACHEDB_DEFAULT, dns_rootname,
|
||||||
dns_dbtype_cache, dns_rdataclass_in, 0, NULL,
|
dns_dbtype_cache, dns_rdataclass_in, 0, NULL,
|
||||||
@ -183,7 +183,7 @@ ISC_LOOP_TEST_IMPL(overmempurge_longname) {
|
|||||||
isc_stdtime_t now = isc_stdtime_now();
|
isc_stdtime_t now = isc_stdtime_now();
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
isc_mem_create(&mctx2);
|
isc_mem_create("test", &mctx2);
|
||||||
|
|
||||||
result = dns_db_create(mctx2, CACHEDB_DEFAULT, dns_rootname,
|
result = dns_db_create(mctx2, CACHEDB_DEFAULT, dns_rootname,
|
||||||
dns_dbtype_cache, dns_rdataclass_in, 0, NULL,
|
dns_dbtype_cache, dns_rdataclass_in, 0, NULL,
|
||||||
|
@ -56,8 +56,8 @@ ISC_RUN_TEST_IMPL(isc_mem_get) {
|
|||||||
unsigned int i, j;
|
unsigned int i, j;
|
||||||
int rval;
|
int rval;
|
||||||
|
|
||||||
isc_mempool_create(mctx, 24, &mp1);
|
isc_mempool_create(mctx, 24, "mp1", &mp1);
|
||||||
isc_mempool_create(mctx, 31, &mp2);
|
isc_mempool_create(mctx, 31, "mp2", &mp2);
|
||||||
|
|
||||||
isc_mempool_setfreemax(mp1, MP1_FREEMAX);
|
isc_mempool_setfreemax(mp1, MP1_FREEMAX);
|
||||||
isc_mempool_setfillcount(mp1, MP1_FILLCNT);
|
isc_mempool_setfillcount(mp1, MP1_FILLCNT);
|
||||||
@ -114,7 +114,7 @@ ISC_RUN_TEST_IMPL(isc_mem_get) {
|
|||||||
isc_mempool_destroy(&mp1);
|
isc_mempool_destroy(&mp1);
|
||||||
isc_mempool_destroy(&mp2);
|
isc_mempool_destroy(&mp2);
|
||||||
|
|
||||||
isc_mempool_create(mctx, 2, &mp1);
|
isc_mempool_create(mctx, 2, "mp1", &mp1);
|
||||||
|
|
||||||
tmp = isc_mempool_get(mp1);
|
tmp = isc_mempool_get(mp1);
|
||||||
assert_non_null(tmp);
|
assert_non_null(tmp);
|
||||||
@ -183,7 +183,7 @@ ISC_RUN_TEST_IMPL(isc_mem_inuse) {
|
|||||||
void *ptr;
|
void *ptr;
|
||||||
|
|
||||||
mctx2 = NULL;
|
mctx2 = NULL;
|
||||||
isc_mem_create(&mctx2);
|
isc_mem_create("test", &mctx2);
|
||||||
|
|
||||||
before = isc_mem_inuse(mctx2);
|
before = isc_mem_inuse(mctx2);
|
||||||
ptr = isc_mem_allocate(mctx2, 1024000);
|
ptr = isc_mem_allocate(mctx2, 1024000);
|
||||||
@ -291,7 +291,7 @@ ISC_RUN_TEST_IMPL(isc_mem_reallocate) {
|
|||||||
|
|
||||||
ISC_RUN_TEST_IMPL(isc_mem_overmem) {
|
ISC_RUN_TEST_IMPL(isc_mem_overmem) {
|
||||||
isc_mem_t *omctx = NULL;
|
isc_mem_t *omctx = NULL;
|
||||||
isc_mem_create(&omctx);
|
isc_mem_create("test", &omctx);
|
||||||
assert_non_null(omctx);
|
assert_non_null(omctx);
|
||||||
|
|
||||||
isc_mem_setwater(omctx, 1024, 512);
|
isc_mem_setwater(omctx, 1024, 512);
|
||||||
@ -337,7 +337,7 @@ ISC_RUN_TEST_IMPL(isc_mem_noflags) {
|
|||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
isc_mem_debugging = 0;
|
isc_mem_debugging = 0;
|
||||||
isc_mem_create(&mctx2);
|
isc_mem_create("test", &mctx2);
|
||||||
ptr = isc_mem_get(mctx2, 2048);
|
ptr = isc_mem_get(mctx2, 2048);
|
||||||
assert_non_null(ptr);
|
assert_non_null(ptr);
|
||||||
isc__mem_printactive(mctx2, f);
|
isc__mem_printactive(mctx2, f);
|
||||||
@ -373,7 +373,7 @@ ISC_RUN_TEST_IMPL(isc_mem_recordflag) {
|
|||||||
result = isc_stdio_open("mem.output", "w", &f);
|
result = isc_stdio_open("mem.output", "w", &f);
|
||||||
assert_int_equal(result, ISC_R_SUCCESS);
|
assert_int_equal(result, ISC_R_SUCCESS);
|
||||||
|
|
||||||
isc_mem_create(&mctx2);
|
isc_mem_create("test", &mctx2);
|
||||||
|
|
||||||
ptr = isc_mem_get(mctx2, 2048);
|
ptr = isc_mem_get(mctx2, 2048);
|
||||||
assert_non_null(ptr);
|
assert_non_null(ptr);
|
||||||
@ -437,7 +437,7 @@ ISC_RUN_TEST_IMPL(isc_mem_traceflag) {
|
|||||||
assert_non_null(f);
|
assert_non_null(f);
|
||||||
|
|
||||||
isc_mem_debugging = ISC_MEM_DEBUGRECORD | ISC_MEM_DEBUGTRACE;
|
isc_mem_debugging = ISC_MEM_DEBUGRECORD | ISC_MEM_DEBUGTRACE;
|
||||||
isc_mem_create(&mctx2);
|
isc_mem_create("test", &mctx2);
|
||||||
ptr = isc_mem_get(mctx2, 2048);
|
ptr = isc_mem_get(mctx2, 2048);
|
||||||
assert_non_null(ptr);
|
assert_non_null(ptr);
|
||||||
isc__mem_printactive(mctx2, f);
|
isc__mem_printactive(mctx2, f);
|
||||||
|
@ -72,7 +72,7 @@ setup_workers(void **state ISC_ATTR_UNUSED) {
|
|||||||
int
|
int
|
||||||
setup_mctx(void **state ISC_ATTR_UNUSED) {
|
setup_mctx(void **state ISC_ATTR_UNUSED) {
|
||||||
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
|
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
|
||||||
isc_mem_create(&mctx);
|
isc_mem_create("test", &mctx);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user