mirror of
https://github.com/isc-projects/bind9.git
synced 2026-02-19 02:28:27 -05:00
chg: dev: Add and use global memory context called isc_g_mctx
Instead of having individual memory contexts scattered across different files and called different names, add a single memory context called isc_g_mctx that replaces named_g_mctx and various other global memory contexts in various utilities and tests. Merge branch 'ondrej/add-global-isc_g_mctx-instance' into 'main' See merge request isc-projects/bind9!10737
This commit is contained in:
commit
999d7a5558
113 changed files with 1439 additions and 1394 deletions
|
|
@ -93,7 +93,6 @@ dns_zoneopt_t zone_options = DNS_ZONEOPT_CHECKNS | DNS_ZONEOPT_CHECKMX |
|
|||
DNS_ZONEOPT_WARNMXCNAME | DNS_ZONEOPT_WARNSRVCNAME;
|
||||
|
||||
static isc_symtab_t *symtab = NULL;
|
||||
static isc_mem_t *sym_mctx;
|
||||
|
||||
static void
|
||||
freekey(char *key, unsigned int type, isc_symvalue_t value, void *userarg) {
|
||||
|
|
@ -107,21 +106,18 @@ add(char *key, int value) {
|
|||
isc_result_t result;
|
||||
isc_symvalue_t symvalue;
|
||||
|
||||
if (sym_mctx == NULL) {
|
||||
isc_mem_create("check-tool", &sym_mctx);
|
||||
}
|
||||
|
||||
if (symtab == NULL) {
|
||||
isc_symtab_create(sym_mctx, freekey, sym_mctx, false, &symtab);
|
||||
isc_symtab_create(isc_g_mctx, freekey, isc_g_mctx, false,
|
||||
&symtab);
|
||||
}
|
||||
|
||||
key = isc_mem_strdup(sym_mctx, key);
|
||||
key = isc_mem_strdup(isc_g_mctx, key);
|
||||
|
||||
symvalue.as_pointer = NULL;
|
||||
result = isc_symtab_define(symtab, key, value, symvalue,
|
||||
isc_symexists_reject);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_mem_free(sym_mctx, key);
|
||||
isc_mem_free(isc_g_mctx, key);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ get_checknames(const cfg_obj_t **maps, const cfg_obj_t **obj) {
|
|||
}
|
||||
|
||||
static isc_result_t
|
||||
configure_hint(const char *zfile, const char *zclass, isc_mem_t *mctx) {
|
||||
configure_hint(const char *zfile, const char *zclass) {
|
||||
isc_result_t result;
|
||||
dns_db_t *db = NULL;
|
||||
dns_rdataclass_t rdclass;
|
||||
|
|
@ -156,7 +156,7 @@ configure_hint(const char *zfile, const char *zclass, isc_mem_t *mctx) {
|
|||
return result;
|
||||
}
|
||||
|
||||
result = dns_rootns_create(mctx, rdclass, zfile, &db);
|
||||
result = dns_rootns_create(isc_g_mctx, rdclass, zfile, &db);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
|
|
@ -168,8 +168,7 @@ configure_hint(const char *zfile, const char *zclass, isc_mem_t *mctx) {
|
|||
/*% configure the zone */
|
||||
static isc_result_t
|
||||
configure_zone(const char *vclass, const char *view, const cfg_obj_t *zconfig,
|
||||
const cfg_obj_t *vconfig, const cfg_obj_t *config,
|
||||
isc_mem_t *mctx, bool list) {
|
||||
const cfg_obj_t *vconfig, const cfg_obj_t *config, bool list) {
|
||||
int i = 0;
|
||||
isc_result_t result;
|
||||
const char *zclass;
|
||||
|
|
@ -258,7 +257,7 @@ configure_zone(const char *vclass, const char *view, const cfg_obj_t *zconfig,
|
|||
* master and redirect
|
||||
*/
|
||||
if (strcasecmp(cfg_obj_asstring(typeobj), "hint") == 0) {
|
||||
return configure_hint(zfile, zclass, mctx);
|
||||
return configure_hint(zfile, zclass);
|
||||
} else if ((strcasecmp(cfg_obj_asstring(typeobj), "primary") != 0) &&
|
||||
(strcasecmp(cfg_obj_asstring(typeobj), "master") != 0) &&
|
||||
(strcasecmp(cfg_obj_asstring(typeobj), "redirect") != 0))
|
||||
|
|
@ -453,8 +452,8 @@ configure_zone(const char *vclass, const char *view, const cfg_obj_t *zconfig,
|
|||
zone_options |= DNS_ZONEOPT_CHECKTTL;
|
||||
}
|
||||
|
||||
result = load_zone(mctx, zname, zfile, masterformat, zclass, maxttl,
|
||||
NULL);
|
||||
result = load_zone(isc_g_mctx, zname, zfile, masterformat, zclass,
|
||||
maxttl, NULL);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fprintf(stderr, "%s/%s/%s: %s\n", view, zname, zclass,
|
||||
isc_result_totext(result));
|
||||
|
|
@ -465,7 +464,7 @@ configure_zone(const char *vclass, const char *view, const cfg_obj_t *zconfig,
|
|||
/*% configure a view */
|
||||
static isc_result_t
|
||||
configure_view(const char *vclass, const char *view, const cfg_obj_t *config,
|
||||
const cfg_obj_t *vconfig, isc_mem_t *mctx, bool list) {
|
||||
const cfg_obj_t *vconfig, bool list) {
|
||||
const cfg_obj_t *voptions = NULL;
|
||||
const cfg_obj_t *zonelist = NULL;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
|
|
@ -486,7 +485,7 @@ configure_view(const char *vclass, const char *view, const cfg_obj_t *config,
|
|||
CFG_LIST_FOREACH (zonelist, element) {
|
||||
const cfg_obj_t *zconfig = cfg_listelt_value(element);
|
||||
tresult = configure_zone(vclass, view, zconfig, vconfig, config,
|
||||
mctx, list);
|
||||
list);
|
||||
if (tresult != ISC_R_SUCCESS) {
|
||||
result = tresult;
|
||||
}
|
||||
|
|
@ -510,8 +509,7 @@ config_getclass(const cfg_obj_t *classobj, dns_rdataclass_t defclass,
|
|||
|
||||
/*% load zones from the configuration */
|
||||
static isc_result_t
|
||||
load_zones_fromconfig(const cfg_obj_t *config, isc_mem_t *mctx,
|
||||
bool list_zones) {
|
||||
load_zones_fromconfig(const cfg_obj_t *config, bool list_zones) {
|
||||
const cfg_obj_t *views = NULL;
|
||||
const cfg_obj_t *vconfig = NULL;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
|
|
@ -544,7 +542,7 @@ load_zones_fromconfig(const cfg_obj_t *config, isc_mem_t *mctx,
|
|||
|
||||
dns_rdataclass_format(viewclass, buf, sizeof(buf));
|
||||
vname = cfg_obj_asstring(cfg_tuple_get(vconfig, "name"));
|
||||
tresult = configure_view(buf, vname, config, vconfig, mctx,
|
||||
tresult = configure_view(buf, vname, config, vconfig,
|
||||
list_zones);
|
||||
if (tresult != ISC_R_SUCCESS) {
|
||||
result = tresult;
|
||||
|
|
@ -552,7 +550,7 @@ load_zones_fromconfig(const cfg_obj_t *config, isc_mem_t *mctx,
|
|||
}
|
||||
|
||||
if (views == NULL) {
|
||||
tresult = configure_view("IN", "_default", config, NULL, mctx,
|
||||
tresult = configure_view("IN", "_default", config, NULL,
|
||||
list_zones);
|
||||
if (tresult != ISC_R_SUCCESS) {
|
||||
result = tresult;
|
||||
|
|
@ -579,7 +577,6 @@ main(int argc, char **argv) {
|
|||
cfg_parser_t *parser = NULL;
|
||||
cfg_obj_t *config = NULL;
|
||||
const char *conffile = NULL;
|
||||
isc_mem_t *mctx = NULL;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
bool load_zones = false;
|
||||
bool list_zones = false;
|
||||
|
|
@ -602,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:
|
||||
|
|
@ -619,8 +616,6 @@ main(int argc, char **argv) {
|
|||
}
|
||||
isc_commandline_reset = true;
|
||||
|
||||
isc_mem_create(isc_commandline_progname, &mctx);
|
||||
|
||||
while ((c = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != EOF) {
|
||||
switch (c) {
|
||||
case 'a':
|
||||
|
|
@ -691,7 +686,6 @@ main(int argc, char **argv) {
|
|||
}
|
||||
FALLTHROUGH;
|
||||
case 'h':
|
||||
isc_mem_detach(&mctx);
|
||||
usage();
|
||||
|
||||
default:
|
||||
|
|
@ -714,7 +708,6 @@ main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
if (isc_commandline_index + 1 < argc) {
|
||||
isc_mem_detach(&mctx);
|
||||
usage();
|
||||
}
|
||||
if (argv[isc_commandline_index] != NULL) {
|
||||
|
|
@ -726,7 +719,7 @@ main(int argc, char **argv) {
|
|||
|
||||
CHECK(setup_logging(stdout));
|
||||
|
||||
CHECK(cfg_parser_create(mctx, &parser));
|
||||
CHECK(cfg_parser_create(isc_g_mctx, &parser));
|
||||
|
||||
if (nodeprecate) {
|
||||
cfg_parser_setflags(parser, CFG_PCTX_NODEPRECATED, true);
|
||||
|
|
@ -737,9 +730,9 @@ main(int argc, char **argv) {
|
|||
cfg_parser_setcallback(parser, directory_callback, NULL);
|
||||
|
||||
CHECK(cfg_parse_file(parser, conffile, &cfg_type_namedconf, &config));
|
||||
CHECK(isccfg_check_namedconf(config, checkflags, mctx));
|
||||
CHECK(isccfg_check_namedconf(config, checkflags, isc_g_mctx));
|
||||
if (load_zones || list_zones) {
|
||||
CHECK(load_zones_fromconfig(config, mctx, list_zones));
|
||||
CHECK(load_zones_fromconfig(config, list_zones));
|
||||
}
|
||||
|
||||
if (print) {
|
||||
|
|
@ -755,9 +748,5 @@ cleanup:
|
|||
cfg_parser_destroy(&parser);
|
||||
}
|
||||
|
||||
if (mctx != NULL) {
|
||||
isc_mem_detach(&mctx);
|
||||
}
|
||||
|
||||
return result == ISC_R_SUCCESS ? 0 : 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@
|
|||
#include "check-tool.h"
|
||||
|
||||
static int quiet = 0;
|
||||
static isc_mem_t *mctx = NULL;
|
||||
dns_zone_t *zone = NULL;
|
||||
dns_zonetype_t zonetype = dns_zone_primary;
|
||||
static int dumpzone = 0;
|
||||
|
|
@ -110,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);
|
||||
|
|
@ -519,7 +513,6 @@ main(int argc, char **argv) {
|
|||
usage();
|
||||
}
|
||||
|
||||
isc_mem_create(isc_commandline_progname, &mctx);
|
||||
if (!quiet) {
|
||||
RUNTIME_CHECK(setup_logging(errout) == ISC_R_SUCCESS);
|
||||
}
|
||||
|
|
@ -535,7 +528,7 @@ main(int argc, char **argv) {
|
|||
|
||||
isc_commandline_index++;
|
||||
|
||||
result = load_zone(mctx, origin, filename, inputformat, classname,
|
||||
result = load_zone(isc_g_mctx, origin, filename, inputformat, classname,
|
||||
maxttl, &zone);
|
||||
|
||||
if (snset) {
|
||||
|
|
@ -561,7 +554,6 @@ main(int argc, char **argv) {
|
|||
fprintf(errout, "OK\n");
|
||||
}
|
||||
destroy();
|
||||
isc_mem_detach(&mctx);
|
||||
|
||||
return (result == ISC_R_SUCCESS) ? 0 : 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,7 +87,6 @@ main(int argc, char **argv) {
|
|||
bool show_final_mem = false;
|
||||
isc_buffer_t key_txtbuffer;
|
||||
char key_txtsecret[256];
|
||||
isc_mem_t *mctx = NULL;
|
||||
const char *keyname = NULL;
|
||||
const char *serveraddr = NULL;
|
||||
dns_secalg_t alg;
|
||||
|
|
@ -146,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':
|
||||
|
|
@ -219,10 +218,9 @@ main(int argc, char **argv) {
|
|||
}
|
||||
algname = dst_hmac_algorithm_totext(alg);
|
||||
|
||||
isc_mem_create(isc_commandline_progname, &mctx);
|
||||
isc_buffer_init(&key_txtbuffer, &key_txtsecret, sizeof(key_txtsecret));
|
||||
|
||||
generate_key(mctx, alg, keysize, &key_txtbuffer);
|
||||
generate_key(isc_g_mctx, alg, keysize, &key_txtbuffer);
|
||||
|
||||
if (keyonly) {
|
||||
write_key_file(keyfile, chrootdir == NULL ? user : NULL,
|
||||
|
|
@ -234,7 +232,7 @@ main(int argc, char **argv) {
|
|||
if (chrootdir != NULL) {
|
||||
char *buf;
|
||||
len = strlen(chrootdir) + strlen(keyfile) + 2;
|
||||
buf = isc_mem_get(mctx, len);
|
||||
buf = isc_mem_get(isc_g_mctx, len);
|
||||
snprintf(buf, len, "%s%s%s", chrootdir,
|
||||
(*keyfile != '/') ? "/" : "", keyfile);
|
||||
|
||||
|
|
@ -242,7 +240,7 @@ main(int argc, char **argv) {
|
|||
if (!quiet) {
|
||||
printf("wrote key file \"%s\"\n", buf);
|
||||
}
|
||||
isc_mem_put(mctx, buf, len);
|
||||
isc_mem_put(isc_g_mctx, buf, len);
|
||||
}
|
||||
} else {
|
||||
printf("\
|
||||
|
|
@ -280,10 +278,8 @@ options {\n\
|
|||
}
|
||||
|
||||
if (show_final_mem) {
|
||||
isc_mem_stats(mctx, stderr);
|
||||
isc_mem_stats(isc_g_mctx, stderr);
|
||||
}
|
||||
|
||||
isc_mem_detach(&mctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,7 +84,6 @@ main(int argc, char **argv) {
|
|||
bool quiet = false;
|
||||
isc_buffer_t key_txtbuffer;
|
||||
char key_txtsecret[256];
|
||||
isc_mem_t *mctx = NULL;
|
||||
const char *keyname = NULL;
|
||||
const char *zone = NULL;
|
||||
const char *self_domain = NULL;
|
||||
|
|
@ -131,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;
|
||||
|
|
@ -195,8 +194,6 @@ main(int argc, char **argv) {
|
|||
/* Use canonical algorithm name */
|
||||
algname = dst_hmac_algorithm_totext(alg);
|
||||
|
||||
isc_mem_create(isc_commandline_progname, &mctx);
|
||||
|
||||
if (keyname == NULL) {
|
||||
const char *suffix = NULL;
|
||||
|
||||
|
|
@ -209,7 +206,7 @@ main(int argc, char **argv) {
|
|||
}
|
||||
if (suffix != NULL) {
|
||||
len = strlen(keyname) + strlen(suffix) + 2;
|
||||
keybuf = isc_mem_get(mctx, len);
|
||||
keybuf = isc_mem_get(isc_g_mctx, len);
|
||||
snprintf(keybuf, len, "%s.%s", keyname, suffix);
|
||||
keyname = (const char *)keybuf;
|
||||
}
|
||||
|
|
@ -217,7 +214,7 @@ main(int argc, char **argv) {
|
|||
|
||||
isc_buffer_init(&key_txtbuffer, &key_txtsecret, sizeof(key_txtsecret));
|
||||
|
||||
generate_key(mctx, alg, keysize, &key_txtbuffer);
|
||||
generate_key(isc_g_mctx, alg, keysize, &key_txtbuffer);
|
||||
|
||||
if (!quiet) {
|
||||
printf("\
|
||||
|
|
@ -272,14 +269,12 @@ nsupdate -k <keyfile>\n");
|
|||
}
|
||||
|
||||
if (keybuf != NULL) {
|
||||
isc_mem_put(mctx, keybuf, len);
|
||||
isc_mem_put(isc_g_mctx, keybuf, len);
|
||||
}
|
||||
|
||||
if (show_final_mem) {
|
||||
isc_mem_stats(mctx, stderr);
|
||||
isc_mem_stats(isc_g_mctx, stderr);
|
||||
}
|
||||
|
||||
isc_mem_detach(&mctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
106
bin/delv/delv.c
106
bin/delv/delv.c
|
|
@ -97,7 +97,6 @@
|
|||
#define MAX_RESTARTS 11
|
||||
|
||||
/* Variables used internally by delv. */
|
||||
static isc_mem_t *mctx = NULL;
|
||||
static dns_view_t *view = NULL;
|
||||
static ns_server_t *sctx = NULL;
|
||||
static ns_interface_t *ifp = NULL;
|
||||
|
|
@ -465,7 +464,7 @@ printdata(dns_rdataset_t *rdataset, dns_name_t *owner) {
|
|||
}
|
||||
|
||||
do {
|
||||
t = isc_mem_get(mctx, len);
|
||||
t = isc_mem_get(isc_g_mctx, len);
|
||||
|
||||
isc_buffer_init(&target, t, len);
|
||||
if (short_form) {
|
||||
|
|
@ -502,7 +501,7 @@ printdata(dns_rdataset_t *rdataset, dns_name_t *owner) {
|
|||
}
|
||||
|
||||
if (result == ISC_R_NOSPACE) {
|
||||
isc_mem_put(mctx, t, len);
|
||||
isc_mem_put(isc_g_mctx, t, len);
|
||||
len += 1024;
|
||||
} else if (result == ISC_R_NOMORE) {
|
||||
result = ISC_R_SUCCESS;
|
||||
|
|
@ -516,7 +515,7 @@ printdata(dns_rdataset_t *rdataset, dns_name_t *owner) {
|
|||
|
||||
cleanup:
|
||||
if (t != NULL) {
|
||||
isc_mem_put(mctx, t, len);
|
||||
isc_mem_put(isc_g_mctx, t, len);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -554,13 +553,16 @@ setup_style(void) {
|
|||
|
||||
if (multiline || (nottl && noclass)) {
|
||||
result = dns_master_stylecreate(&style, styleflags, 24, 24, 24,
|
||||
32, 80, 8, splitwidth, mctx);
|
||||
32, 80, 8, splitwidth,
|
||||
isc_g_mctx);
|
||||
} else if (nottl || noclass) {
|
||||
result = dns_master_stylecreate(&style, styleflags, 24, 24, 32,
|
||||
40, 80, 8, splitwidth, mctx);
|
||||
40, 80, 8, splitwidth,
|
||||
isc_g_mctx);
|
||||
} else {
|
||||
result = dns_master_stylecreate(&style, styleflags, 24, 32, 40,
|
||||
48, 80, 8, splitwidth, mctx);
|
||||
48, 80, 8, splitwidth,
|
||||
isc_g_mctx);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
@ -812,14 +814,14 @@ setup_dnsseckeys(dns_client_t *client, dns_view_t *toview) {
|
|||
}
|
||||
|
||||
if (trust_anchor == NULL) {
|
||||
trust_anchor = isc_mem_strdup(mctx, ".");
|
||||
trust_anchor = isc_mem_strdup(isc_g_mctx, ".");
|
||||
}
|
||||
|
||||
if (trust_anchor != NULL) {
|
||||
CHECK(convert_name(&afn, &anchor_name, trust_anchor));
|
||||
}
|
||||
|
||||
CHECK(cfg_parser_create(mctx, &parser));
|
||||
CHECK(cfg_parser_create(isc_g_mctx, &parser));
|
||||
|
||||
if (anchorfile != NULL) {
|
||||
if (access(anchorfile, R_OK) != 0) {
|
||||
|
|
@ -886,7 +888,7 @@ addserver(dns_client_t *client) {
|
|||
if (!use_ipv4) {
|
||||
fatal("Use of IPv4 disabled by -6");
|
||||
}
|
||||
sa = isc_mem_get(mctx, sizeof(*sa));
|
||||
sa = isc_mem_get(isc_g_mctx, sizeof(*sa));
|
||||
ISC_LINK_INIT(sa, link);
|
||||
isc_sockaddr_fromin(sa, &in4, destport);
|
||||
ISC_LIST_APPEND(servers, sa, link);
|
||||
|
|
@ -894,7 +896,7 @@ addserver(dns_client_t *client) {
|
|||
if (!use_ipv6) {
|
||||
fatal("Use of IPv6 disabled by -4");
|
||||
}
|
||||
sa = isc_mem_get(mctx, sizeof(*sa));
|
||||
sa = isc_mem_get(isc_g_mctx, sizeof(*sa));
|
||||
ISC_LINK_INIT(sa, link);
|
||||
isc_sockaddr_fromin6(sa, &in6, destport);
|
||||
ISC_LIST_APPEND(servers, sa, link);
|
||||
|
|
@ -923,7 +925,7 @@ addserver(dns_client_t *client) {
|
|||
{
|
||||
continue;
|
||||
}
|
||||
sa = isc_mem_get(mctx, sizeof(*sa));
|
||||
sa = isc_mem_get(isc_g_mctx, sizeof(*sa));
|
||||
*sa = (isc_sockaddr_t){
|
||||
.length = (unsigned int)cur->ai_addrlen,
|
||||
};
|
||||
|
|
@ -940,7 +942,7 @@ addserver(dns_client_t *client) {
|
|||
cleanup:
|
||||
ISC_LIST_FOREACH (servers, s, link) {
|
||||
ISC_LIST_UNLINK(servers, s, link);
|
||||
isc_mem_put(mctx, s, sizeof(*s));
|
||||
isc_mem_put(isc_g_mctx, s, sizeof(*s));
|
||||
}
|
||||
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
|
|
@ -957,7 +959,7 @@ findserver(dns_client_t *client) {
|
|||
irs_resconf_t *resconf = NULL;
|
||||
isc_sockaddrlist_t *nameservers = NULL;
|
||||
|
||||
result = irs_resconf_load(mctx, "/etc/resolv.conf", &resconf);
|
||||
result = irs_resconf_load(isc_g_mctx, "/etc/resolv.conf", &resconf);
|
||||
if (result != ISC_R_SUCCESS && result != ISC_R_FILENOTFOUND) {
|
||||
delv_log(ISC_LOG_ERROR, "irs_resconf_load: %s",
|
||||
isc_result_totext(result));
|
||||
|
|
@ -979,7 +981,7 @@ findserver(dns_client_t *client) {
|
|||
|
||||
/* Incompatible protocol family */
|
||||
ISC_LIST_UNLINK(*nameservers, sa, link);
|
||||
isc_mem_put(mctx, sa, sizeof(*sa));
|
||||
isc_mem_put(isc_g_mctx, sa, sizeof(*sa));
|
||||
}
|
||||
|
||||
/* None found, use localhost */
|
||||
|
|
@ -987,7 +989,8 @@ findserver(dns_client_t *client) {
|
|||
if (use_ipv4) {
|
||||
struct in_addr localhost;
|
||||
localhost.s_addr = htonl(INADDR_LOOPBACK);
|
||||
isc_sockaddr_t *sa = isc_mem_get(mctx, sizeof(*sa));
|
||||
isc_sockaddr_t *sa = isc_mem_get(isc_g_mctx,
|
||||
sizeof(*sa));
|
||||
isc_sockaddr_fromin(sa, &localhost, destport);
|
||||
|
||||
ISC_LINK_INIT(sa, link);
|
||||
|
|
@ -995,7 +998,8 @@ findserver(dns_client_t *client) {
|
|||
}
|
||||
|
||||
if (use_ipv6) {
|
||||
isc_sockaddr_t *sa = isc_mem_get(mctx, sizeof(*sa));
|
||||
isc_sockaddr_t *sa = isc_mem_get(isc_g_mctx,
|
||||
sizeof(*sa));
|
||||
isc_sockaddr_fromin6(sa, &in6addr_loopback, destport);
|
||||
|
||||
ISC_LINK_INIT(sa, link);
|
||||
|
|
@ -1233,7 +1237,8 @@ plus_option(char *option) {
|
|||
}
|
||||
root_validation = state;
|
||||
if (value != NULL) {
|
||||
trust_anchor = isc_mem_strdup(mctx, value);
|
||||
trust_anchor = isc_mem_strdup(isc_g_mctx,
|
||||
value);
|
||||
}
|
||||
break;
|
||||
case 'r': /* rrcomments */
|
||||
|
|
@ -1445,7 +1450,7 @@ dash_option(char *option, char *next, bool *open_type_class) {
|
|||
}
|
||||
switch (opt) {
|
||||
case 'a':
|
||||
anchorfile = isc_mem_strdup(mctx, value);
|
||||
anchorfile = isc_mem_strdup(isc_g_mctx, value);
|
||||
return value_from_next;
|
||||
case 'b':
|
||||
hash = strchr(value, '#');
|
||||
|
|
@ -1519,9 +1524,9 @@ dash_option(char *option, char *next, bool *open_type_class) {
|
|||
case 'q':
|
||||
if (curqname != NULL) {
|
||||
warn("extra query name");
|
||||
isc_mem_free(mctx, curqname);
|
||||
isc_mem_free(isc_g_mctx, curqname);
|
||||
}
|
||||
curqname = isc_mem_strdup(mctx, value);
|
||||
curqname = isc_mem_strdup(isc_g_mctx, value);
|
||||
return value_from_next;
|
||||
case 't':
|
||||
*open_type_class = false;
|
||||
|
|
@ -1548,10 +1553,10 @@ dash_option(char *option, char *next, bool *open_type_class) {
|
|||
result = get_reverse(textname, sizeof(textname), value, false);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
if (curqname != NULL) {
|
||||
isc_mem_free(mctx, curqname);
|
||||
isc_mem_free(isc_g_mctx, curqname);
|
||||
warn("extra query name");
|
||||
}
|
||||
curqname = isc_mem_strdup(mctx, textname);
|
||||
curqname = isc_mem_strdup(isc_g_mctx, textname);
|
||||
if (typeset) {
|
||||
warn("extra query type");
|
||||
}
|
||||
|
|
@ -1594,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) {
|
||||
|
|
@ -1708,7 +1713,7 @@ parse_args(int argc, char **argv) {
|
|||
}
|
||||
|
||||
if (curqname == NULL) {
|
||||
curqname = isc_mem_strdup(mctx, argv[0]);
|
||||
curqname = isc_mem_strdup(isc_g_mctx, argv[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1727,7 +1732,7 @@ parse_args(int argc, char **argv) {
|
|||
}
|
||||
|
||||
if (curqname == NULL) {
|
||||
qname = isc_mem_strdup(mctx, ".");
|
||||
qname = isc_mem_strdup(isc_g_mctx, ".");
|
||||
|
||||
if (!typeset) {
|
||||
qtype = dns_rdatatype_ns;
|
||||
|
|
@ -1839,7 +1844,7 @@ resolve_cb(dns_client_t *client, const dns_name_t *query_name,
|
|||
}
|
||||
|
||||
dns_client_freeresanswer(client, namelist);
|
||||
isc_mem_put(mctx, namelist, sizeof(*namelist));
|
||||
isc_mem_put(isc_g_mctx, namelist, sizeof(*namelist));
|
||||
|
||||
dns_client_detach(&client);
|
||||
|
||||
|
|
@ -1856,7 +1861,7 @@ run_resolve(void *arg) {
|
|||
|
||||
UNUSED(arg);
|
||||
|
||||
namelist = isc_mem_get(mctx, sizeof(*namelist));
|
||||
namelist = isc_mem_get(isc_g_mctx, sizeof(*namelist));
|
||||
ISC_LIST_INIT(*namelist);
|
||||
|
||||
/* Construct QNAME */
|
||||
|
|
@ -1878,8 +1883,8 @@ run_resolve(void *arg) {
|
|||
}
|
||||
|
||||
/* Create client */
|
||||
CHECK(dns_client_create(mctx, 0, tlsctx_client_cache, &client, srcaddr4,
|
||||
srcaddr6));
|
||||
CHECK(dns_client_create(isc_g_mctx, 0, tlsctx_client_cache, &client,
|
||||
srcaddr4, srcaddr6));
|
||||
dns_client_setmaxrestarts(client, restarts);
|
||||
dns_client_setmaxqueries(client, maxtotal);
|
||||
|
||||
|
|
@ -1902,7 +1907,7 @@ cleanup:
|
|||
isc_result_totext(result));
|
||||
}
|
||||
|
||||
isc_mem_put(mctx, namelist, sizeof(*namelist));
|
||||
isc_mem_put(isc_g_mctx, namelist, sizeof(*namelist));
|
||||
isc_loopmgr_shutdown();
|
||||
|
||||
dns_client_detach(&client);
|
||||
|
|
@ -1946,7 +1951,7 @@ recvresponse(void *arg) {
|
|||
fatal("request event result: %s", isc_result_totext(result));
|
||||
}
|
||||
|
||||
dns_message_create(mctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE,
|
||||
dns_message_create(isc_g_mctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE,
|
||||
&response);
|
||||
|
||||
result = dns_request_getresponse(request, response,
|
||||
|
|
@ -2053,7 +2058,7 @@ sendquery(void *arg) {
|
|||
/* Construct query message */
|
||||
CHECK(convert_name(&qfn, &query_name, qname));
|
||||
|
||||
dns_message_create(mctx, NULL, NULL, DNS_MESSAGE_INTENTRENDER,
|
||||
dns_message_create(isc_g_mctx, NULL, NULL, DNS_MESSAGE_INTENTRENDER,
|
||||
&message);
|
||||
message->opcode = dns_opcode_query;
|
||||
message->flags = DNS_MESSAGEFLAG_RD | DNS_MESSAGEFLAG_AD;
|
||||
|
|
@ -2076,7 +2081,7 @@ sendquery(void *arg) {
|
|||
NULL, 0));
|
||||
CHECK(dns_message_setopt(message, opt));
|
||||
|
||||
CHECK(dns_requestmgr_create(mctx, dispatchmgr, NULL, NULL,
|
||||
CHECK(dns_requestmgr_create(isc_g_mctx, dispatchmgr, NULL, NULL,
|
||||
&requestmgr));
|
||||
|
||||
dns_view_attach(view, &(dns_view_t *){ NULL });
|
||||
|
|
@ -2129,9 +2134,9 @@ run_server(void *arg) {
|
|||
RUNTIME_CHECK(inet_pton(AF_INET, "127.0.0.1", &in));
|
||||
isc_sockaddr_fromin(&addr, &in, 0);
|
||||
|
||||
ns_server_create(mctx, matchview, &sctx);
|
||||
ns_server_create(isc_g_mctx, matchview, &sctx);
|
||||
|
||||
CHECK(dns_dispatchmgr_create(mctx, &dispatchmgr));
|
||||
CHECK(dns_dispatchmgr_create(isc_g_mctx, &dispatchmgr));
|
||||
|
||||
if (use_ipv4) {
|
||||
isc_sockaddr_any(&any);
|
||||
|
|
@ -2145,19 +2150,20 @@ run_server(void *arg) {
|
|||
CHECK(dns_dispatch_createudp(dispatchmgr, a, &dispatch6));
|
||||
}
|
||||
|
||||
CHECK(ns_interfacemgr_create(mctx, sctx, dispatchmgr, NULL,
|
||||
CHECK(ns_interfacemgr_create(isc_g_mctx, sctx, dispatchmgr, NULL,
|
||||
&interfacemgr));
|
||||
|
||||
dns_view_create(mctx, dispatchmgr, dns_rdataclass_in, "_default",
|
||||
dns_view_create(isc_g_mctx, dispatchmgr, dns_rdataclass_in, "_default",
|
||||
&view);
|
||||
CHECK(dns_cache_create(dns_rdataclass_in, "", mctx, &cache));
|
||||
CHECK(dns_cache_create(dns_rdataclass_in, "", isc_g_mctx, &cache));
|
||||
dns_view_setcache(view, cache, false);
|
||||
dns_cache_detach(&cache);
|
||||
dns_view_setdstport(view, destport);
|
||||
dns_view_setmaxrestarts(view, restarts);
|
||||
dns_view_setmaxqueries(view, maxtotal);
|
||||
|
||||
CHECK(dns_rootns_create(mctx, dns_rdataclass_in, hintfile, &roothints));
|
||||
CHECK(dns_rootns_create(isc_g_mctx, dns_rdataclass_in, hintfile,
|
||||
&roothints));
|
||||
dns_view_sethints(view, roothints);
|
||||
dns_db_detach(&roothints);
|
||||
|
||||
|
|
@ -2171,11 +2177,11 @@ run_server(void *arg) {
|
|||
dispatch6));
|
||||
dns_resolver_setmaxqueries(view->resolver, maxqueries);
|
||||
|
||||
isc_stats_create(mctx, &resstats, dns_resstatscounter_max);
|
||||
isc_stats_create(isc_g_mctx, &resstats, dns_resstatscounter_max);
|
||||
dns_resolver_setstats(view->resolver, resstats);
|
||||
isc_stats_detach(&resstats);
|
||||
|
||||
dns_rdatatypestats_create(mctx, &resquerystats);
|
||||
dns_rdatatypestats_create(isc_g_mctx, &resquerystats);
|
||||
dns_resolver_setquerystats(view->resolver, resquerystats);
|
||||
dns_stats_detach(&resquerystats);
|
||||
|
||||
|
|
@ -2212,7 +2218,7 @@ main(int argc, char *argv[]) {
|
|||
argc--;
|
||||
argv++;
|
||||
|
||||
isc_managers_create(&mctx, 1);
|
||||
isc_managers_create(1);
|
||||
loop = isc_loop_main();
|
||||
|
||||
parse_args(argc, argv);
|
||||
|
|
@ -2234,7 +2240,7 @@ main(int argc, char *argv[]) {
|
|||
server);
|
||||
}
|
||||
|
||||
isc_tlsctx_cache_create(mctx, &tlsctx_client_cache);
|
||||
isc_tlsctx_cache_create(isc_g_mctx, &tlsctx_client_cache);
|
||||
|
||||
isc_loop_setup(loop, fulltrace ? run_server : run_resolve, NULL);
|
||||
isc_loopmgr_run();
|
||||
|
|
@ -2244,19 +2250,19 @@ cleanup:
|
|||
isc_tlsctx_cache_detach(&tlsctx_client_cache);
|
||||
}
|
||||
if (trust_anchor != NULL) {
|
||||
isc_mem_free(mctx, trust_anchor);
|
||||
isc_mem_free(isc_g_mctx, trust_anchor);
|
||||
}
|
||||
if (anchorfile != NULL) {
|
||||
isc_mem_free(mctx, anchorfile);
|
||||
isc_mem_free(isc_g_mctx, anchorfile);
|
||||
}
|
||||
if (qname != NULL) {
|
||||
isc_mem_free(mctx, qname);
|
||||
isc_mem_free(isc_g_mctx, qname);
|
||||
}
|
||||
if (style != NULL) {
|
||||
dns_master_styledestroy(&style, mctx);
|
||||
dns_master_styledestroy(&style, isc_g_mctx);
|
||||
}
|
||||
|
||||
isc_managers_destroy(&mctx);
|
||||
isc_managers_destroy();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -707,13 +707,16 @@ printmessage(dig_query_t *query, const isc_buffer_t *msgbuf, dns_message_t *msg,
|
|||
(query->lookup->nottl && query->lookup->noclass))
|
||||
{
|
||||
result = dns_master_stylecreate(&style, styleflags, 24, 24, 24,
|
||||
32, 80, 8, splitwidth, mctx);
|
||||
32, 80, 8, splitwidth,
|
||||
isc_g_mctx);
|
||||
} else if (query->lookup->nottl || query->lookup->noclass) {
|
||||
result = dns_master_stylecreate(&style, styleflags, 24, 24, 32,
|
||||
40, 80, 8, splitwidth, mctx);
|
||||
40, 80, 8, splitwidth,
|
||||
isc_g_mctx);
|
||||
} else {
|
||||
result = dns_master_stylecreate(&style, styleflags, 24, 32, 40,
|
||||
48, 80, 8, splitwidth, mctx);
|
||||
48, 80, 8, splitwidth,
|
||||
isc_g_mctx);
|
||||
}
|
||||
check_result(result, "dns_master_stylecreate");
|
||||
|
||||
|
|
@ -744,7 +747,7 @@ printmessage(dig_query_t *query, const isc_buffer_t *msgbuf, dns_message_t *msg,
|
|||
flags |= DNS_MESSAGETEXTFLAG_NOCOMMENTS;
|
||||
}
|
||||
|
||||
isc_buffer_allocate(mctx, &buf, len);
|
||||
isc_buffer_allocate(isc_g_mctx, &buf, len);
|
||||
|
||||
if (yaml) {
|
||||
enum { Q = 0x1, R = 0x2 }; /* Q:query; R:ecursive */
|
||||
|
|
@ -936,7 +939,7 @@ repopulate_buffer:
|
|||
buftoosmall:
|
||||
len += OUTPUTBUF;
|
||||
isc_buffer_free(&buf);
|
||||
isc_buffer_allocate(mctx, &buf, len);
|
||||
isc_buffer_allocate(isc_g_mctx, &buf, len);
|
||||
goto repopulate_buffer;
|
||||
}
|
||||
check_result(result, "dns_message_pseudosectiontotext");
|
||||
|
|
@ -1025,7 +1028,7 @@ repopulate_buffer:
|
|||
isc_buffer_free(&buf);
|
||||
|
||||
if (style != NULL) {
|
||||
dns_master_styledestroy(&style, mctx);
|
||||
dns_master_styledestroy(&style, isc_g_mctx);
|
||||
}
|
||||
|
||||
dig_idnsetup(query->lookup, false);
|
||||
|
|
@ -1440,8 +1443,8 @@ plus_tls_options(const char *cmd, const char *value, const bool state,
|
|||
FULLCHECK("tls-ca");
|
||||
lookup->tls_ca_set = state;
|
||||
if (state && value != NULL) {
|
||||
lookup->tls_ca_file =
|
||||
isc_mem_strdup(mctx, value);
|
||||
lookup->tls_ca_file = isc_mem_strdup(
|
||||
isc_g_mctx, value);
|
||||
}
|
||||
break;
|
||||
case 'e':
|
||||
|
|
@ -1450,8 +1453,9 @@ plus_tls_options(const char *cmd, const char *value, const bool state,
|
|||
if (state) {
|
||||
if (value != NULL && *value != '\0') {
|
||||
lookup->tls_cert_file =
|
||||
isc_mem_strdup(mctx,
|
||||
value);
|
||||
isc_mem_strdup(
|
||||
isc_g_mctx,
|
||||
value);
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
";; TLS certificate "
|
||||
|
|
@ -1470,8 +1474,8 @@ plus_tls_options(const char *cmd, const char *value, const bool state,
|
|||
lookup->tls_hostname_set = state;
|
||||
if (state) {
|
||||
if (value != NULL && *value != '\0') {
|
||||
lookup->tls_hostname =
|
||||
isc_mem_strdup(mctx, value);
|
||||
lookup->tls_hostname = isc_mem_strdup(
|
||||
isc_g_mctx, value);
|
||||
} else {
|
||||
fprintf(stderr, ";; TLS hostname is "
|
||||
"not specified\n");
|
||||
|
|
@ -1484,8 +1488,8 @@ plus_tls_options(const char *cmd, const char *value, const bool state,
|
|||
lookup->tls_key_file_set = state;
|
||||
if (state) {
|
||||
if (value != NULL && *value != '\0') {
|
||||
lookup->tls_key_file =
|
||||
isc_mem_strdup(mctx, value);
|
||||
lookup->tls_key_file = isc_mem_strdup(
|
||||
isc_g_mctx, value);
|
||||
} else {
|
||||
fprintf(stderr,
|
||||
";; TLS private key file is "
|
||||
|
|
@ -1920,7 +1924,7 @@ plus_option(char *option, bool is_batchfile, bool *need_clone,
|
|||
"http-plain-post");
|
||||
#if HAVE_LIBNGHTTP2
|
||||
if (lookup->https_path != NULL) {
|
||||
isc_mem_free(mctx, lookup->https_path);
|
||||
isc_mem_free(isc_g_mctx, lookup->https_path);
|
||||
lookup->https_path = NULL;
|
||||
}
|
||||
if (!state) {
|
||||
|
|
@ -1973,7 +1977,7 @@ plus_option(char *option, bool is_batchfile, bool *need_clone,
|
|||
}
|
||||
if (value == NULL) {
|
||||
lookup->https_path = isc_mem_strdup(
|
||||
mctx, ISC_NM_HTTP_DEFAULT_PATH);
|
||||
isc_g_mctx, ISC_NM_HTTP_DEFAULT_PATH);
|
||||
} else {
|
||||
if (!isc_nm_http_path_isvalid(value)) {
|
||||
fprintf(stderr,
|
||||
|
|
@ -1983,7 +1987,7 @@ plus_option(char *option, bool is_batchfile, bool *need_clone,
|
|||
value);
|
||||
goto invalid_option;
|
||||
}
|
||||
lookup->https_path = isc_mem_strdup(mctx,
|
||||
lookup->https_path = isc_mem_strdup(isc_g_mctx,
|
||||
value);
|
||||
}
|
||||
#else
|
||||
|
|
@ -2387,7 +2391,8 @@ plus_option(char *option, bool is_batchfile, bool *need_clone,
|
|||
}
|
||||
if (!state) {
|
||||
if (lookup->ecs_addr != NULL) {
|
||||
isc_mem_put(mctx, lookup->ecs_addr,
|
||||
isc_mem_put(isc_g_mctx,
|
||||
lookup->ecs_addr,
|
||||
sizeof(*lookup->ecs_addr));
|
||||
lookup->ecs_addr = NULL;
|
||||
}
|
||||
|
|
@ -2397,7 +2402,7 @@ plus_option(char *option, bool is_batchfile, bool *need_clone,
|
|||
lookup->edns = DEFAULT_EDNS_VERSION;
|
||||
}
|
||||
if (lookup->ecs_addr != NULL) {
|
||||
isc_mem_put(mctx, lookup->ecs_addr,
|
||||
isc_mem_put(isc_g_mctx, lookup->ecs_addr,
|
||||
sizeof(*lookup->ecs_addr));
|
||||
lookup->ecs_addr = NULL;
|
||||
}
|
||||
|
|
@ -2955,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':
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -99,7 +99,6 @@ in_port_t port = 53;
|
|||
bool port_set = false;
|
||||
unsigned int timeout = 0;
|
||||
unsigned int extrabytes;
|
||||
isc_mem_t *mctx = NULL;
|
||||
isc_loop_t *mainloop = NULL;
|
||||
isc_sockaddr_t localaddr;
|
||||
isc_refcount_t sendcount = 0;
|
||||
|
|
@ -448,7 +447,7 @@ make_server(const char *servname, const char *userarg) {
|
|||
REQUIRE(servname != NULL);
|
||||
|
||||
debug("make_server(%s)", servname);
|
||||
srv = isc_mem_allocate(mctx, sizeof(struct dig_server));
|
||||
srv = isc_mem_allocate(isc_g_mctx, sizeof(struct dig_server));
|
||||
strlcpy(srv->servername, servname, MXNAME);
|
||||
strlcpy(srv->userarg, userarg, MXNAME);
|
||||
ISC_LINK_INIT(srv, link);
|
||||
|
|
@ -502,7 +501,7 @@ flush_server_list(void) {
|
|||
debug("flush_server_list()");
|
||||
ISC_LIST_FOREACH (server_list, s, link) {
|
||||
ISC_LIST_DEQUEUE(server_list, s, link);
|
||||
isc_mem_free(mctx, s);
|
||||
isc_mem_free(isc_g_mctx, s);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -577,7 +576,7 @@ make_empty_lookup(void) {
|
|||
|
||||
INSIST(!free_now);
|
||||
|
||||
looknew = isc_mem_allocate(mctx, sizeof(*looknew));
|
||||
looknew = isc_mem_allocate(isc_g_mctx, sizeof(*looknew));
|
||||
*looknew = (dig_lookup_t){
|
||||
.pending = true,
|
||||
.rdtype = dns_rdatatype_a,
|
||||
|
|
@ -608,7 +607,7 @@ make_empty_lookup(void) {
|
|||
ISC_LIST_INIT(looknew->q);
|
||||
ISC_LIST_INIT(looknew->my_server_list);
|
||||
|
||||
isc_tlsctx_cache_create(mctx, &looknew->tls_ctx_cache);
|
||||
isc_tlsctx_cache_create(isc_g_mctx, &looknew->tls_ctx_cache);
|
||||
|
||||
isc_refcount_init(&looknew->references, 1);
|
||||
|
||||
|
|
@ -626,7 +625,7 @@ static void
|
|||
cloneopts(dig_lookup_t *looknew, dig_lookup_t *lookold) {
|
||||
size_t len = sizeof(looknew->ednsopts[0]) * EDNSOPT_OPTIONS;
|
||||
size_t i;
|
||||
looknew->ednsopts = isc_mem_allocate(mctx, len);
|
||||
looknew->ednsopts = isc_mem_allocate(isc_g_mctx, len);
|
||||
for (i = 0; i < EDNSOPT_OPTIONS; i++) {
|
||||
looknew->ednsopts[i].code = 0;
|
||||
looknew->ednsopts[i].length = 0;
|
||||
|
|
@ -641,8 +640,8 @@ cloneopts(dig_lookup_t *looknew, dig_lookup_t *lookold) {
|
|||
len = lookold->ednsopts[i].length;
|
||||
if (len != 0) {
|
||||
INSIST(lookold->ednsopts[i].value != NULL);
|
||||
looknew->ednsopts[i].value = isc_mem_allocate(mctx,
|
||||
len);
|
||||
looknew->ednsopts[i].value =
|
||||
isc_mem_allocate(isc_g_mctx, len);
|
||||
memmove(looknew->ednsopts[i].value,
|
||||
lookold->ednsopts[i].value, len);
|
||||
}
|
||||
|
|
@ -696,32 +695,33 @@ clone_lookup(dig_lookup_t *lookold, bool servers) {
|
|||
looknew->header_only = lookold->header_only;
|
||||
looknew->https_mode = lookold->https_mode;
|
||||
if (lookold->https_path != NULL) {
|
||||
looknew->https_path = isc_mem_strdup(mctx, lookold->https_path);
|
||||
looknew->https_path = isc_mem_strdup(isc_g_mctx,
|
||||
lookold->https_path);
|
||||
}
|
||||
looknew->https_get = lookold->https_get;
|
||||
looknew->http_plain = lookold->http_plain;
|
||||
|
||||
looknew->tls_ca_set = lookold->tls_ca_set;
|
||||
if (lookold->tls_ca_file != NULL) {
|
||||
looknew->tls_ca_file = isc_mem_strdup(mctx,
|
||||
looknew->tls_ca_file = isc_mem_strdup(isc_g_mctx,
|
||||
lookold->tls_ca_file);
|
||||
};
|
||||
|
||||
looknew->tls_hostname_set = lookold->tls_hostname_set;
|
||||
if (lookold->tls_hostname != NULL) {
|
||||
looknew->tls_hostname = isc_mem_strdup(mctx,
|
||||
looknew->tls_hostname = isc_mem_strdup(isc_g_mctx,
|
||||
lookold->tls_hostname);
|
||||
}
|
||||
|
||||
looknew->tls_key_file_set = lookold->tls_key_file_set;
|
||||
if (lookold->tls_key_file != NULL) {
|
||||
looknew->tls_key_file = isc_mem_strdup(mctx,
|
||||
looknew->tls_key_file = isc_mem_strdup(isc_g_mctx,
|
||||
lookold->tls_key_file);
|
||||
}
|
||||
|
||||
looknew->tls_cert_file_set = lookold->tls_cert_file_set;
|
||||
if (lookold->tls_cert_file != NULL) {
|
||||
looknew->tls_cert_file = isc_mem_strdup(mctx,
|
||||
looknew->tls_cert_file = isc_mem_strdup(isc_g_mctx,
|
||||
lookold->tls_cert_file);
|
||||
}
|
||||
|
||||
|
|
@ -790,7 +790,7 @@ clone_lookup(dig_lookup_t *lookold, bool servers) {
|
|||
looknew->proxy_dst_addr = lookold->proxy_dst_addr;
|
||||
|
||||
if (lookold->ecs_addr != NULL) {
|
||||
looknew->ecs_addr = isc_mem_get(mctx,
|
||||
looknew->ecs_addr = isc_mem_get(isc_g_mctx,
|
||||
sizeof(*looknew->ecs_addr));
|
||||
memmove(looknew->ecs_addr, lookold->ecs_addr,
|
||||
sizeof(*looknew->ecs_addr));
|
||||
|
|
@ -856,10 +856,10 @@ setup_text_key(void) {
|
|||
unsigned char *secretstore;
|
||||
|
||||
debug("setup_text_key()");
|
||||
isc_buffer_allocate(mctx, &namebuf, MXNAME);
|
||||
isc_buffer_allocate(isc_g_mctx, &namebuf, MXNAME);
|
||||
isc_buffer_putstr(namebuf, keynametext);
|
||||
secretsize = (unsigned int)strlen(keysecret) * 3 / 4;
|
||||
secretstore = isc_mem_allocate(mctx, secretsize);
|
||||
secretstore = isc_mem_allocate(isc_g_mctx, secretsize);
|
||||
isc_buffer_init(&secretbuf, secretstore, secretsize);
|
||||
result = isc_base64_decodestring(keysecret, &secretbuf);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
|
|
@ -879,7 +879,7 @@ setup_text_key(void) {
|
|||
}
|
||||
|
||||
result = dns_tsigkey_create(keyname, hmac_alg, secretstore,
|
||||
(int)secretsize, mctx, &tsigkey);
|
||||
(int)secretsize, isc_g_mctx, &tsigkey);
|
||||
failure:
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
printf(";; Couldn't create key %s: %s\n", keynametext,
|
||||
|
|
@ -888,7 +888,7 @@ failure:
|
|||
dst_key_setbits(tsigkey->key, digestbits);
|
||||
}
|
||||
|
||||
isc_mem_free(mctx, secretstore);
|
||||
isc_mem_free(isc_g_mctx, secretstore);
|
||||
isc_buffer_free(&namebuf);
|
||||
}
|
||||
|
||||
|
|
@ -950,7 +950,7 @@ parse_netprefix(isc_sockaddr_t **sap, const char *value) {
|
|||
fatal("invalid prefix '%s'\n", value);
|
||||
}
|
||||
|
||||
sa = isc_mem_get(mctx, sizeof(*sa));
|
||||
sa = isc_mem_get(isc_g_mctx, sizeof(*sa));
|
||||
*sa = (isc_sockaddr_t){ .length = 0 };
|
||||
|
||||
if (strcmp(buf, "0") == 0) {
|
||||
|
|
@ -1086,7 +1086,7 @@ read_confkey(void) {
|
|||
return ISC_R_FILENOTFOUND;
|
||||
}
|
||||
|
||||
result = cfg_parser_create(mctx, &pctx);
|
||||
result = cfg_parser_create(isc_g_mctx, &pctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
|
@ -1139,8 +1139,9 @@ setup_file_key(void) {
|
|||
}
|
||||
|
||||
/* Try reading the key from a K* pair */
|
||||
result = dst_key_fromnamedfile(
|
||||
keyfile, NULL, DST_TYPE_PRIVATE | DST_TYPE_KEY, mctx, &dstkey);
|
||||
result = dst_key_fromnamedfile(keyfile, NULL,
|
||||
DST_TYPE_PRIVATE | DST_TYPE_KEY,
|
||||
isc_g_mctx, &dstkey);
|
||||
|
||||
/* If that didn't work, try reading it as a session.key keyfile */
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
|
|
@ -1174,7 +1175,7 @@ setup_file_key(void) {
|
|||
if (dstkey != NULL) {
|
||||
result = dns_tsigkey_createfromkey(
|
||||
dst_key_name(dstkey), hmac_alg, dstkey, false, false,
|
||||
NULL, 0, 0, mctx, &tsigkey);
|
||||
NULL, 0, 0, isc_g_mctx, &tsigkey);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
printf(";; Couldn't create key %s: %s\n", keynametext,
|
||||
isc_result_totext(result));
|
||||
|
|
@ -1190,7 +1191,7 @@ failure:
|
|||
static dig_searchlist_t *
|
||||
make_searchlist_entry(char *domain) {
|
||||
dig_searchlist_t *search;
|
||||
search = isc_mem_allocate(mctx, sizeof(*search));
|
||||
search = isc_mem_allocate(isc_g_mctx, sizeof(*search));
|
||||
strlcpy(search->origin, domain, MXNAME);
|
||||
search->origin[MXNAME - 1] = 0;
|
||||
ISC_LINK_INIT(search, link);
|
||||
|
|
@ -1201,7 +1202,7 @@ static void
|
|||
clear_searchlist(void) {
|
||||
ISC_LIST_FOREACH (search_list, search, link) {
|
||||
ISC_LIST_UNLINK(search_list, search, link);
|
||||
isc_mem_free(mctx, search);
|
||||
isc_mem_free(isc_g_mctx, search);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1259,7 +1260,7 @@ setup_system(bool ipv4only, bool ipv6only) {
|
|||
}
|
||||
}
|
||||
|
||||
result = irs_resconf_load(mctx, RESOLV_CONF, &resconf);
|
||||
result = irs_resconf_load(isc_g_mctx, RESOLV_CONF, &resconf);
|
||||
if (result != ISC_R_SUCCESS && result != ISC_R_FILENOTFOUND) {
|
||||
fatal("parse of %s failed", RESOLV_CONF);
|
||||
}
|
||||
|
|
@ -1344,7 +1345,7 @@ setup_libs(int argc, char **argv) {
|
|||
fatal("can't find either v4 or v6 networking");
|
||||
}
|
||||
|
||||
isc_managers_create(&mctx, 1);
|
||||
isc_managers_create(1);
|
||||
|
||||
logconfig = isc_logconfig_get();
|
||||
isc_log_createandusechannel(logconfig, "debug", ISC_LOG_TOFILEDESC,
|
||||
|
|
@ -1421,7 +1422,8 @@ save_opt(dig_lookup_t *lookup, char *code, char *value) {
|
|||
INSIST(lookup->ednsopts != NULL);
|
||||
|
||||
if (lookup->ednsopts[lookup->ednsoptscnt].value != NULL) {
|
||||
isc_mem_free(mctx, lookup->ednsopts[lookup->ednsoptscnt].value);
|
||||
isc_mem_free(isc_g_mctx,
|
||||
lookup->ednsopts[lookup->ednsoptscnt].value);
|
||||
}
|
||||
|
||||
lookup->ednsopts[lookup->ednsoptscnt].code = num;
|
||||
|
|
@ -1430,7 +1432,7 @@ save_opt(dig_lookup_t *lookup, char *code, char *value) {
|
|||
|
||||
if (value != NULL) {
|
||||
char *buf;
|
||||
buf = isc_mem_allocate(mctx, strlen(value) / 2 + 1);
|
||||
buf = isc_mem_allocate(isc_g_mctx, strlen(value) / 2 + 1);
|
||||
isc_buffer_init(&b, buf, (unsigned int)strlen(value) / 2 + 1);
|
||||
result = isc_hex_decodestring(value, &b);
|
||||
check_result(result, "isc_hex_decodestring");
|
||||
|
|
@ -1541,7 +1543,7 @@ _destroy_lookup(dig_lookup_t *lookup) {
|
|||
ISC_LIST_FOREACH (lookup->my_server_list, s, link) {
|
||||
debug("freeing server %p belonging to %p", s, lookup);
|
||||
ISC_LIST_DEQUEUE(lookup->my_server_list, s, link);
|
||||
isc_mem_free(mctx, s);
|
||||
isc_mem_free(isc_g_mctx, s);
|
||||
}
|
||||
if (lookup->sendmsg != NULL) {
|
||||
dns_message_detach(&lookup->sendmsg);
|
||||
|
|
@ -1551,7 +1553,7 @@ _destroy_lookup(dig_lookup_t *lookup) {
|
|||
isc_buffer_free(&lookup->querysig);
|
||||
}
|
||||
if (lookup->sendspace != NULL) {
|
||||
isc_mem_put(mctx, lookup->sendspace, COMMSIZE);
|
||||
isc_mem_put(isc_g_mctx, lookup->sendspace, COMMSIZE);
|
||||
}
|
||||
|
||||
if (lookup->tsigctx != NULL) {
|
||||
|
|
@ -1559,21 +1561,23 @@ _destroy_lookup(dig_lookup_t *lookup) {
|
|||
}
|
||||
|
||||
if (lookup->ecs_addr != NULL) {
|
||||
isc_mem_put(mctx, lookup->ecs_addr, sizeof(*lookup->ecs_addr));
|
||||
isc_mem_put(isc_g_mctx, lookup->ecs_addr,
|
||||
sizeof(*lookup->ecs_addr));
|
||||
}
|
||||
|
||||
if (lookup->ednsopts != NULL) {
|
||||
size_t i;
|
||||
for (i = 0; i < EDNSOPT_OPTIONS; i++) {
|
||||
if (lookup->ednsopts[i].value != NULL) {
|
||||
isc_mem_free(mctx, lookup->ednsopts[i].value);
|
||||
isc_mem_free(isc_g_mctx,
|
||||
lookup->ednsopts[i].value);
|
||||
}
|
||||
}
|
||||
isc_mem_free(mctx, lookup->ednsopts);
|
||||
isc_mem_free(isc_g_mctx, lookup->ednsopts);
|
||||
}
|
||||
|
||||
if (lookup->https_path) {
|
||||
isc_mem_free(mctx, lookup->https_path);
|
||||
isc_mem_free(isc_g_mctx, lookup->https_path);
|
||||
}
|
||||
|
||||
if (lookup->tls_ctx_cache != NULL) {
|
||||
|
|
@ -1581,22 +1585,22 @@ _destroy_lookup(dig_lookup_t *lookup) {
|
|||
}
|
||||
|
||||
if (lookup->tls_ca_file != NULL) {
|
||||
isc_mem_free(mctx, lookup->tls_ca_file);
|
||||
isc_mem_free(isc_g_mctx, lookup->tls_ca_file);
|
||||
}
|
||||
|
||||
if (lookup->tls_hostname != NULL) {
|
||||
isc_mem_free(mctx, lookup->tls_hostname);
|
||||
isc_mem_free(isc_g_mctx, lookup->tls_hostname);
|
||||
}
|
||||
|
||||
if (lookup->tls_key_file != NULL) {
|
||||
isc_mem_free(mctx, lookup->tls_key_file);
|
||||
isc_mem_free(isc_g_mctx, lookup->tls_key_file);
|
||||
}
|
||||
|
||||
if (lookup->tls_cert_file != NULL) {
|
||||
isc_mem_free(mctx, lookup->tls_cert_file);
|
||||
isc_mem_free(isc_g_mctx, lookup->tls_cert_file);
|
||||
}
|
||||
|
||||
isc_mem_free(mctx, lookup);
|
||||
isc_mem_free(isc_g_mctx, lookup);
|
||||
}
|
||||
|
||||
#define lookup_attach(s, t) _lookup_attach(s, t, __FILE__, __LINE__)
|
||||
|
|
@ -1657,11 +1661,11 @@ destroy_query(dig_query_t *query, const char *file, unsigned int line) {
|
|||
|
||||
INSIST(query->recvspace != NULL);
|
||||
|
||||
isc_mem_put(mctx, query->recvspace, COMMSIZE);
|
||||
isc_mem_put(mctx, query->tmpsendspace, COMMSIZE);
|
||||
isc_mem_put(isc_g_mctx, query->recvspace, COMMSIZE);
|
||||
isc_mem_put(isc_g_mctx, query->tmpsendspace, COMMSIZE);
|
||||
|
||||
query->magic = 0;
|
||||
isc_mem_free(mctx, query);
|
||||
isc_mem_free(isc_g_mctx, query);
|
||||
}
|
||||
|
||||
#define query_attach(s, t) _query_attach(s, t, __FILE__, __LINE__)
|
||||
|
|
@ -2033,7 +2037,7 @@ insert_soa(dig_lookup_t *lookup) {
|
|||
dns_name_t *soaname = NULL;
|
||||
|
||||
debug("insert_soa()");
|
||||
soa.mctx = mctx;
|
||||
soa.mctx = isc_g_mctx;
|
||||
soa.serial = lookup->ixfr_serial;
|
||||
soa.refresh = 0;
|
||||
soa.retry = 0;
|
||||
|
|
@ -2087,14 +2091,15 @@ _new_query(dig_lookup_t *lookup, char *servname, char *userarg,
|
|||
const char *file, unsigned int line) {
|
||||
dig_query_t *query = NULL;
|
||||
|
||||
query = isc_mem_allocate(mctx, sizeof(dig_query_t));
|
||||
query = isc_mem_allocate(isc_g_mctx, sizeof(dig_query_t));
|
||||
debug("create query %p linked to lookup %p", query, lookup);
|
||||
*query = (dig_query_t){ .sendbuf = lookup->renderbuf,
|
||||
.servname = servname,
|
||||
.userarg = userarg,
|
||||
.warn_id = true,
|
||||
.recvspace = isc_mem_get(mctx, COMMSIZE),
|
||||
.tmpsendspace = isc_mem_get(mctx, COMMSIZE) };
|
||||
.recvspace = isc_mem_get(isc_g_mctx, COMMSIZE),
|
||||
.tmpsendspace = isc_mem_get(isc_g_mctx,
|
||||
COMMSIZE) };
|
||||
|
||||
lookup_attach(lookup, &query->lookup);
|
||||
|
||||
|
|
@ -2148,7 +2153,7 @@ setup_lookup(dig_lookup_t *lookup) {
|
|||
|
||||
debug("setup_lookup(%p)", lookup);
|
||||
|
||||
dns_message_create(mctx, NULL, NULL, DNS_MESSAGE_INTENTRENDER,
|
||||
dns_message_create(isc_g_mctx, NULL, NULL, DNS_MESSAGE_INTENTRENDER,
|
||||
&lookup->sendmsg);
|
||||
|
||||
if (lookup->new_search) {
|
||||
|
|
@ -2386,9 +2391,9 @@ setup_lookup(dig_lookup_t *lookup) {
|
|||
lookup->sendmsg->fuzztime = lookup->fuzztime;
|
||||
}
|
||||
|
||||
lookup->sendspace = isc_mem_get(mctx, COMMSIZE);
|
||||
lookup->sendspace = isc_mem_get(isc_g_mctx, COMMSIZE);
|
||||
|
||||
dns_compress_init(&cctx, mctx, 0);
|
||||
dns_compress_init(&cctx, isc_g_mctx, 0);
|
||||
|
||||
debug("starting to render the message");
|
||||
isc_buffer_init(&lookup->renderbuf, lookup->sendspace, COMMSIZE);
|
||||
|
|
@ -2836,7 +2841,8 @@ get_create_tls_context(dig_query_t *query, const bool is_https,
|
|||
#endif /* HAVE_LIBNGHTTP2 */
|
||||
|
||||
isc_tlsctx_client_session_cache_create(
|
||||
mctx, ctx, ISC_TLSCTX_CLIENT_SESSION_CACHE_DEFAULT_SIZE,
|
||||
isc_g_mctx, ctx,
|
||||
ISC_TLSCTX_CLIENT_SESSION_CACHE_DEFAULT_SIZE,
|
||||
&sess_cache);
|
||||
|
||||
result = isc_tlsctx_cache_add(
|
||||
|
|
@ -4132,13 +4138,14 @@ recv_done(isc_nmhandle_t *handle, isc_result_t eresult, isc_region_t *region,
|
|||
goto keep_query;
|
||||
}
|
||||
|
||||
dns_message_create(mctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE, &msg);
|
||||
dns_message_create(isc_g_mctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE,
|
||||
&msg);
|
||||
|
||||
if (tsigkey != NULL) {
|
||||
if (l->querysig == NULL) {
|
||||
debug("getting initial querysig");
|
||||
result = dns_message_getquerytsig(l->sendmsg, mctx,
|
||||
&l->querysig);
|
||||
result = dns_message_getquerytsig(
|
||||
l->sendmsg, isc_g_mctx, &l->querysig);
|
||||
check_result(result, "dns_message_getquerytsig");
|
||||
}
|
||||
dns_message_setquerytsig(msg, l->querysig);
|
||||
|
|
@ -4361,7 +4368,8 @@ recv_done(isc_nmhandle_t *handle, isc_result_t eresult, isc_region_t *region,
|
|||
debug("freeing querysig buffer %p", l->querysig);
|
||||
isc_buffer_free(&l->querysig);
|
||||
}
|
||||
result = dns_message_getquerytsig(msg, mctx, &l->querysig);
|
||||
result = dns_message_getquerytsig(msg, isc_g_mctx,
|
||||
&l->querysig);
|
||||
check_result(result, "dns_message_getquerytsig");
|
||||
}
|
||||
|
||||
|
|
@ -4704,10 +4712,10 @@ destroy_libs(void) {
|
|||
|
||||
debug("Destroy memory");
|
||||
if (memdebugging != 0) {
|
||||
isc_mem_stats(mctx, stderr);
|
||||
isc_mem_stats(isc_g_mctx, stderr);
|
||||
}
|
||||
|
||||
isc_managers_destroy(&mctx);
|
||||
isc_managers_destroy();
|
||||
|
||||
#if ENABLE_LEAK_DETECTION
|
||||
isc__crypto_setdestroycheck(true);
|
||||
|
|
|
|||
|
|
@ -253,7 +253,6 @@ extern bool check_ra, have_ipv4, have_ipv6, specified_source, usesearch,
|
|||
extern in_port_t port;
|
||||
extern bool port_set;
|
||||
extern unsigned int timeout;
|
||||
extern isc_mem_t *mctx;
|
||||
extern isc_refcount_t sendcount;
|
||||
extern int ndots;
|
||||
extern int lookup_counter;
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@ say_message(dns_name_t *name, const char *msg, dns_rdata_t *rdata,
|
|||
|
||||
dns_name_format(name, namestr, sizeof(namestr));
|
||||
retry:
|
||||
isc_buffer_allocate(mctx, &b, bufsize);
|
||||
isc_buffer_allocate(isc_g_mctx, &b, bufsize);
|
||||
result = dns_rdata_totext(rdata, NULL, b);
|
||||
if (result == ISC_R_NOSPACE) {
|
||||
isc_buffer_free(&b);
|
||||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -180,7 +180,7 @@ printrdata(dns_rdata_t *rdata) {
|
|||
}
|
||||
|
||||
while (!done) {
|
||||
isc_buffer_allocate(mctx, &b, size);
|
||||
isc_buffer_allocate(isc_g_mctx, &b, size);
|
||||
result = dns_rdata_totext(rdata, NULL, b);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
printf("%.*s\n", (int)isc_buffer_usedlength(b),
|
||||
|
|
|
|||
|
|
@ -60,11 +60,6 @@
|
|||
|
||||
#include "dnssectool.h"
|
||||
|
||||
/*
|
||||
* Infrastructure
|
||||
*/
|
||||
static isc_mem_t *mctx = NULL;
|
||||
|
||||
/*
|
||||
* The domain we are working on
|
||||
*/
|
||||
|
|
@ -217,9 +212,9 @@ freelist(dns_rdataset_t *rdataset) {
|
|||
|
||||
ISC_LIST_FOREACH (rdlist->rdata, rdata, link) {
|
||||
ISC_LIST_UNLINK(rdlist->rdata, rdata, link);
|
||||
isc_mem_put(mctx, rdata, sizeof(*rdata));
|
||||
isc_mem_put(isc_g_mctx, rdata, sizeof(*rdata));
|
||||
}
|
||||
isc_mem_put(mctx, rdlist, sizeof(*rdlist));
|
||||
isc_mem_put(isc_g_mctx, rdlist, sizeof(*rdlist));
|
||||
dns_rdataset_disassociate(rdataset);
|
||||
}
|
||||
|
||||
|
|
@ -242,8 +237,8 @@ static void
|
|||
load_db(const char *filename, dns_db_t **dbp, dns_dbnode_t **nodep) {
|
||||
isc_result_t result;
|
||||
|
||||
result = dns_db_create(mctx, ZONEDB_DEFAULT, name, dns_dbtype_zone,
|
||||
rdclass, 0, NULL, dbp);
|
||||
result = dns_db_create(isc_g_mctx, ZONEDB_DEFAULT, name,
|
||||
dns_dbtype_zone, rdclass, 0, NULL, dbp);
|
||||
check_result(result, "dns_db_create()");
|
||||
|
||||
result = dns_db_load(*dbp, filename, dns_masterformat_text,
|
||||
|
|
@ -373,12 +368,12 @@ formatset(dns_rdataset_t *rdataset) {
|
|||
* eliminates any tab characters.
|
||||
*/
|
||||
result = dns_master_stylecreate(&style, styleflags, 0, 0, 0, 0, 0,
|
||||
1000000, 0, mctx);
|
||||
1000000, 0, isc_g_mctx);
|
||||
check_result(result, "dns_master_stylecreate2 failed");
|
||||
|
||||
isc_buffer_allocate(mctx, &buf, MAX_CDS_RDATA_TEXT_SIZE);
|
||||
isc_buffer_allocate(isc_g_mctx, &buf, MAX_CDS_RDATA_TEXT_SIZE);
|
||||
result = dns_master_rdatasettotext(name, rdataset, style, NULL, buf);
|
||||
dns_master_styledestroy(&style, mctx);
|
||||
dns_master_styledestroy(&style, isc_g_mctx);
|
||||
|
||||
if ((result == ISC_R_SUCCESS) && isc_buffer_availablelength(buf) < 1) {
|
||||
result = ISC_R_NOSPACE;
|
||||
|
|
@ -530,7 +525,7 @@ match_keyset_dsset(dns_rdataset_t *keyset, dns_rdataset_t *dsset,
|
|||
|
||||
nkey = dns_rdataset_count(keyset);
|
||||
|
||||
keytable = isc_mem_cget(mctx, nkey, sizeof(keytable[0]));
|
||||
keytable = isc_mem_cget(isc_g_mctx, nkey, sizeof(keytable[0]));
|
||||
ki = keytable;
|
||||
|
||||
DNS_RDATASET_FOREACH (keyset) {
|
||||
|
|
@ -557,7 +552,7 @@ match_keyset_dsset(dns_rdataset_t *keyset, dns_rdataset_t *dsset,
|
|||
continue;
|
||||
}
|
||||
|
||||
result = dns_dnssec_keyfromrdata(name, keyrdata, mctx,
|
||||
result = dns_dnssec_keyfromrdata(name, keyrdata, isc_g_mctx,
|
||||
&ki->dst);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
vbprintf(3,
|
||||
|
|
@ -586,7 +581,7 @@ free_keytable(keyinfo_t **keytable_p) {
|
|||
}
|
||||
}
|
||||
|
||||
isc_mem_cput(mctx, keytable, nkey, sizeof(keytable[0]));
|
||||
isc_mem_cput(isc_g_mctx, keytable, nkey, sizeof(keytable[0]));
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -607,7 +602,7 @@ matching_sigs(keyinfo_t *keytbl, dns_rdataset_t *rdataset,
|
|||
|
||||
REQUIRE(keytbl != NULL);
|
||||
|
||||
algo = isc_mem_cget(mctx, nkey, sizeof(algo[0]));
|
||||
algo = isc_mem_cget(isc_g_mctx, nkey, sizeof(algo[0]));
|
||||
|
||||
DNS_RDATASET_FOREACH (sigset) {
|
||||
dns_rdata_t sigrdata = DNS_RDATA_INIT;
|
||||
|
|
@ -642,7 +637,7 @@ matching_sigs(keyinfo_t *keytbl, dns_rdataset_t *rdataset,
|
|||
}
|
||||
|
||||
result = dns_dnssec_verify(name, rdataset, ki->dst,
|
||||
false, mctx, &sigrdata,
|
||||
false, isc_g_mctx, &sigrdata,
|
||||
NULL);
|
||||
|
||||
if (result != ISC_R_SUCCESS &&
|
||||
|
|
@ -688,7 +683,7 @@ signed_loose(dns_secalg_t *algo) {
|
|||
ok = true;
|
||||
}
|
||||
}
|
||||
isc_mem_cput(mctx, algo, nkey, sizeof(algo[0]));
|
||||
isc_mem_cput(isc_g_mctx, algo, nkey, sizeof(algo[0]));
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
|
@ -728,7 +723,7 @@ signed_strict(dns_rdataset_t *dsset, dns_secalg_t *algo) {
|
|||
}
|
||||
}
|
||||
|
||||
isc_mem_cput(mctx, algo, nkey, sizeof(algo[0]));
|
||||
isc_mem_cput(isc_g_mctx, algo, nkey, sizeof(algo[0]));
|
||||
return all_ok;
|
||||
}
|
||||
|
||||
|
|
@ -789,7 +784,7 @@ append_new_ds_set(ds_maker_func_t *ds_from_rdata, isc_buffer_t *buf,
|
|||
|
||||
dns_rdataset_current(crdset, &crdata);
|
||||
|
||||
ds = isc_mem_get(mctx, sizeof(*ds));
|
||||
ds = isc_mem_get(isc_g_mctx, sizeof(*ds));
|
||||
dns_rdata_init(ds);
|
||||
|
||||
result = ds_from_rdata(buf, ds, dt, &crdata);
|
||||
|
|
@ -799,13 +794,13 @@ append_new_ds_set(ds_maker_func_t *ds_from_rdata, isc_buffer_t *buf,
|
|||
ISC_LIST_APPEND(dslist->rdata, ds, link);
|
||||
break;
|
||||
case ISC_R_IGNORE:
|
||||
isc_mem_put(mctx, ds, sizeof(*ds));
|
||||
isc_mem_put(isc_g_mctx, ds, sizeof(*ds));
|
||||
continue;
|
||||
case ISC_R_NOSPACE:
|
||||
isc_mem_put(mctx, ds, sizeof(*ds));
|
||||
isc_mem_put(isc_g_mctx, ds, sizeof(*ds));
|
||||
return result;
|
||||
default:
|
||||
isc_mem_put(mctx, ds, sizeof(*ds));
|
||||
isc_mem_put(isc_g_mctx, ds, sizeof(*ds));
|
||||
check_result(result, "ds_from_rdata()");
|
||||
}
|
||||
}
|
||||
|
|
@ -823,7 +818,7 @@ make_new_ds_set(ds_maker_func_t *ds_from_rdata, uint32_t ttl,
|
|||
dns_rdatalist_t *dslist = NULL;
|
||||
size_t n;
|
||||
|
||||
dslist = isc_mem_get(mctx, sizeof(*dslist));
|
||||
dslist = isc_mem_get(isc_g_mctx, sizeof(*dslist));
|
||||
dns_rdatalist_init(dslist);
|
||||
dslist->rdclass = rdclass;
|
||||
dslist->type = dns_rdatatype_ds;
|
||||
|
|
@ -832,7 +827,7 @@ make_new_ds_set(ds_maker_func_t *ds_from_rdata, uint32_t ttl,
|
|||
dns_rdataset_init(&new_ds_set);
|
||||
dns_rdatalist_tordataset(dslist, &new_ds_set);
|
||||
|
||||
isc_buffer_allocate(mctx, &new_ds_buf, size);
|
||||
isc_buffer_allocate(isc_g_mctx, &new_ds_buf, size);
|
||||
|
||||
n = sizeof(dtype) / sizeof(dtype[0]);
|
||||
for (size_t i = 0; i < n && dtype[i] != 0; i++) {
|
||||
|
|
@ -881,7 +876,7 @@ consistent_digests(dns_rdataset_t *dsset) {
|
|||
|
||||
n = dns_rdataset_count(dsset);
|
||||
|
||||
arrdata = isc_mem_cget(mctx, n, sizeof(dns_rdata_t));
|
||||
arrdata = isc_mem_cget(isc_g_mctx, n, sizeof(dns_rdata_t));
|
||||
|
||||
DNS_RDATASET_FOREACH (dsset) {
|
||||
dns_rdata_init(&arrdata[i]);
|
||||
|
|
@ -894,7 +889,7 @@ consistent_digests(dns_rdataset_t *dsset) {
|
|||
/*
|
||||
* Convert sorted arrdata to more accessible format
|
||||
*/
|
||||
ds = isc_mem_cget(mctx, n, sizeof(dns_rdata_ds_t));
|
||||
ds = isc_mem_cget(isc_g_mctx, n, sizeof(dns_rdata_ds_t));
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
result = dns_rdata_tostruct(&arrdata[i], &ds[i], NULL);
|
||||
|
|
@ -933,8 +928,8 @@ consistent_digests(dns_rdataset_t *dsset) {
|
|||
/*
|
||||
* Done!
|
||||
*/
|
||||
isc_mem_cput(mctx, ds, n, sizeof(dns_rdata_ds_t));
|
||||
isc_mem_cput(mctx, arrdata, n, sizeof(dns_rdata_t));
|
||||
isc_mem_cput(isc_g_mctx, ds, n, sizeof(dns_rdata_ds_t));
|
||||
isc_mem_cput(isc_g_mctx, arrdata, n, sizeof(dns_rdata_t));
|
||||
|
||||
return match;
|
||||
}
|
||||
|
|
@ -965,8 +960,8 @@ update_diff(const char *cmd, uint32_t ttl, dns_rdataset_t *addset,
|
|||
dns_rdataset_t diffset;
|
||||
uint32_t save;
|
||||
|
||||
result = dns_db_create(mctx, ZONEDB_DEFAULT, name, dns_dbtype_zone,
|
||||
rdclass, 0, NULL, &update_db);
|
||||
result = dns_db_create(isc_g_mctx, ZONEDB_DEFAULT, name,
|
||||
dns_dbtype_zone, rdclass, 0, NULL, &update_db);
|
||||
check_result(result, "dns_db_create()");
|
||||
|
||||
result = dns_db_newversion(update_db, &update_version);
|
||||
|
|
@ -1057,11 +1052,8 @@ cleanup(void) {
|
|||
free_keytable(&new_key_tbl);
|
||||
}
|
||||
free_all_sets();
|
||||
if (mctx != NULL) {
|
||||
if (print_mem_stats && verbose > 10) {
|
||||
isc_mem_stats(mctx, stdout);
|
||||
}
|
||||
isc_mem_detach(&mctx);
|
||||
if (print_mem_stats && verbose > 10) {
|
||||
isc_mem_stats(isc_g_mctx, stdout);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1080,8 +1072,6 @@ main(int argc, char *argv[]) {
|
|||
|
||||
isc_commandline_init(argc, argv);
|
||||
|
||||
isc_mem_create(isc_commandline_progname, &mctx);
|
||||
|
||||
isc_commandline_errprint = false;
|
||||
|
||||
#define OPTIONS "a:c:Dd:f:i:ms:T:uv:V"
|
||||
|
|
@ -1117,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;
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@
|
|||
static dns_rdataclass_t rdclass;
|
||||
static dns_fixedname_t fixed;
|
||||
static dns_name_t *name = NULL;
|
||||
static isc_mem_t *mctx = NULL;
|
||||
static uint32_t ttl;
|
||||
static bool emitttl = false;
|
||||
static unsigned int split_width = 0;
|
||||
|
|
@ -81,7 +80,7 @@ db_load_from_stream(dns_db_t *db, FILE *fp) {
|
|||
}
|
||||
|
||||
result = dns_master_loadstream(fp, name, name, rdclass, 0, &callbacks,
|
||||
mctx);
|
||||
isc_g_mctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fatal("can't load from input: %s", isc_result_totext(result));
|
||||
}
|
||||
|
|
@ -101,8 +100,8 @@ loadset(const char *filename, dns_rdataset_t *rdataset) {
|
|||
|
||||
dns_name_format(name, setname, sizeof(setname));
|
||||
|
||||
result = dns_db_create(mctx, ZONEDB_DEFAULT, name, dns_dbtype_zone,
|
||||
rdclass, 0, NULL, &db);
|
||||
result = dns_db_create(isc_g_mctx, ZONEDB_DEFAULT, name,
|
||||
dns_dbtype_zone, rdclass, 0, NULL, &db);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fatal("can't create database");
|
||||
}
|
||||
|
|
@ -188,8 +187,8 @@ loadkey(char *filename, unsigned char *key_buf, unsigned int key_buf_size,
|
|||
|
||||
isc_buffer_init(&keyb, key_buf, key_buf_size);
|
||||
|
||||
result = dst_key_fromnamedfile(filename, NULL, DST_TYPE_PUBLIC, mctx,
|
||||
&key);
|
||||
result = dst_key_fromnamedfile(filename, NULL, DST_TYPE_PUBLIC,
|
||||
isc_g_mctx, &key);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fatal("can't load %s.key: %s", filename,
|
||||
isc_result_totext(result));
|
||||
|
|
@ -228,7 +227,7 @@ logkey(dns_rdata_t *rdata) {
|
|||
|
||||
isc_buffer_init(&buf, rdata->data, rdata->length);
|
||||
isc_buffer_add(&buf, rdata->length);
|
||||
result = dst_key_fromdns(name, rdclass, &buf, mctx, &key);
|
||||
result = dst_key_fromdns(name, rdclass, &buf, isc_g_mctx, &key);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return;
|
||||
}
|
||||
|
|
@ -384,8 +383,6 @@ main(int argc, char **argv) {
|
|||
|
||||
isc_commandline_init(argc, argv);
|
||||
|
||||
isc_mem_create(isc_commandline_progname, &mctx);
|
||||
|
||||
isc_commandline_errprint = false;
|
||||
|
||||
#define OPTIONS "12Aa:Cc:d:Ff:K:sT:v:whV"
|
||||
|
|
@ -546,9 +543,8 @@ main(int argc, char **argv) {
|
|||
dns_rdataset_disassociate(&rdataset);
|
||||
}
|
||||
if (verbose > 10) {
|
||||
isc_mem_stats(mctx, stdout);
|
||||
isc_mem_stats(isc_g_mctx, stdout);
|
||||
}
|
||||
isc_mem_detach(&mctx);
|
||||
|
||||
fflush(stdout);
|
||||
if (ferror(stdout)) {
|
||||
|
|
|
|||
|
|
@ -49,7 +49,6 @@
|
|||
static dns_rdataclass_t rdclass;
|
||||
static dns_fixedname_t fixed;
|
||||
static dns_name_t *name = NULL;
|
||||
static isc_mem_t *mctx = NULL;
|
||||
static bool setpub = false, setdel = false;
|
||||
static bool setttl = false;
|
||||
static isc_stdtime_t pub = 0, del = 0;
|
||||
|
|
@ -83,7 +82,7 @@ db_load_from_stream(dns_db_t *db, FILE *fp) {
|
|||
}
|
||||
|
||||
result = dns_master_loadstream(fp, name, name, rdclass, 0, &callbacks,
|
||||
mctx);
|
||||
isc_g_mctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fatal("can't load from input: %s", isc_result_totext(result));
|
||||
}
|
||||
|
|
@ -103,8 +102,8 @@ loadset(const char *filename, dns_rdataset_t *rdataset) {
|
|||
|
||||
dns_name_format(name, setname, sizeof(setname));
|
||||
|
||||
result = dns_db_create(mctx, ZONEDB_DEFAULT, name, dns_dbtype_zone,
|
||||
rdclass, 0, NULL, &db);
|
||||
result = dns_db_create(isc_g_mctx, ZONEDB_DEFAULT, name,
|
||||
dns_dbtype_zone, rdclass, 0, NULL, &db);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fatal("can't create database");
|
||||
}
|
||||
|
|
@ -156,8 +155,8 @@ loadkey(char *filename, unsigned char *key_buf, unsigned int key_buf_size,
|
|||
|
||||
isc_buffer_init(&keyb, key_buf, key_buf_size);
|
||||
|
||||
result = dst_key_fromnamedfile(filename, NULL, DST_TYPE_PUBLIC, mctx,
|
||||
&key);
|
||||
result = dst_key_fromnamedfile(filename, NULL, DST_TYPE_PUBLIC,
|
||||
isc_g_mctx, &key);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fatal("invalid keyfile name %s: %s", filename,
|
||||
isc_result_totext(result));
|
||||
|
|
@ -198,7 +197,7 @@ emit(const char *dir, dns_rdata_t *rdata) {
|
|||
|
||||
isc_buffer_init(&buf, rdata->data, rdata->length);
|
||||
isc_buffer_add(&buf, rdata->length);
|
||||
result = dst_key_fromdns(name, rdclass, &buf, mctx, &key);
|
||||
result = dst_key_fromdns(name, rdclass, &buf, isc_g_mctx, &key);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fatal("dst_key_fromdns: %s", isc_result_totext(result));
|
||||
}
|
||||
|
|
@ -218,7 +217,7 @@ emit(const char *dir, dns_rdata_t *rdata) {
|
|||
|
||||
result = dst_key_fromfile(
|
||||
dst_key_name(key), dst_key_id(key), dst_key_alg(key),
|
||||
DST_TYPE_PUBLIC | DST_TYPE_PRIVATE, dir, mctx, &tmp);
|
||||
DST_TYPE_PUBLIC | DST_TYPE_PRIVATE, dir, isc_g_mctx, &tmp);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
if (dst_key_isprivate(tmp) && !dst_key_isexternal(tmp)) {
|
||||
fatal("Private key already exists in %s", priname);
|
||||
|
|
@ -310,8 +309,6 @@ main(int argc, char **argv) {
|
|||
|
||||
isc_commandline_init(argc, argv);
|
||||
|
||||
isc_mem_create(isc_commandline_progname, &mctx);
|
||||
|
||||
isc_commandline_errprint = false;
|
||||
|
||||
#define CMDLINE_FLAGS "D:f:hK:L:P:v:V"
|
||||
|
|
@ -453,9 +450,8 @@ main(int argc, char **argv) {
|
|||
dns_rdataset_disassociate(&rdataset);
|
||||
}
|
||||
if (verbose > 10) {
|
||||
isc_mem_stats(mctx, stdout);
|
||||
isc_mem_stats(isc_g_mctx, stdout);
|
||||
}
|
||||
isc_mem_detach(&mctx);
|
||||
|
||||
fflush(stdout);
|
||||
if (ferror(stdout)) {
|
||||
|
|
|
|||
|
|
@ -115,7 +115,6 @@ main(int argc, char **argv) {
|
|||
uint16_t flags = 0, kskflag = 0, revflag = 0;
|
||||
dst_algorithm_t alg;
|
||||
bool oldstyle = false;
|
||||
isc_mem_t *mctx = NULL;
|
||||
int ch;
|
||||
isc_result_t ret;
|
||||
isc_textregion_t r;
|
||||
|
|
@ -150,8 +149,6 @@ main(int argc, char **argv) {
|
|||
|
||||
isc_commandline_init(argc, argv);
|
||||
|
||||
isc_mem_create(isc_commandline_progname, &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"
|
||||
|
|
@ -199,7 +196,8 @@ main(int argc, char **argv) {
|
|||
setttl = true;
|
||||
break;
|
||||
case 'l':
|
||||
label = isc_mem_strdup(mctx, isc_commandline_argument);
|
||||
label = isc_mem_strdup(isc_g_mctx,
|
||||
isc_commandline_argument);
|
||||
break;
|
||||
case 'M': {
|
||||
unsigned long ul;
|
||||
|
|
@ -370,9 +368,9 @@ main(int argc, char **argv) {
|
|||
int len;
|
||||
|
||||
len = strlen(label) + 8;
|
||||
l = isc_mem_allocate(mctx, len);
|
||||
l = isc_mem_allocate(isc_g_mctx, len);
|
||||
snprintf(l, len, "pkcs11:%s", label);
|
||||
isc_mem_free(mctx, label);
|
||||
isc_mem_free(isc_g_mctx, label);
|
||||
label = l;
|
||||
}
|
||||
|
||||
|
|
@ -461,7 +459,7 @@ main(int argc, char **argv) {
|
|||
|
||||
ret = dst_key_fromnamedfile(predecessor, directory,
|
||||
DST_TYPE_PUBLIC | DST_TYPE_PRIVATE,
|
||||
mctx, &prevkey);
|
||||
isc_g_mctx, &prevkey);
|
||||
if (ret != ISC_R_SUCCESS) {
|
||||
fatal("Invalid keyfile %s: %s", predecessor,
|
||||
isc_result_totext(ret));
|
||||
|
|
@ -557,7 +555,7 @@ main(int argc, char **argv) {
|
|||
|
||||
/* associate the key */
|
||||
ret = dst_key_fromlabel(name, alg, flags, DNS_KEYPROTO_DNSSEC, rdclass,
|
||||
label, NULL, mctx, &key);
|
||||
label, NULL, isc_g_mctx, &key);
|
||||
|
||||
if (ret != ISC_R_SUCCESS) {
|
||||
char namestr[DNS_NAME_FORMATSIZE];
|
||||
|
|
@ -647,7 +645,8 @@ main(int argc, char **argv) {
|
|||
* is a risk of ID collision due to this key or another key
|
||||
* being revoked.
|
||||
*/
|
||||
if (key_collision(key, name, directory, mctx, tag_min, tag_max, &exact))
|
||||
if (key_collision(key, name, directory, isc_g_mctx, tag_min, tag_max,
|
||||
&exact))
|
||||
{
|
||||
isc_buffer_clear(&buf);
|
||||
ret = dst_key_buildfilename(key, 0, directory, &buf);
|
||||
|
|
@ -695,10 +694,9 @@ main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
if (verbose > 10) {
|
||||
isc_mem_stats(mctx, stdout);
|
||||
isc_mem_stats(isc_g_mctx, stdout);
|
||||
}
|
||||
isc_mem_free(mctx, label);
|
||||
isc_mem_detach(&mctx);
|
||||
isc_mem_free(isc_g_mctx, label);
|
||||
|
||||
if (freeit != NULL) {
|
||||
free(freeit);
|
||||
|
|
|
|||
|
|
@ -231,7 +231,7 @@ progress(int p) {
|
|||
}
|
||||
|
||||
static void
|
||||
keygen(keygen_ctx_t *ctx, isc_mem_t *mctx, int argc, char **argv) {
|
||||
keygen(keygen_ctx_t *ctx, int argc, char **argv) {
|
||||
char filename[255];
|
||||
char algstr[DNS_SECALG_FORMATSIZE];
|
||||
uint16_t flags = 0;
|
||||
|
|
@ -394,7 +394,7 @@ keygen(keygen_ctx_t *ctx, isc_mem_t *mctx, int argc, char **argv) {
|
|||
ret = dst_key_fromnamedfile(ctx->predecessor, ctx->directory,
|
||||
DST_TYPE_PUBLIC | DST_TYPE_PRIVATE |
|
||||
DST_TYPE_STATE,
|
||||
mctx, &prevkey);
|
||||
isc_g_mctx, &prevkey);
|
||||
if (ret != ISC_R_SUCCESS) {
|
||||
fatal("Invalid keyfile %s: %s", ctx->predecessor,
|
||||
isc_result_totext(ret));
|
||||
|
|
@ -560,17 +560,17 @@ keygen(keygen_ctx_t *ctx, isc_mem_t *mctx, int argc, char **argv) {
|
|||
if (ctx->keystore != NULL && ctx->policy != NULL) {
|
||||
ret = dns_keystore_keygen(
|
||||
ctx->keystore, name, ctx->policy, ctx->rdclass,
|
||||
mctx, ctx->alg, ctx->size, flags, &key);
|
||||
isc_g_mctx, ctx->alg, ctx->size, flags, &key);
|
||||
} else if (!ctx->quiet && show_progress) {
|
||||
ret = dst_key_generate(name, ctx->alg, ctx->size, 0,
|
||||
flags, DNS_KEYPROTO_DNSSEC,
|
||||
ctx->rdclass, NULL, mctx, &key,
|
||||
&progress);
|
||||
ctx->rdclass, NULL, isc_g_mctx,
|
||||
&key, &progress);
|
||||
} else {
|
||||
ret = dst_key_generate(name, ctx->alg, ctx->size, 0,
|
||||
flags, DNS_KEYPROTO_DNSSEC,
|
||||
ctx->rdclass, NULL, mctx, &key,
|
||||
NULL);
|
||||
ctx->rdclass, NULL, isc_g_mctx,
|
||||
&key, NULL);
|
||||
}
|
||||
|
||||
if (!ctx->quiet && show_progress) {
|
||||
|
|
@ -704,8 +704,8 @@ keygen(keygen_ctx_t *ctx, isc_mem_t *mctx, int argc, char **argv) {
|
|||
* if there is a risk of ID collision due to this key
|
||||
* or another key being revoked.
|
||||
*/
|
||||
if (key_collision(key, name, ctx->directory, mctx, ctx->tag_min,
|
||||
ctx->tag_max, NULL))
|
||||
if (key_collision(key, name, ctx->directory, isc_g_mctx,
|
||||
ctx->tag_min, ctx->tag_max, NULL))
|
||||
{
|
||||
conflict = true;
|
||||
if (null_key) {
|
||||
|
|
@ -789,7 +789,6 @@ main(int argc, char **argv) {
|
|||
char *algname = NULL, *freeit = NULL;
|
||||
char *classname = NULL;
|
||||
char *endp;
|
||||
isc_mem_t *mctx = NULL;
|
||||
isc_result_t ret;
|
||||
isc_textregion_t r;
|
||||
unsigned char c;
|
||||
|
|
@ -821,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:
|
||||
|
|
@ -838,8 +837,6 @@ main(int argc, char **argv) {
|
|||
}
|
||||
isc_commandline_reset = true;
|
||||
|
||||
isc_mem_create(isc_commandline_progname, &mctx);
|
||||
|
||||
while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) {
|
||||
switch (ch) {
|
||||
case '3':
|
||||
|
|
@ -1146,13 +1143,13 @@ main(int argc, char **argv) {
|
|||
ctx.tag_min = 0;
|
||||
ctx.tag_max = 0xffff;
|
||||
|
||||
keygen(&ctx, mctx, argc, argv);
|
||||
keygen(&ctx, argc, argv);
|
||||
} else {
|
||||
cfg_parser_t *parser = NULL;
|
||||
cfg_obj_t *config = NULL;
|
||||
dns_kasp_t *kasp = NULL;
|
||||
|
||||
RUNTIME_CHECK(cfg_parser_create(mctx, &parser) ==
|
||||
RUNTIME_CHECK(cfg_parser_create(isc_g_mctx, &parser) ==
|
||||
ISC_R_SUCCESS);
|
||||
if (cfg_parse_file(parser, ctx.configfile,
|
||||
&cfg_type_namedconf,
|
||||
|
|
@ -1163,8 +1160,8 @@ main(int argc, char **argv) {
|
|||
ctx.policy, ctx.configfile);
|
||||
}
|
||||
|
||||
kasp_from_conf(config, mctx, ctx.policy, ctx.directory,
|
||||
&kasp);
|
||||
kasp_from_conf(config, isc_g_mctx, ctx.policy,
|
||||
ctx.directory, &kasp);
|
||||
if (kasp == NULL) {
|
||||
fatal("failed to load dnssec-policy '%s'",
|
||||
ctx.policy);
|
||||
|
|
@ -1196,7 +1193,7 @@ main(int argc, char **argv) {
|
|||
{
|
||||
continue;
|
||||
}
|
||||
keygen(&ctx, mctx, argc, argv);
|
||||
keygen(&ctx, argc, argv);
|
||||
}
|
||||
|
||||
dns_kasp_detach(&kasp);
|
||||
|
|
@ -1204,13 +1201,12 @@ main(int argc, char **argv) {
|
|||
cfg_parser_destroy(&parser);
|
||||
}
|
||||
} else {
|
||||
keygen(&ctx, mctx, argc, argv);
|
||||
keygen(&ctx, argc, argv);
|
||||
}
|
||||
|
||||
if (verbose > 10) {
|
||||
isc_mem_stats(mctx, stdout);
|
||||
isc_mem_stats(isc_g_mctx, stdout);
|
||||
}
|
||||
isc_mem_detach(&mctx);
|
||||
|
||||
if (freeit != NULL) {
|
||||
free(freeit);
|
||||
|
|
|
|||
|
|
@ -37,10 +37,6 @@
|
|||
|
||||
#include "dnssectool.h"
|
||||
|
||||
/*
|
||||
* Infrastructure
|
||||
*/
|
||||
static isc_mem_t *mctx = NULL;
|
||||
/*
|
||||
* The domain we are working on
|
||||
*/
|
||||
|
|
@ -177,14 +173,14 @@ getkasp(ksr_ctx_t *ksr, dns_kasp_t **kasp) {
|
|||
cfg_parser_t *parser = NULL;
|
||||
cfg_obj_t *config = NULL;
|
||||
|
||||
RUNTIME_CHECK(cfg_parser_create(mctx, &parser) == ISC_R_SUCCESS);
|
||||
RUNTIME_CHECK(cfg_parser_create(isc_g_mctx, &parser) == ISC_R_SUCCESS);
|
||||
if (cfg_parse_file(parser, ksr->configfile, &cfg_type_namedconf,
|
||||
&config) != ISC_R_SUCCESS)
|
||||
{
|
||||
fatal("unable to load dnssec-policy '%s' from '%s'",
|
||||
ksr->policy, ksr->configfile);
|
||||
}
|
||||
kasp_from_conf(config, mctx, ksr->policy, ksr->keydir, kasp);
|
||||
kasp_from_conf(config, isc_g_mctx, ksr->policy, ksr->keydir, kasp);
|
||||
if (*kasp == NULL) {
|
||||
fatal("failed to load dnssec-policy '%s'", ksr->policy);
|
||||
}
|
||||
|
|
@ -221,7 +217,7 @@ get_dnskeys(ksr_ctx_t *ksr, dns_dnsseckeylist_t *keys) {
|
|||
ISC_LIST_INIT(*keys);
|
||||
ISC_LIST_INIT(keys_read);
|
||||
ret = dns_dnssec_findmatchingkeys(name, NULL, ksr->keydir, NULL,
|
||||
ksr->now, mctx, &keys_read);
|
||||
ksr->now, isc_g_mctx, &keys_read);
|
||||
if (ret != ISC_R_SUCCESS && ret != ISC_R_NOTFOUND) {
|
||||
fatal("failed to load existing keys from %s: %s", ksr->keydir,
|
||||
isc_result_totext(ret));
|
||||
|
|
@ -230,7 +226,7 @@ get_dnskeys(ksr_ctx_t *ksr, dns_dnsseckeylist_t *keys) {
|
|||
ISC_LIST_FOREACH (keys_read, dk, link) {
|
||||
n++;
|
||||
}
|
||||
keys_sorted = isc_mem_cget(mctx, n, sizeof(dns_dnsseckey_t *));
|
||||
keys_sorted = isc_mem_cget(isc_g_mctx, n, sizeof(dns_dnsseckey_t *));
|
||||
ISC_LIST_FOREACH (keys_read, dk, link) {
|
||||
keys_sorted[i++] = dk;
|
||||
}
|
||||
|
|
@ -243,7 +239,7 @@ get_dnskeys(ksr_ctx_t *ksr, dns_dnsseckeylist_t *keys) {
|
|||
ISC_LIST_APPEND(*keys, keys_sorted[i], link);
|
||||
}
|
||||
INSIST(ISC_LIST_EMPTY(keys_read));
|
||||
isc_mem_cput(mctx, keys_sorted, n, sizeof(dns_dnsseckey_t *));
|
||||
isc_mem_cput(isc_g_mctx, keys_sorted, n, sizeof(dns_dnsseckey_t *));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -265,7 +261,7 @@ cleanup(dns_dnsseckeylist_t *keys, dns_kasp_t *kasp) {
|
|||
ISC_LIST_FOREACH (*keys, key, link) {
|
||||
ISC_LIST_UNLINK(*keys, key, link);
|
||||
dst_key_free(&key->key);
|
||||
dns_dnsseckey_destroy(mctx, &key);
|
||||
dns_dnsseckey_destroy(isc_g_mctx, &key);
|
||||
}
|
||||
dns_kasp_detach(&kasp);
|
||||
|
||||
|
|
@ -310,9 +306,9 @@ freerrset(dns_rdataset_t *rdataset) {
|
|||
|
||||
ISC_LIST_FOREACH (rdlist->rdata, rdata, link) {
|
||||
ISC_LIST_UNLINK(rdlist->rdata, rdata, link);
|
||||
isc_mem_put(mctx, rdata, sizeof(*rdata));
|
||||
isc_mem_put(isc_g_mctx, rdata, sizeof(*rdata));
|
||||
}
|
||||
isc_mem_put(mctx, rdlist, sizeof(*rdlist));
|
||||
isc_mem_put(isc_g_mctx, rdlist, sizeof(*rdlist));
|
||||
dns_rdataset_disassociate(rdataset);
|
||||
}
|
||||
|
||||
|
|
@ -429,19 +425,19 @@ create_key(ksr_ctx_t *ksr, dns_kasp_t *kasp, dns_kasp_key_t *kaspkey,
|
|||
if (ksr->keystore != NULL && ksr->policy != NULL) {
|
||||
ret = dns_keystore_keygen(
|
||||
ksr->keystore, name, ksr->policy,
|
||||
dns_rdataclass_in, mctx, ksr->alg, ksr->size,
|
||||
flags, &key);
|
||||
dns_rdataclass_in, isc_g_mctx, ksr->alg,
|
||||
ksr->size, flags, &key);
|
||||
} else if (show_progress) {
|
||||
ret = dst_key_generate(name, ksr->alg, ksr->size, 0,
|
||||
flags, DNS_KEYPROTO_DNSSEC,
|
||||
dns_rdataclass_in, NULL, mctx,
|
||||
&key, &progress);
|
||||
dns_rdataclass_in, NULL,
|
||||
isc_g_mctx, &key, &progress);
|
||||
fflush(stderr);
|
||||
} else {
|
||||
ret = dst_key_generate(name, ksr->alg, ksr->size, 0,
|
||||
flags, DNS_KEYPROTO_DNSSEC,
|
||||
dns_rdataclass_in, NULL, mctx,
|
||||
&key, NULL);
|
||||
dns_rdataclass_in, NULL,
|
||||
isc_g_mctx, &key, NULL);
|
||||
}
|
||||
|
||||
if (ret != ISC_R_SUCCESS) {
|
||||
|
|
@ -450,7 +446,7 @@ create_key(ksr_ctx_t *ksr, dns_kasp_t *kasp, dns_kasp_key_t *kaspkey,
|
|||
}
|
||||
|
||||
/* Do not overwrite an existing key. */
|
||||
if (key_collision(key, name, ksr->keydir, mctx,
|
||||
if (key_collision(key, name, ksr->keydir, isc_g_mctx,
|
||||
dns_kasp_key_tagmin(kaspkey),
|
||||
dns_kasp_key_tagmax(kaspkey), NULL))
|
||||
{
|
||||
|
|
@ -561,7 +557,7 @@ print_dnskeys(dns_kasp_key_t *kaspkey, dns_ttl_t ttl, dns_dnsseckeylist_t *keys,
|
|||
sizeof(algstr));
|
||||
|
||||
/* Fetch matching key pair. */
|
||||
rdatalist = isc_mem_get(mctx, sizeof(*rdatalist));
|
||||
rdatalist = isc_mem_get(isc_g_mctx, sizeof(*rdatalist));
|
||||
dns_rdatalist_init(rdatalist);
|
||||
rdatalist->rdclass = dns_rdataclass_in;
|
||||
rdatalist->type = dns_rdatatype_dnskey;
|
||||
|
|
@ -596,12 +592,12 @@ print_dnskeys(dns_kasp_key_t *kaspkey, dns_ttl_t ttl, dns_dnsseckeylist_t *keys,
|
|||
isc_region_t r;
|
||||
unsigned char rdatabuf[DST_KEY_MAXSIZE];
|
||||
|
||||
rdata = isc_mem_get(mctx, sizeof(*rdata));
|
||||
rdata = isc_mem_get(isc_g_mctx, sizeof(*rdata));
|
||||
dns_rdata_init(rdata);
|
||||
isc_buffer_init(&buf, rdatabuf, sizeof(rdatabuf));
|
||||
CHECK(dst_key_todns(dk->key, &buf));
|
||||
isc_buffer_usedregion(&buf, &r);
|
||||
isc_buffer_allocate(mctx, &newbuf, r.length);
|
||||
isc_buffer_allocate(isc_g_mctx, &newbuf, r.length);
|
||||
isc_buffer_putmem(newbuf, r.base, r.length);
|
||||
isc_buffer_usedregion(newbuf, &r);
|
||||
dns_rdata_fromregion(rdata, dns_rdataclass_in,
|
||||
|
|
@ -666,7 +662,7 @@ sign_rrset(ksr_ctx_t *ksr, isc_stdtime_t inception, isc_stdtime_t expiration,
|
|||
print_rdata(rrset);
|
||||
|
||||
/* Signatures */
|
||||
rrsiglist = isc_mem_get(mctx, sizeof(*rrsiglist));
|
||||
rrsiglist = isc_mem_get(isc_g_mctx, sizeof(*rrsiglist));
|
||||
dns_rdatalist_init(rrsiglist);
|
||||
rrsiglist->rdclass = dns_rdataclass_in;
|
||||
rrsiglist->type = dns_rdatatype_rrsig;
|
||||
|
|
@ -699,16 +695,16 @@ sign_rrset(ksr_ctx_t *ksr, isc_stdtime_t inception, isc_stdtime_t expiration,
|
|||
continue;
|
||||
}
|
||||
|
||||
rrsig = isc_mem_get(mctx, sizeof(*rrsig));
|
||||
rrsig = isc_mem_get(isc_g_mctx, sizeof(*rrsig));
|
||||
dns_rdata_init(rrsig);
|
||||
isc_buffer_init(&buf, rdatabuf, sizeof(rdatabuf));
|
||||
ret = dns_dnssec_sign(name, rrset, dk->key, &clockskew,
|
||||
&expiration, mctx, &buf, &rdata);
|
||||
&expiration, isc_g_mctx, &buf, &rdata);
|
||||
if (ret != ISC_R_SUCCESS) {
|
||||
fatal("failed to sign KSR");
|
||||
}
|
||||
isc_buffer_usedregion(&buf, &rs);
|
||||
isc_buffer_allocate(mctx, &newbuf, rs.length);
|
||||
isc_buffer_allocate(isc_g_mctx, &newbuf, rs.length);
|
||||
isc_buffer_putmem(newbuf, rs.base, rs.length);
|
||||
isc_buffer_usedregion(newbuf, &rs);
|
||||
dns_rdata_fromregion(rrsig, dns_rdataclass_in,
|
||||
|
|
@ -734,9 +730,11 @@ get_keymaterial(ksr_ctx_t *ksr, dns_kasp_t *kasp, isc_stdtime_t inception,
|
|||
dns_rdataset_t *dnskeyset, dns_rdataset_t *cdnskeyset,
|
||||
dns_rdataset_t *cdsset) {
|
||||
dns_kasp_digestlist_t digests = dns_kasp_digests(kasp);
|
||||
dns_rdatalist_t *dnskeylist = isc_mem_get(mctx, sizeof(*dnskeylist));
|
||||
dns_rdatalist_t *cdnskeylist = isc_mem_get(mctx, sizeof(*cdnskeylist));
|
||||
dns_rdatalist_t *cdslist = isc_mem_get(mctx, sizeof(*cdslist));
|
||||
dns_rdatalist_t *dnskeylist = isc_mem_get(isc_g_mctx,
|
||||
sizeof(*dnskeylist));
|
||||
dns_rdatalist_t *cdnskeylist = isc_mem_get(isc_g_mctx,
|
||||
sizeof(*cdnskeylist));
|
||||
dns_rdatalist_t *cdslist = isc_mem_get(isc_g_mctx, sizeof(*cdslist));
|
||||
isc_result_t ret = ISC_R_SUCCESS;
|
||||
isc_stdtime_t next_bundle = next_inception;
|
||||
|
||||
|
|
@ -782,13 +780,13 @@ get_keymaterial(ksr_ctx_t *ksr, dns_kasp_t *kasp, isc_stdtime_t inception,
|
|||
|
||||
if (published) {
|
||||
newbuf = NULL;
|
||||
rdata = isc_mem_get(mctx, sizeof(*rdata));
|
||||
rdata = isc_mem_get(isc_g_mctx, sizeof(*rdata));
|
||||
dns_rdata_init(rdata);
|
||||
|
||||
isc_buffer_init(&buf, kskbuf, sizeof(kskbuf));
|
||||
CHECK(dst_key_todns(dk->key, &buf));
|
||||
isc_buffer_usedregion(&buf, &r);
|
||||
isc_buffer_allocate(mctx, &newbuf, r.length);
|
||||
isc_buffer_allocate(isc_g_mctx, &newbuf, r.length);
|
||||
isc_buffer_putmem(newbuf, r.base, r.length);
|
||||
isc_buffer_usedregion(newbuf, &r);
|
||||
dns_rdata_fromregion(rdata, dns_rdataclass_in,
|
||||
|
|
@ -826,13 +824,13 @@ get_keymaterial(ksr_ctx_t *ksr, dns_kasp_t *kasp, isc_stdtime_t inception,
|
|||
|
||||
/* CDNSKEY */
|
||||
newbuf = NULL;
|
||||
rdata = isc_mem_get(mctx, sizeof(*rdata));
|
||||
rdata = isc_mem_get(isc_g_mctx, sizeof(*rdata));
|
||||
dns_rdata_init(rdata);
|
||||
|
||||
isc_buffer_init(&buf, cdnskeybuf, sizeof(cdnskeybuf));
|
||||
CHECK(dst_key_todns(dk->key, &buf));
|
||||
isc_buffer_usedregion(&buf, &r);
|
||||
isc_buffer_allocate(mctx, &newbuf, r.length);
|
||||
isc_buffer_allocate(isc_g_mctx, &newbuf, r.length);
|
||||
isc_buffer_putmem(newbuf, r.base, r.length);
|
||||
isc_buffer_usedregion(newbuf, &r);
|
||||
dns_rdata_fromregion(rdata, dns_rdataclass_in,
|
||||
|
|
@ -849,14 +847,14 @@ get_keymaterial(ksr_ctx_t *ksr, dns_kasp_t *kasp, isc_stdtime_t inception,
|
|||
dns_rdata_t *rdata2 = NULL;
|
||||
dns_rdata_t cds = DNS_RDATA_INIT;
|
||||
|
||||
rdata2 = isc_mem_get(mctx, sizeof(*rdata2));
|
||||
rdata2 = isc_mem_get(isc_g_mctx, sizeof(*rdata2));
|
||||
dns_rdata_init(rdata2);
|
||||
|
||||
CHECK(dns_ds_buildrdata(name, rdata, alg->digest,
|
||||
cdsbuf, sizeof(cdsbuf), &cds));
|
||||
cds.type = dns_rdatatype_cds;
|
||||
dns_rdata_toregion(&cds, &rcds);
|
||||
isc_buffer_allocate(mctx, &newbuf2, rcds.length);
|
||||
isc_buffer_allocate(isc_g_mctx, &newbuf2, rcds.length);
|
||||
isc_buffer_putmem(newbuf2, rcds.base, rcds.length);
|
||||
isc_buffer_usedregion(newbuf2, &rcds);
|
||||
dns_rdata_fromregion(rdata2, dns_rdataclass_in,
|
||||
|
|
@ -867,7 +865,7 @@ get_keymaterial(ksr_ctx_t *ksr, dns_kasp_t *kasp, isc_stdtime_t inception,
|
|||
}
|
||||
|
||||
if (!dns_kasp_cdnskey(kasp)) {
|
||||
isc_mem_put(mctx, rdata, sizeof(*rdata));
|
||||
isc_mem_put(isc_g_mctx, rdata, sizeof(*rdata));
|
||||
}
|
||||
}
|
||||
/* All good */
|
||||
|
|
@ -898,7 +896,7 @@ sign_bundle(ksr_ctx_t *ksr, dns_kasp_t *kasp, isc_stdtime_t inception,
|
|||
|
||||
/* DNSKEY RRset */
|
||||
dns_rdatalist_t *dnskeylist;
|
||||
dnskeylist = isc_mem_get(mctx, sizeof(*dnskeylist));
|
||||
dnskeylist = isc_mem_get(isc_g_mctx, sizeof(*dnskeylist));
|
||||
dns_rdatalist_init(dnskeylist);
|
||||
dnskeylist->rdclass = dns_rdataclass_in;
|
||||
dnskeylist->type = dns_rdatatype_dnskey;
|
||||
|
|
@ -918,7 +916,8 @@ sign_bundle(ksr_ctx_t *ksr, dns_kasp_t *kasp, isc_stdtime_t inception,
|
|||
for (isc_result_t r = dns_rdatalist_first(&ksk);
|
||||
r == ISC_R_SUCCESS; r = dns_rdatalist_next(&ksk))
|
||||
{
|
||||
dns_rdata_t *clone = isc_mem_get(mctx, sizeof(*clone));
|
||||
dns_rdata_t *clone = isc_mem_get(isc_g_mctx,
|
||||
sizeof(*clone));
|
||||
dns_rdata_init(clone);
|
||||
dns_rdatalist_current(&ksk, clone);
|
||||
ISC_LIST_APPEND(dnskeylist->rdata, clone, link);
|
||||
|
|
@ -927,7 +926,8 @@ sign_bundle(ksr_ctx_t *ksr, dns_kasp_t *kasp, isc_stdtime_t inception,
|
|||
for (isc_result_t r = dns_rdatalist_first(&zsk);
|
||||
r == ISC_R_SUCCESS; r = dns_rdatalist_next(&zsk))
|
||||
{
|
||||
dns_rdata_t *clone = isc_mem_get(mctx, sizeof(*clone));
|
||||
dns_rdata_t *clone = isc_mem_get(isc_g_mctx,
|
||||
sizeof(*clone));
|
||||
dns_rdata_init(clone);
|
||||
dns_rdatalist_current(&zsk, clone);
|
||||
ISC_LIST_APPEND(dnskeylist->rdata, clone, link);
|
||||
|
|
@ -1027,7 +1027,7 @@ parse_dnskey(isc_lex_t *lex, char *owner, isc_buffer_t *buf, dns_ttl_t *ttl) {
|
|||
}
|
||||
|
||||
ret = dns_rdata_fromtext(NULL, rdclass, dns_rdatatype_dnskey, lex, name,
|
||||
0, mctx, buf, NULL);
|
||||
0, isc_g_mctx, buf, NULL);
|
||||
|
||||
cleanup:
|
||||
isc_lex_setcomments(lex, 0);
|
||||
|
|
@ -1171,7 +1171,7 @@ sign(ksr_ctx_t *ksr) {
|
|||
setcontext(ksr, kasp);
|
||||
/* Sign request */
|
||||
inception = ksr->start;
|
||||
isc_lex_create(mctx, KSR_LINESIZE, &lex);
|
||||
isc_lex_create(isc_g_mctx, KSR_LINESIZE, &lex);
|
||||
memset(specials, 0, sizeof(specials));
|
||||
specials['('] = 1;
|
||||
specials[')'] = 1;
|
||||
|
|
@ -1238,7 +1238,7 @@ sign(ksr_ctx_t *ksr) {
|
|||
}
|
||||
|
||||
/* Start next bundle */
|
||||
rdatalist = isc_mem_get(mctx, sizeof(*rdatalist));
|
||||
rdatalist = isc_mem_get(isc_g_mctx, sizeof(*rdatalist));
|
||||
dns_rdatalist_init(rdatalist);
|
||||
rdatalist->rdclass = dns_rdataclass_in;
|
||||
rdatalist->type = dns_rdatatype_dnskey;
|
||||
|
|
@ -1270,7 +1270,7 @@ sign(ksr_ctx_t *ksr) {
|
|||
|
||||
INSIST(rdatalist != NULL);
|
||||
|
||||
rdata = isc_mem_get(mctx, sizeof(*rdata));
|
||||
rdata = isc_mem_get(isc_g_mctx, sizeof(*rdata));
|
||||
dns_rdata_init(rdata);
|
||||
isc_buffer_init(&buf, rdatabuf, sizeof(rdatabuf));
|
||||
ret = parse_dnskey(lex, STR(token), &buf, &ttl);
|
||||
|
|
@ -1280,7 +1280,7 @@ sign(ksr_ctx_t *ksr) {
|
|||
isc_result_totext(ret));
|
||||
}
|
||||
isc_buffer_usedregion(&buf, &r);
|
||||
isc_buffer_allocate(mctx, &newbuf, r.length);
|
||||
isc_buffer_allocate(isc_g_mctx, &newbuf, r.length);
|
||||
isc_buffer_putmem(newbuf, r.base, r.length);
|
||||
isc_buffer_usedregion(newbuf, &r);
|
||||
dns_rdata_fromregion(rdata, dns_rdataclass_in,
|
||||
|
|
@ -1330,8 +1330,6 @@ main(int argc, char *argv[]) {
|
|||
|
||||
isc_commandline_init(argc, argv);
|
||||
|
||||
isc_mem_create(isc_commandline_progname, &mctx);
|
||||
|
||||
isc_commandline_errprint = false;
|
||||
|
||||
#define OPTIONS "E:e:Ff:hi:K:k:l:ov:V"
|
||||
|
|
|
|||
|
|
@ -36,8 +36,6 @@
|
|||
|
||||
#include "dnssectool.h"
|
||||
|
||||
static isc_mem_t *mctx = NULL;
|
||||
|
||||
ISC_NORETURN static void
|
||||
usage(void);
|
||||
|
||||
|
|
@ -83,8 +81,6 @@ main(int argc, char **argv) {
|
|||
usage();
|
||||
}
|
||||
|
||||
isc_mem_create(isc_commandline_progname, &mctx);
|
||||
|
||||
isc_commandline_errprint = false;
|
||||
|
||||
while ((ch = isc_commandline_parse(argc, argv, "E:fK:rRhv:V")) != -1) {
|
||||
|
|
@ -100,7 +96,8 @@ main(int argc, char **argv) {
|
|||
* We don't have to copy it here, but do it to
|
||||
* simplify cleanup later
|
||||
*/
|
||||
dir = isc_mem_strdup(mctx, isc_commandline_argument);
|
||||
dir = isc_mem_strdup(isc_g_mctx,
|
||||
isc_commandline_argument);
|
||||
break;
|
||||
case 'r':
|
||||
removefile = true;
|
||||
|
|
@ -149,20 +146,22 @@ main(int argc, char **argv) {
|
|||
if (dir != NULL) {
|
||||
filename = argv[isc_commandline_index];
|
||||
} else {
|
||||
result = isc_file_splitpath(mctx, argv[isc_commandline_index],
|
||||
&dir, &filename);
|
||||
result = isc_file_splitpath(isc_g_mctx,
|
||||
argv[isc_commandline_index], &dir,
|
||||
&filename);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fatal("cannot process filename %s: %s",
|
||||
argv[isc_commandline_index],
|
||||
isc_result_totext(result));
|
||||
}
|
||||
if (strcmp(dir, ".") == 0) {
|
||||
isc_mem_free(mctx, dir);
|
||||
isc_mem_free(isc_g_mctx, dir);
|
||||
}
|
||||
}
|
||||
|
||||
result = dst_key_fromnamedfile(
|
||||
filename, dir, DST_TYPE_PUBLIC | DST_TYPE_PRIVATE, mctx, &key);
|
||||
result = dst_key_fromnamedfile(filename, dir,
|
||||
DST_TYPE_PUBLIC | DST_TYPE_PRIVATE,
|
||||
isc_g_mctx, &key);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fatal("Invalid keyfile name %s: %s", filename,
|
||||
isc_result_totext(result));
|
||||
|
|
@ -245,12 +244,11 @@ main(int argc, char **argv) {
|
|||
cleanup:
|
||||
dst_key_free(&key);
|
||||
if (verbose > 10) {
|
||||
isc_mem_stats(mctx, stdout);
|
||||
isc_mem_stats(isc_g_mctx, stdout);
|
||||
}
|
||||
if (dir != NULL) {
|
||||
isc_mem_free(mctx, dir);
|
||||
isc_mem_free(isc_g_mctx, dir);
|
||||
}
|
||||
isc_mem_detach(&mctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,8 +40,6 @@
|
|||
|
||||
#include "dnssectool.h"
|
||||
|
||||
static isc_mem_t *mctx = NULL;
|
||||
|
||||
ISC_NORETURN static void
|
||||
usage(void);
|
||||
|
||||
|
|
@ -245,8 +243,6 @@ main(int argc, char **argv) {
|
|||
usage();
|
||||
}
|
||||
|
||||
isc_mem_create(isc_commandline_progname, &mctx);
|
||||
|
||||
setup_logging();
|
||||
|
||||
isc_commandline_errprint = false;
|
||||
|
|
@ -362,7 +358,7 @@ main(int argc, char **argv) {
|
|||
* We don't have to copy it here, but do it to
|
||||
* simplify cleanup later
|
||||
*/
|
||||
directory = isc_mem_strdup(mctx,
|
||||
directory = isc_mem_strdup(isc_g_mctx,
|
||||
isc_commandline_argument);
|
||||
break;
|
||||
case 'k':
|
||||
|
|
@ -572,7 +568,7 @@ main(int argc, char **argv) {
|
|||
}
|
||||
|
||||
result = dst_key_fromnamedfile(predecessor, directory, options,
|
||||
mctx, &prevkey);
|
||||
isc_g_mctx, &prevkey);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fatal("Invalid keyfile %s: %s", filename,
|
||||
isc_result_totext(result));
|
||||
|
|
@ -670,7 +666,8 @@ main(int argc, char **argv) {
|
|||
if (directory != NULL) {
|
||||
filename = argv[isc_commandline_index];
|
||||
} else {
|
||||
result = isc_file_splitpath(mctx, argv[isc_commandline_index],
|
||||
result = isc_file_splitpath(isc_g_mctx,
|
||||
argv[isc_commandline_index],
|
||||
&directory, &filename);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fatal("cannot process filename %s: %s",
|
||||
|
|
@ -679,7 +676,7 @@ main(int argc, char **argv) {
|
|||
}
|
||||
}
|
||||
|
||||
result = dst_key_fromnamedfile(filename, directory, options, mctx,
|
||||
result = dst_key_fromnamedfile(filename, directory, options, isc_g_mctx,
|
||||
&key);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fatal("Invalid keyfile %s: %s", filename,
|
||||
|
|
@ -949,10 +946,9 @@ main(int argc, char **argv) {
|
|||
}
|
||||
dst_key_free(&key);
|
||||
if (verbose > 10) {
|
||||
isc_mem_stats(mctx, stdout);
|
||||
isc_mem_stats(isc_g_mctx, stdout);
|
||||
}
|
||||
isc_mem_free(mctx, directory);
|
||||
isc_mem_detach(&mctx);
|
||||
isc_mem_free(isc_g_mctx, directory);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -125,7 +125,6 @@ static int cycle = -1;
|
|||
static int jitter = 0;
|
||||
static bool tryverify = false;
|
||||
static bool printstats = false;
|
||||
static isc_mem_t *mctx = NULL;
|
||||
static dns_ttl_t zone_soa_min_ttl;
|
||||
static dns_ttl_t soa_ttl;
|
||||
static FILE *outfp = NULL;
|
||||
|
|
@ -208,7 +207,7 @@ dumpnode(dns_name_t *name, dns_dbnode_t *node) {
|
|||
result = dns_db_allrdatasets(gdb, node, gversion, 0, 0, &iter);
|
||||
check_result(result, "dns_db_allrdatasets");
|
||||
|
||||
isc_buffer_allocate(mctx, &buffer, bufsize);
|
||||
isc_buffer_allocate(isc_g_mctx, &buffer, bufsize);
|
||||
|
||||
DNS_RDATASETITER_FOREACH (iter) {
|
||||
dns_rdataset_t rds = DNS_RDATASET_INIT;
|
||||
|
|
@ -233,7 +232,7 @@ dumpnode(dns_name_t *name, dns_dbnode_t *node) {
|
|||
|
||||
bufsize <<= 1;
|
||||
isc_buffer_free(&buffer);
|
||||
isc_buffer_allocate(mctx, &buffer, bufsize);
|
||||
isc_buffer_allocate(isc_g_mctx, &buffer, bufsize);
|
||||
}
|
||||
check_result(result, "dns_master_rdatasettotext");
|
||||
|
||||
|
|
@ -287,7 +286,7 @@ signwithkey(dns_name_t *name, dns_rdataset_t *rdataset, dst_key_t *key,
|
|||
jendtime = (jitter != 0) ? expiry - isc_random_uniform(jitter) : expiry;
|
||||
isc_buffer_init(&b, array, sizeof(array));
|
||||
result = dns_dnssec_sign(name, rdataset, key, &starttime, &jendtime,
|
||||
mctx, &b, &trdata);
|
||||
isc_g_mctx, &b, &trdata);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fatal("dnskey '%s' failed to sign data: %s", keystr,
|
||||
isc_result_totext(result));
|
||||
|
|
@ -295,8 +294,8 @@ signwithkey(dns_name_t *name, dns_rdataset_t *rdataset, dst_key_t *key,
|
|||
INCSTAT(nsigned);
|
||||
|
||||
if (tryverify) {
|
||||
result = dns_dnssec_verify(name, rdataset, key, true, mctx,
|
||||
&trdata, NULL);
|
||||
result = dns_dnssec_verify(name, rdataset, key, true,
|
||||
isc_g_mctx, &trdata, NULL);
|
||||
if (result == ISC_R_SUCCESS || result == DNS_R_FROMWILDCARD) {
|
||||
vbprintf(3, "\tsignature verified\n");
|
||||
INCSTAT(nverified);
|
||||
|
|
@ -307,8 +306,8 @@ signwithkey(dns_name_t *name, dns_rdataset_t *rdataset, dst_key_t *key,
|
|||
}
|
||||
|
||||
tuple = NULL;
|
||||
dns_difftuple_create(mctx, DNS_DIFFOP_ADDRESIGN, name, ttl, &trdata,
|
||||
&tuple);
|
||||
dns_difftuple_create(isc_g_mctx, DNS_DIFFOP_ADDRESIGN, name, ttl,
|
||||
&trdata, &tuple);
|
||||
dns_diff_append(add, &tuple);
|
||||
}
|
||||
|
||||
|
|
@ -393,20 +392,21 @@ keythatsigned(dns_rdata_rrsig_t *rrsig) {
|
|||
|
||||
result = dst_key_fromfile(&rrsig->signer, rrsig->keyid,
|
||||
rrsig->algorithm, DST_TYPE_PUBLIC, directory,
|
||||
mctx, &pubkey);
|
||||
isc_g_mctx, &pubkey);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_rwlock_unlock(&keylist_lock, isc_rwlocktype_write);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
result = dst_key_fromfile(
|
||||
&rrsig->signer, rrsig->keyid, rrsig->algorithm,
|
||||
DST_TYPE_PUBLIC | DST_TYPE_PRIVATE, directory, mctx, &privkey);
|
||||
result = dst_key_fromfile(&rrsig->signer, rrsig->keyid,
|
||||
rrsig->algorithm,
|
||||
DST_TYPE_PUBLIC | DST_TYPE_PRIVATE, directory,
|
||||
isc_g_mctx, &privkey);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
dst_key_free(&pubkey);
|
||||
dns_dnsseckey_create(mctx, &privkey, &key);
|
||||
dns_dnsseckey_create(isc_g_mctx, &privkey, &key);
|
||||
} else {
|
||||
dns_dnsseckey_create(mctx, &pubkey, &key);
|
||||
dns_dnsseckey_create(isc_g_mctx, &pubkey, &key);
|
||||
key->pubkey = true;
|
||||
}
|
||||
|
||||
|
|
@ -455,7 +455,8 @@ static bool
|
|||
setverifies(dns_name_t *name, dns_rdataset_t *set, dst_key_t *key,
|
||||
dns_rdata_t *rrsig) {
|
||||
isc_result_t result;
|
||||
result = dns_dnssec_verify(name, set, key, false, mctx, rrsig, NULL);
|
||||
result = dns_dnssec_verify(name, set, key, false, isc_g_mctx, rrsig,
|
||||
NULL);
|
||||
if (result == ISC_R_SUCCESS || result == DNS_R_FROMWILDCARD) {
|
||||
INCSTAT(nverified);
|
||||
return true;
|
||||
|
|
@ -511,8 +512,8 @@ signset(dns_diff_t *del, dns_diff_t *add, dns_dbnode_t *node, dns_name_t *name,
|
|||
if (!nosigs) {
|
||||
arraysize += dns_rdataset_count(&sigset);
|
||||
}
|
||||
wassignedby = isc_mem_cget(mctx, arraysize, sizeof(bool));
|
||||
nowsignedby = isc_mem_cget(mctx, arraysize, sizeof(bool));
|
||||
wassignedby = isc_mem_cget(isc_g_mctx, arraysize, sizeof(bool));
|
||||
nowsignedby = isc_mem_cget(isc_g_mctx, arraysize, sizeof(bool));
|
||||
|
||||
for (i = 0; i < arraysize; i++) {
|
||||
wassignedby[i] = nowsignedby[i] = false;
|
||||
|
|
@ -642,22 +643,23 @@ signset(dns_diff_t *del, dns_diff_t *add, dns_dbnode_t *node, dns_name_t *name,
|
|||
sigstr);
|
||||
tuple = NULL;
|
||||
dns_difftuple_create(
|
||||
mctx, DNS_DIFFOP_DELRESIGN,
|
||||
name, sigset.ttl, &sigrdata,
|
||||
&tuple);
|
||||
isc_g_mctx,
|
||||
DNS_DIFFOP_DELRESIGN, name,
|
||||
sigset.ttl, &sigrdata, &tuple);
|
||||
dns_diff_append(del, &tuple);
|
||||
dns_difftuple_create(
|
||||
mctx, DNS_DIFFOP_ADDRESIGN,
|
||||
name, ttl, &sigrdata, &tuple);
|
||||
isc_g_mctx,
|
||||
DNS_DIFFOP_ADDRESIGN, name, ttl,
|
||||
&sigrdata, &tuple);
|
||||
dns_diff_append(add, &tuple);
|
||||
}
|
||||
} else {
|
||||
tuple = NULL;
|
||||
vbprintf(2, "\tremoving signature by %s\n",
|
||||
sigstr);
|
||||
dns_difftuple_create(mctx, DNS_DIFFOP_DELRESIGN,
|
||||
name, sigset.ttl,
|
||||
&sigrdata, &tuple);
|
||||
dns_difftuple_create(
|
||||
isc_g_mctx, DNS_DIFFOP_DELRESIGN, name,
|
||||
sigset.ttl, &sigrdata, &tuple);
|
||||
dns_diff_append(del, &tuple);
|
||||
INCSTAT(ndropped);
|
||||
}
|
||||
|
|
@ -779,8 +781,8 @@ signset(dns_diff_t *del, dns_diff_t *add, dns_dbnode_t *node, dns_name_t *name,
|
|||
}
|
||||
}
|
||||
|
||||
isc_mem_cput(mctx, wassignedby, arraysize, sizeof(bool));
|
||||
isc_mem_cput(mctx, nowsignedby, arraysize, sizeof(bool));
|
||||
isc_mem_cput(isc_g_mctx, wassignedby, arraysize, sizeof(bool));
|
||||
isc_mem_cput(isc_g_mctx, nowsignedby, arraysize, sizeof(bool));
|
||||
}
|
||||
|
||||
struct hashlist {
|
||||
|
|
@ -995,7 +997,7 @@ opendb(const char *prefix, dns_name_t *name, dns_rdataclass_t rdclass,
|
|||
}
|
||||
isc_buffer_putuint8(&b, 0);
|
||||
|
||||
result = dns_db_create(mctx, ZONEDB_DEFAULT, dns_rootname,
|
||||
result = dns_db_create(isc_g_mctx, ZONEDB_DEFAULT, dns_rootname,
|
||||
dns_dbtype_zone, rdclass, 0, NULL, dbp);
|
||||
check_result(result, "dns_db_create()");
|
||||
|
||||
|
|
@ -1064,7 +1066,7 @@ loadds(dns_name_t *name, uint32_t ttl, dns_rdataset_t *dsset) {
|
|||
|
||||
result = dns_db_newversion(db, &ver);
|
||||
check_result(result, "dns_db_newversion");
|
||||
dns_diff_init(mctx, &diff);
|
||||
dns_diff_init(isc_g_mctx, &diff);
|
||||
|
||||
DNS_RDATASET_FOREACH (&keyset) {
|
||||
dns_rdata_t key = DNS_RDATA_INIT;
|
||||
|
|
@ -1074,8 +1076,8 @@ loadds(dns_name_t *name, uint32_t ttl, dns_rdataset_t *dsset) {
|
|||
dsbuf, sizeof(dsbuf), &ds);
|
||||
check_result(result, "dns_ds_buildrdata");
|
||||
|
||||
dns_difftuple_create(mctx, DNS_DIFFOP_ADDRESIGN, name, ttl, &ds,
|
||||
&tuple);
|
||||
dns_difftuple_create(isc_g_mctx, DNS_DIFFOP_ADDRESIGN, name,
|
||||
ttl, &ds, &tuple);
|
||||
dns_diff_append(&diff, &tuple);
|
||||
}
|
||||
|
||||
|
|
@ -1181,8 +1183,8 @@ signname(dns_dbnode_t *node, bool apex, dns_name_t *name) {
|
|||
/*
|
||||
* Now iterate through the rdatasets.
|
||||
*/
|
||||
dns_diff_init(mctx, &del);
|
||||
dns_diff_init(mctx, &add);
|
||||
dns_diff_init(isc_g_mctx, &del);
|
||||
dns_diff_init(isc_g_mctx, &add);
|
||||
rdsiter = NULL;
|
||||
result = dns_db_allrdatasets(gdb, node, gversion, 0, 0, &rdsiter);
|
||||
check_result(result, "dns_db_allrdatasets()");
|
||||
|
|
@ -2130,9 +2132,9 @@ rrset_cleanup(dns_name_t *name, dns_rdataset_t *rdataset, dns_diff_t *add,
|
|||
{
|
||||
vbprintf(2, "removing duplicate at %s/%s\n",
|
||||
namestr, typestr);
|
||||
dns_difftuple_create(mctx, DNS_DIFFOP_DELRESIGN,
|
||||
name, rdataset->ttl,
|
||||
&rdata2, &tuple);
|
||||
dns_difftuple_create(
|
||||
isc_g_mctx, DNS_DIFFOP_DELRESIGN, name,
|
||||
rdataset->ttl, &rdata2, &tuple);
|
||||
dns_diff_append(del, &tuple);
|
||||
} else if (set_maxttl && rdataset->ttl > maxttl) {
|
||||
vbprintf(2,
|
||||
|
|
@ -2140,14 +2142,14 @@ rrset_cleanup(dns_name_t *name, dns_rdataset_t *rdataset, dns_diff_t *add,
|
|||
"from %d to %d\n",
|
||||
namestr, typestr, rdataset->ttl,
|
||||
maxttl);
|
||||
dns_difftuple_create(mctx, DNS_DIFFOP_DELRESIGN,
|
||||
name, rdataset->ttl,
|
||||
&rdata2, &tuple);
|
||||
dns_difftuple_create(
|
||||
isc_g_mctx, DNS_DIFFOP_DELRESIGN, name,
|
||||
rdataset->ttl, &rdata2, &tuple);
|
||||
dns_diff_append(del, &tuple);
|
||||
tuple = NULL;
|
||||
dns_difftuple_create(mctx, DNS_DIFFOP_ADDRESIGN,
|
||||
name, maxttl, &rdata2,
|
||||
&tuple);
|
||||
dns_difftuple_create(isc_g_mctx,
|
||||
DNS_DIFFOP_ADDRESIGN, name,
|
||||
maxttl, &rdata2, &tuple);
|
||||
dns_diff_append(add, &tuple);
|
||||
}
|
||||
}
|
||||
|
|
@ -2165,8 +2167,8 @@ cleanup_zone(void) {
|
|||
dns_fixedname_t fname;
|
||||
dns_name_t *name = dns_fixedname_initname(&fname);
|
||||
|
||||
dns_diff_init(mctx, &add);
|
||||
dns_diff_init(mctx, &del);
|
||||
dns_diff_init(isc_g_mctx, &add);
|
||||
dns_diff_init(isc_g_mctx, &del);
|
||||
|
||||
result = dns_db_createiterator(gdb, 0, &dbiter);
|
||||
check_result(result, "dns_db_createiterator()");
|
||||
|
|
@ -2487,8 +2489,8 @@ loadzone(char *file, char *origin, dns_rdataclass_t rdclass, dns_db_t **db) {
|
|||
isc_result_totext(result));
|
||||
}
|
||||
|
||||
result = dns_db_create(mctx, ZONEDB_DEFAULT, name, dns_dbtype_zone,
|
||||
rdclass, 0, NULL, db);
|
||||
result = dns_db_create(isc_g_mctx, ZONEDB_DEFAULT, name,
|
||||
dns_dbtype_zone, rdclass, 0, NULL, db);
|
||||
check_result(result, "dns_db_create()");
|
||||
|
||||
result = dns_db_load(*db, file, inputformat, 0);
|
||||
|
|
@ -2554,8 +2556,8 @@ loadzonekeys(bool preserve_keys, bool load_public) {
|
|||
|
||||
/* Load keys corresponding to the existing DNSKEY RRset. */
|
||||
result = dns_dnssec_keylistfromrdataset(
|
||||
gorigin, NULL, directory, mctx, &rdataset, &keysigs, &soasigs,
|
||||
preserve_keys, load_public, &keylist);
|
||||
gorigin, NULL, directory, isc_g_mctx, &rdataset, &keysigs,
|
||||
&soasigs, preserve_keys, load_public, &keylist);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fatal("failed to load the zone keys: %s",
|
||||
isc_result_totext(result));
|
||||
|
|
@ -2584,9 +2586,10 @@ loadexplicitkeys(char *keyfiles[], int n, bool setksk) {
|
|||
dns_dnsseckey_t *key = NULL;
|
||||
dst_key_t *newkey = NULL;
|
||||
|
||||
result = dst_key_fromnamedfile(
|
||||
keyfiles[i], directory,
|
||||
DST_TYPE_PUBLIC | DST_TYPE_PRIVATE, mctx, &newkey);
|
||||
result = dst_key_fromnamedfile(keyfiles[i], directory,
|
||||
DST_TYPE_PUBLIC |
|
||||
DST_TYPE_PRIVATE,
|
||||
isc_g_mctx, &newkey);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fatal("cannot load dnskey %s: %s", keyfiles[i],
|
||||
isc_result_totext(result));
|
||||
|
|
@ -2613,7 +2616,7 @@ loadexplicitkeys(char *keyfiles[], int n, bool setksk) {
|
|||
|
||||
if (key == NULL) {
|
||||
/* We haven't seen this key before */
|
||||
dns_dnsseckey_create(mctx, &newkey, &key);
|
||||
dns_dnsseckey_create(isc_g_mctx, &newkey, &key);
|
||||
ISC_LIST_APPEND(keylist, key, link);
|
||||
key->source = dns_keysource_user;
|
||||
} else {
|
||||
|
|
@ -2648,7 +2651,7 @@ static void
|
|||
clear_keylist(dns_dnsseckeylist_t *list) {
|
||||
ISC_LIST_FOREACH (*list, key, link) {
|
||||
ISC_LIST_UNLINK(*list, key, link);
|
||||
dns_dnsseckey_destroy(mctx, &key);
|
||||
dns_dnsseckey_destroy(isc_g_mctx, &key);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2689,7 +2692,7 @@ add_digest(char *str, size_t dlen, dns_kasp_digestlist_t *digests,
|
|||
}
|
||||
}
|
||||
|
||||
digest = isc_mem_get(mctx, sizeof(*digest));
|
||||
digest = isc_mem_get(isc_g_mctx, sizeof(*digest));
|
||||
digest->digest = alg;
|
||||
ISC_LINK_INIT(digest, link);
|
||||
ISC_LIST_APPEND(*digests, digest, link);
|
||||
|
|
@ -2740,7 +2743,7 @@ findkeys:
|
|||
* Find keys that match this zone in the key repository.
|
||||
*/
|
||||
result = dns_dnssec_findmatchingkeys(gorigin, NULL, directory, NULL,
|
||||
now, mctx, &matchkeys);
|
||||
now, isc_g_mctx, &matchkeys);
|
||||
if (result == ISC_R_NOTFOUND) {
|
||||
result = ISC_R_SUCCESS;
|
||||
}
|
||||
|
|
@ -2766,20 +2769,20 @@ findkeys:
|
|||
dns_rdataset_disassociate(&cdnskeyset);
|
||||
}
|
||||
|
||||
dns_diff_init(mctx, &diff);
|
||||
dns_diff_init(isc_g_mctx, &diff);
|
||||
|
||||
/*
|
||||
* Update keylist with information from from the key repository.
|
||||
*/
|
||||
dns_dnssec_updatekeys(&keylist, &matchkeys, NULL, gorigin, keyttl,
|
||||
&diff, mctx, report);
|
||||
&diff, isc_g_mctx, report);
|
||||
|
||||
/*
|
||||
* Update keylist with sync records.
|
||||
*/
|
||||
|
||||
dns_dnssec_syncupdate(&keylist, &rmkeys, &cdsset, &cdnskeyset, now,
|
||||
&digests, cdnskey, keyttl, &diff, mctx);
|
||||
&digests, cdnskey, keyttl, &diff, isc_g_mctx);
|
||||
|
||||
dns_name_format(gorigin, name, sizeof(name));
|
||||
|
||||
|
|
@ -2806,7 +2809,7 @@ findkeys:
|
|||
|
||||
ISC_LIST_FOREACH (digests, d, link) {
|
||||
ISC_LIST_UNLINK(digests, d, link);
|
||||
isc_mem_put(mctx, d, sizeof(*d));
|
||||
isc_mem_put(isc_g_mctx, d, sizeof(*d));
|
||||
}
|
||||
INSIST(ISC_LIST_EMPTY(digests));
|
||||
}
|
||||
|
|
@ -3001,7 +3004,7 @@ writeset(const char *prefix, dns_rdatatype_t type) {
|
|||
if (dsdir != NULL) {
|
||||
filenamelen += strlen(dsdir) + 1;
|
||||
}
|
||||
filename = isc_mem_get(mctx, filenamelen);
|
||||
filename = isc_mem_get(isc_g_mctx, filenamelen);
|
||||
if (dsdir != NULL) {
|
||||
snprintf(filename, filenamelen, "%s/", dsdir);
|
||||
} else {
|
||||
|
|
@ -3010,7 +3013,7 @@ writeset(const char *prefix, dns_rdatatype_t type) {
|
|||
strlcat(filename, prefix, filenamelen);
|
||||
strlcat(filename, namestr, filenamelen);
|
||||
|
||||
dns_diff_init(mctx, &diff);
|
||||
dns_diff_init(isc_g_mctx, &diff);
|
||||
|
||||
name = gorigin;
|
||||
|
||||
|
|
@ -3054,17 +3057,17 @@ writeset(const char *prefix, dns_rdatatype_t type) {
|
|||
DNS_DSDIGEST_SHA256, dsbuf,
|
||||
sizeof(dsbuf), &ds);
|
||||
check_result(result, "dns_ds_buildrdata");
|
||||
dns_difftuple_create(mctx, DNS_DIFFOP_ADDRESIGN, name,
|
||||
0, &ds, &tuple);
|
||||
dns_difftuple_create(isc_g_mctx, DNS_DIFFOP_ADDRESIGN,
|
||||
name, 0, &ds, &tuple);
|
||||
} else {
|
||||
dns_difftuple_create(mctx, DNS_DIFFOP_ADDRESIGN,
|
||||
dns_difftuple_create(isc_g_mctx, DNS_DIFFOP_ADDRESIGN,
|
||||
gorigin, zone_soa_min_ttl, &rdata,
|
||||
&tuple);
|
||||
}
|
||||
dns_diff_append(&diff, &tuple);
|
||||
}
|
||||
|
||||
result = dns_db_create(mctx, ZONEDB_DEFAULT, dns_rootname,
|
||||
result = dns_db_create(isc_g_mctx, ZONEDB_DEFAULT, dns_rootname,
|
||||
dns_dbtype_zone, gclass, 0, NULL, &db);
|
||||
check_result(result, "dns_db_create");
|
||||
|
||||
|
|
@ -3075,11 +3078,11 @@ writeset(const char *prefix, dns_rdatatype_t type) {
|
|||
check_result(result, "dns_diff_apply");
|
||||
dns_diff_clear(&diff);
|
||||
|
||||
result = dns_master_dump(mctx, db, dbversion, style, filename,
|
||||
result = dns_master_dump(isc_g_mctx, db, dbversion, style, filename,
|
||||
dns_masterformat_text, NULL);
|
||||
check_result(result, "dns_master_dump");
|
||||
|
||||
isc_mem_put(mctx, filename, filenamelen);
|
||||
isc_mem_put(isc_g_mctx, filename, filenamelen);
|
||||
|
||||
dns_db_closeversion(db, &dbversion, false);
|
||||
dns_db_detach(&db);
|
||||
|
|
@ -3294,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:
|
||||
|
|
@ -3635,7 +3638,7 @@ main(int argc, char *argv[]) {
|
|||
directory = ".";
|
||||
}
|
||||
|
||||
isc_managers_create(&mctx, nloops);
|
||||
isc_managers_create(nloops);
|
||||
|
||||
setup_logging();
|
||||
|
||||
|
|
@ -3659,7 +3662,7 @@ main(int argc, char *argv[]) {
|
|||
size_t size;
|
||||
free_output = true;
|
||||
size = strlen(file) + strlen(".signed") + 1;
|
||||
output = isc_mem_allocate(mctx, size);
|
||||
output = isc_mem_allocate(isc_g_mctx, size);
|
||||
snprintf(output, size, "%s.signed", file);
|
||||
}
|
||||
|
||||
|
|
@ -3730,14 +3733,14 @@ main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
result = dns_master_stylecreate(&dsstyle, DNS_STYLEFLAG_NO_TTL, 0, 24,
|
||||
0, 0, 0, 8, 0xffffffff, mctx);
|
||||
0, 0, 0, 8, 0xffffffff, isc_g_mctx);
|
||||
check_result(result, "dns_master_stylecreate");
|
||||
|
||||
gdb = NULL;
|
||||
timer_start = isc_time_now();
|
||||
loadzone(file, origin, rdclass, &gdb);
|
||||
if (journal != NULL) {
|
||||
loadjournal(mctx, gdb, journal);
|
||||
loadjournal(isc_g_mctx, gdb, journal);
|
||||
}
|
||||
gorigin = dns_db_origin(gdb);
|
||||
gclass = dns_db_class(gdb);
|
||||
|
|
@ -3898,7 +3901,7 @@ main(int argc, char *argv[]) {
|
|||
}
|
||||
} else {
|
||||
tempfilelen = strlen(output) + 20;
|
||||
tempfile = isc_mem_get(mctx, tempfilelen);
|
||||
tempfile = isc_mem_get(isc_g_mctx, tempfilelen);
|
||||
|
||||
result = isc_file_mktemplate(output, tempfile, tempfilelen);
|
||||
check_result(result, "isc_file_mktemplate");
|
||||
|
|
@ -3939,9 +3942,9 @@ main(int argc, char *argv[]) {
|
|||
if (disable_zone_check) {
|
||||
vresult = ISC_R_SUCCESS;
|
||||
} else {
|
||||
vresult = dns_zoneverify_dnssec(NULL, gdb, gversion, gorigin,
|
||||
NULL, mctx, ignore_kskflag,
|
||||
keyset_kskonly, report);
|
||||
vresult = dns_zoneverify_dnssec(
|
||||
NULL, gdb, gversion, gorigin, NULL, isc_g_mctx,
|
||||
ignore_kskflag, keyset_kskonly, report);
|
||||
if (vresult != ISC_R_SUCCESS) {
|
||||
fprintf(output_stdout ? stderr : stdout,
|
||||
"Zone verification failed (%s)\n",
|
||||
|
|
@ -3958,7 +3961,7 @@ main(int argc, char *argv[]) {
|
|||
header.flags = DNS_MASTERRAW_SOURCESERIALSET;
|
||||
header.sourceserial = serialnum;
|
||||
}
|
||||
result = dns_master_dumptostream(mctx, gdb, gversion,
|
||||
result = dns_master_dumptostream(isc_g_mctx, gdb, gversion,
|
||||
masterstyle, outputformat,
|
||||
&header, outfp);
|
||||
check_result(result, "dns_master_dumptostream");
|
||||
|
|
@ -3988,24 +3991,24 @@ main(int argc, char *argv[]) {
|
|||
|
||||
ISC_LIST_FOREACH (keylist, key, link) {
|
||||
ISC_LIST_UNLINK(keylist, key, link);
|
||||
dns_dnsseckey_destroy(mctx, &key);
|
||||
dns_dnsseckey_destroy(isc_g_mctx, &key);
|
||||
}
|
||||
|
||||
if (tempfilelen != 0) {
|
||||
isc_mem_put(mctx, tempfile, tempfilelen);
|
||||
isc_mem_put(isc_g_mctx, tempfile, tempfilelen);
|
||||
}
|
||||
|
||||
if (free_output) {
|
||||
isc_mem_free(mctx, output);
|
||||
isc_mem_free(isc_g_mctx, output);
|
||||
}
|
||||
|
||||
dns_master_styledestroy(&dsstyle, mctx);
|
||||
dns_master_styledestroy(&dsstyle, isc_g_mctx);
|
||||
|
||||
if (verbose > 10) {
|
||||
isc_mem_stats(mctx, stdout);
|
||||
isc_mem_stats(isc_g_mctx, stdout);
|
||||
}
|
||||
|
||||
isc_managers_destroy(&mctx);
|
||||
isc_managers_destroy();
|
||||
|
||||
if (printstats) {
|
||||
timer_finish = isc_time_now();
|
||||
|
|
|
|||
|
|
@ -64,7 +64,6 @@
|
|||
#include "dnssectool.h"
|
||||
|
||||
static isc_stdtime_t now;
|
||||
static isc_mem_t *mctx = NULL;
|
||||
static dns_masterformat_t inputformat = dns_masterformat_text;
|
||||
static dns_db_t *gdb = NULL; /* The database */
|
||||
static dns_dbversion_t *gversion = NULL; /* The database version */
|
||||
|
|
@ -108,8 +107,8 @@ loadzone(char *file, char *origin, dns_rdataclass_t rdclass, dns_db_t **db) {
|
|||
isc_result_totext(result));
|
||||
}
|
||||
|
||||
result = dns_db_create(mctx, ZONEDB_DEFAULT, name, dns_dbtype_zone,
|
||||
rdclass, 0, NULL, db);
|
||||
result = dns_db_create(isc_g_mctx, ZONEDB_DEFAULT, name,
|
||||
dns_dbtype_zone, rdclass, 0, NULL, db);
|
||||
check_result(result, "dns_db_create()");
|
||||
|
||||
result = dns_db_load(*db, file, inputformat, 0);
|
||||
|
|
@ -185,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:
|
||||
|
|
@ -202,8 +201,6 @@ main(int argc, char *argv[]) {
|
|||
}
|
||||
isc_commandline_reset = true;
|
||||
|
||||
isc_mem_create(isc_commandline_progname, &mctx);
|
||||
|
||||
isc_commandline_errprint = false;
|
||||
|
||||
while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) {
|
||||
|
|
@ -314,7 +311,7 @@ main(int argc, char *argv[]) {
|
|||
report("Loading zone '%s' from file '%s'\n", origin, file);
|
||||
loadzone(file, origin, rdclass, &gdb);
|
||||
if (journal != NULL) {
|
||||
loadjournal(mctx, gdb, journal);
|
||||
loadjournal(isc_g_mctx, gdb, journal);
|
||||
}
|
||||
gorigin = dns_db_origin(gdb);
|
||||
gclass = dns_db_class(gdb);
|
||||
|
|
@ -323,16 +320,16 @@ main(int argc, char *argv[]) {
|
|||
result = dns_db_newversion(gdb, &gversion);
|
||||
check_result(result, "dns_db_newversion()");
|
||||
|
||||
result = dns_zoneverify_dnssec(NULL, gdb, gversion, gorigin, NULL, mctx,
|
||||
ignore_kskflag, keyset_kskonly, report);
|
||||
result = dns_zoneverify_dnssec(NULL, gdb, gversion, gorigin, NULL,
|
||||
isc_g_mctx, ignore_kskflag,
|
||||
keyset_kskonly, report);
|
||||
|
||||
dns_db_closeversion(gdb, &gversion, false);
|
||||
dns_db_detach(&gdb);
|
||||
|
||||
if (verbose > 10) {
|
||||
isc_mem_stats(mctx, stdout);
|
||||
isc_mem_stats(isc_g_mctx, stdout);
|
||||
}
|
||||
isc_mem_detach(&mctx);
|
||||
|
||||
return result == ISC_R_SUCCESS ? 0 : 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -711,10 +711,10 @@ destroy(dns_db_t *db) {
|
|||
isc_refcount_destroy(&bdb->common.references);
|
||||
|
||||
if (bdb->server != NULL) {
|
||||
isc_mem_free(named_g_mctx, bdb->server);
|
||||
isc_mem_free(isc_g_mctx, bdb->server);
|
||||
}
|
||||
if (bdb->contact != NULL) {
|
||||
isc_mem_free(named_g_mctx, bdb->contact);
|
||||
isc_mem_free(isc_g_mctx, bdb->contact);
|
||||
}
|
||||
|
||||
bdb->common.magic = 0;
|
||||
|
|
@ -1216,8 +1216,8 @@ create(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
bdb->server = isc_mem_strdup(named_g_mctx, argv[1]);
|
||||
bdb->contact = isc_mem_strdup(named_g_mctx, argv[2]);
|
||||
bdb->server = isc_mem_strdup(isc_g_mctx, argv[1]);
|
||||
bdb->contact = isc_mem_strdup(isc_g_mctx, argv[2]);
|
||||
} else if (argc != 1) {
|
||||
result = DNS_R_SYNTAX;
|
||||
goto cleanup;
|
||||
|
|
@ -1233,10 +1233,10 @@ create(isc_mem_t *mctx, const dns_name_t *origin, dns_dbtype_t type,
|
|||
cleanup:
|
||||
dns_name_free(&bdb->common.origin, mctx);
|
||||
if (bdb->server != NULL) {
|
||||
isc_mem_free(named_g_mctx, bdb->server);
|
||||
isc_mem_free(isc_g_mctx, bdb->server);
|
||||
}
|
||||
if (bdb->contact != NULL) {
|
||||
isc_mem_free(named_g_mctx, bdb->contact);
|
||||
isc_mem_free(isc_g_mctx, bdb->contact);
|
||||
}
|
||||
|
||||
isc_mem_putanddetach(&bdb->common.mctx, bdb, sizeof(bdb_t));
|
||||
|
|
@ -1253,13 +1253,13 @@ isc_result_t
|
|||
named_builtin_init(void) {
|
||||
isc_result_t result;
|
||||
|
||||
result = dns_db_register("_builtin", create, &builtin, named_g_mctx,
|
||||
result = dns_db_register("_builtin", create, &builtin, isc_g_mctx,
|
||||
&builtin.dbimp);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
|
||||
result = dns_db_register("_dns64", create, &dns64, named_g_mctx,
|
||||
result = dns_db_register("_dns64", create, &dns64, isc_g_mctx,
|
||||
&dns64.dbimp);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
dns_db_unregister(&builtin.dbimp);
|
||||
|
|
|
|||
|
|
@ -448,7 +448,7 @@ named_config_parsefile(cfg_parser_t *parser, cfg_obj_t **conf) {
|
|||
* registered.)
|
||||
*/
|
||||
result = isccfg_check_namedconf(*conf, BIND_CHECK_ALGORITHMS,
|
||||
named_g_mctx);
|
||||
isc_g_mctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ named_control_docommand(isccc_sexpr_t *message, bool readonly,
|
|||
return result;
|
||||
}
|
||||
|
||||
isc_lex_create(named_g_mctx, strlen(cmdline), &lex);
|
||||
isc_lex_create(isc_g_mctx, strlen(cmdline), &lex);
|
||||
|
||||
isc_buffer_init(&src, cmdline, strlen(cmdline));
|
||||
isc_buffer_add(&src, strlen(cmdline));
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@
|
|||
#define NAMED_RUN_PID_DIR 1
|
||||
#endif /* ifndef NAMED_RUN_PID_DIR */
|
||||
|
||||
EXTERN isc_mem_t *named_g_mctx INIT(NULL);
|
||||
EXTERN unsigned int named_g_cpus INIT(0);
|
||||
EXTERN bool named_g_loopmgr_running INIT(false);
|
||||
EXTERN dns_dispatchmgr_t *named_g_dispatchmgr INIT(NULL);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
@ -606,9 +608,9 @@ printversion(bool verbose) {
|
|||
printf(" named PID file: %s\n", named_g_defaultpidfile);
|
||||
#if defined(HAVE_GEOIP2)
|
||||
#define RTC(x) RUNTIME_CHECK((x) == ISC_R_SUCCESS)
|
||||
isc_mem_t *mctx = NULL;
|
||||
isc_mem_create("geoip", &mctx);
|
||||
RTC(cfg_parser_create(mctx, &parser));
|
||||
isc_mem_t *geoip_mctx = NULL;
|
||||
isc_mem_create("geoip", &geoip_mctx);
|
||||
RTC(cfg_parser_create(geoip_mctx, &parser));
|
||||
RTC(named_config_parsedefaults(parser, &config));
|
||||
RTC(cfg_map_get(config, "options", &defaults));
|
||||
RTC(cfg_map_get(defaults, "geoip-directory", &obj));
|
||||
|
|
@ -617,7 +619,7 @@ printversion(bool verbose) {
|
|||
}
|
||||
cfg_obj_destroy(parser, &config);
|
||||
cfg_parser_destroy(&parser);
|
||||
isc_mem_detach(&mctx);
|
||||
isc_mem_detach(&geoip_mctx);
|
||||
#endif /* HAVE_GEOIP2 */
|
||||
}
|
||||
|
||||
|
|
@ -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':
|
||||
|
|
@ -970,7 +973,7 @@ create_managers(void) {
|
|||
"thread count limit)"
|
||||
: "");
|
||||
|
||||
isc_managers_create(&named_g_mctx, named_g_cpus);
|
||||
isc_managers_create(named_g_cpus);
|
||||
|
||||
isc_nm_maxudp(maxudp);
|
||||
|
||||
|
|
@ -1001,7 +1004,7 @@ setup(void) {
|
|||
|
||||
#ifdef HAVE_LIBSCF
|
||||
/* Check if named is under smf control, before chroot. */
|
||||
result = named_smf_get_instance(&instance, 0, named_g_mctx);
|
||||
result = named_smf_get_instance(&instance, 0, isc_g_mctx);
|
||||
/* We don't care about instance, just check if we got one. */
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
named_smf_got_instance = 1;
|
||||
|
|
@ -1009,7 +1012,7 @@ setup(void) {
|
|||
named_smf_got_instance = 0;
|
||||
}
|
||||
if (instance != NULL) {
|
||||
isc_mem_free(named_g_mctx, instance);
|
||||
isc_mem_free(isc_g_mctx, instance);
|
||||
}
|
||||
#endif /* HAVE_LIBSCF */
|
||||
|
||||
|
|
@ -1216,13 +1219,13 @@ setup(void) {
|
|||
/*
|
||||
* Register the DLZ "dlopen" driver.
|
||||
*/
|
||||
result = dlz_dlopen_init(named_g_mctx);
|
||||
result = dlz_dlopen_init(isc_g_mctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
named_main_earlyfatal("dlz_dlopen_init() failed: %s",
|
||||
isc_result_totext(result));
|
||||
}
|
||||
|
||||
named_server_create(named_g_mctx, &named_g_server);
|
||||
named_server_create(isc_g_mctx, &named_g_server);
|
||||
ENSURE(named_g_server != NULL);
|
||||
sctx = named_g_server->sctx;
|
||||
|
||||
|
|
@ -1475,7 +1478,7 @@ main(int argc, char *argv[]) {
|
|||
|
||||
#ifdef HAVE_LIBSCF
|
||||
if (named_smf_want_disable == 1) {
|
||||
result = named_smf_get_instance(&instance, 1, named_g_mctx);
|
||||
result = named_smf_get_instance(&instance, 1, isc_g_mctx);
|
||||
if (result == ISC_R_SUCCESS && instance != NULL) {
|
||||
if (smf_disable_instance(instance, 0) != 0) {
|
||||
UNEXPECTED_ERROR("smf_disable_instance() "
|
||||
|
|
@ -1485,7 +1488,7 @@ main(int argc, char *argv[]) {
|
|||
}
|
||||
}
|
||||
if (instance != NULL) {
|
||||
isc_mem_free(named_g_mctx, instance);
|
||||
isc_mem_free(isc_g_mctx, instance);
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_LIBSCF */
|
||||
|
|
@ -1493,19 +1496,19 @@ main(int argc, char *argv[]) {
|
|||
cleanup();
|
||||
|
||||
if (want_stats) {
|
||||
isc_mem_stats(named_g_mctx, stdout);
|
||||
isc_mem_stats(isc_g_mctx, stdout);
|
||||
}
|
||||
|
||||
if (named_g_memstatistics && memstats != NULL) {
|
||||
FILE *fp = NULL;
|
||||
result = isc_stdio_open(memstats, "w", &fp);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
isc_mem_stats(named_g_mctx, fp);
|
||||
isc_mem_stats(isc_g_mctx, fp);
|
||||
(void)isc_stdio_close(fp);
|
||||
}
|
||||
}
|
||||
|
||||
isc_managers_destroy(&named_g_mctx);
|
||||
isc_managers_destroy();
|
||||
|
||||
#if ENABLE_LEAK_DETECTION
|
||||
isc__crypto_setdestroycheck(true);
|
||||
|
|
|
|||
|
|
@ -1219,7 +1219,7 @@ configure_view_dnsseckeys(dns_view_t *view, const cfg_obj_t *vconfig,
|
|||
}
|
||||
|
||||
if (auto_root) {
|
||||
CHECK(add_keydata_zone(view, directory, named_g_mctx));
|
||||
CHECK(add_keydata_zone(view, directory, isc_g_mctx));
|
||||
}
|
||||
|
||||
cleanup:
|
||||
|
|
@ -3053,7 +3053,7 @@ configure_rrl(dns_view_t *view, const cfg_obj_t *config, const cfg_obj_t *map) {
|
|||
result = cfg_map_get(map, "exempt-clients", &obj);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
result = cfg_acl_fromconfig(obj, config, named_g_aclconfctx,
|
||||
named_g_mctx, 0, &rrl->exempt);
|
||||
isc_g_mctx, 0, &rrl->exempt);
|
||||
CHECK_RRL(result == ISC_R_SUCCESS, "invalid %s%s",
|
||||
"address match list", "");
|
||||
}
|
||||
|
|
@ -3597,7 +3597,7 @@ configure_dnstap(const cfg_obj_t **maps, dns_view_t *view) {
|
|||
fstrm_iothr_options_set_reopen_interval(fopt, i);
|
||||
}
|
||||
|
||||
CHECKM(dns_dt_create(named_g_mctx, dmode, dpath, &fopt,
|
||||
CHECKM(dns_dt_create(isc_g_mctx, dmode, dpath, &fopt,
|
||||
isc_loop_main(), &named_g_server->dtenv),
|
||||
"unable to create dnstap environment");
|
||||
|
||||
|
|
@ -3657,7 +3657,7 @@ create_mapped_acl(void) {
|
|||
|
||||
isc_netaddr_fromin6(&addr, &in6);
|
||||
|
||||
dns_acl_create(named_g_mctx, 1, &acl);
|
||||
dns_acl_create(isc_g_mctx, 1, &acl);
|
||||
|
||||
result = dns_iptable_addprefix(acl->iptable, &addr, 96, true);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
|
|
@ -3693,7 +3693,7 @@ register_one_plugin(const cfg_obj_t *config, const cfg_obj_t *obj,
|
|||
|
||||
result = ns_plugin_register(full_path, parameters, config,
|
||||
cfg_obj_file(obj), cfg_obj_line(obj),
|
||||
named_g_mctx, named_g_aclconfctx, view);
|
||||
isc_g_mctx, named_g_aclconfctx, view);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER,
|
||||
ISC_LOG_ERROR,
|
||||
|
|
@ -4819,9 +4819,9 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
|
|||
* can be retrieved.)
|
||||
*/
|
||||
CHECK(configure_view_acl(vconfig, config, NULL, "match-clients", NULL,
|
||||
actx, named_g_mctx, &view->matchclients));
|
||||
actx, isc_g_mctx, &view->matchclients));
|
||||
CHECK(configure_view_acl(vconfig, config, NULL, "match-destinations",
|
||||
NULL, actx, named_g_mctx,
|
||||
NULL, actx, isc_g_mctx,
|
||||
&view->matchdestinations));
|
||||
|
||||
/*
|
||||
|
|
@ -4926,25 +4926,25 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
|
|||
|
||||
/* named.conf only */
|
||||
CHECK(configure_view_acl(vconfig, config, NULL, "allow-query", NULL,
|
||||
actx, named_g_mctx, &view->queryacl));
|
||||
actx, isc_g_mctx, &view->queryacl));
|
||||
|
||||
/* named.conf only */
|
||||
CHECK(configure_view_acl(vconfig, config, NULL, "allow-query-cache",
|
||||
NULL, actx, named_g_mctx, &view->cacheacl));
|
||||
NULL, actx, isc_g_mctx, &view->cacheacl));
|
||||
/* named.conf only */
|
||||
CHECK(configure_view_acl(vconfig, config, NULL, "allow-query-cache-on",
|
||||
NULL, actx, named_g_mctx, &view->cacheonacl));
|
||||
NULL, actx, isc_g_mctx, &view->cacheonacl));
|
||||
|
||||
CHECK(configure_view_acl(vconfig, config, named_g_defaultconfig,
|
||||
"allow-query-on", NULL, actx, named_g_mctx,
|
||||
"allow-query-on", NULL, actx, isc_g_mctx,
|
||||
&view->queryonacl));
|
||||
|
||||
CHECK(configure_view_acl(vconfig, config, named_g_defaultconfig,
|
||||
"allow-proxy", NULL, actx, named_g_mctx,
|
||||
"allow-proxy", NULL, actx, isc_g_mctx,
|
||||
&view->proxyacl));
|
||||
|
||||
CHECK(configure_view_acl(vconfig, config, named_g_defaultconfig,
|
||||
"allow-proxy-on", NULL, actx, named_g_mctx,
|
||||
"allow-proxy-on", NULL, actx, isc_g_mctx,
|
||||
&view->proxyonacl));
|
||||
|
||||
if (strcmp(view->name, "_bind") != 0 &&
|
||||
|
|
@ -4953,11 +4953,11 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
|
|||
/* named.conf only */
|
||||
CHECK(configure_view_acl(vconfig, config, NULL,
|
||||
"allow-recursion", NULL, actx,
|
||||
named_g_mctx, &view->recursionacl));
|
||||
isc_g_mctx, &view->recursionacl));
|
||||
/* named.conf only */
|
||||
CHECK(configure_view_acl(vconfig, config, NULL,
|
||||
"allow-recursion-on", NULL, actx,
|
||||
named_g_mctx, &view->recursiononacl));
|
||||
isc_g_mctx, &view->recursiononacl));
|
||||
}
|
||||
|
||||
if (view->recursion) {
|
||||
|
|
@ -5019,29 +5019,29 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
|
|||
/* global default only */
|
||||
CHECK(configure_view_acl(
|
||||
NULL, NULL, named_g_defaultconfig,
|
||||
"allow-recursion", NULL, actx, named_g_mctx,
|
||||
"allow-recursion", NULL, actx, isc_g_mctx,
|
||||
&view->recursionacl));
|
||||
}
|
||||
if (view->recursiononacl == NULL) {
|
||||
/* global default only */
|
||||
CHECK(configure_view_acl(
|
||||
NULL, NULL, named_g_defaultconfig,
|
||||
"allow-recursion-on", NULL, actx, named_g_mctx,
|
||||
"allow-recursion-on", NULL, actx, isc_g_mctx,
|
||||
&view->recursiononacl));
|
||||
}
|
||||
if (view->cacheacl == NULL) {
|
||||
/* global default only */
|
||||
CHECK(configure_view_acl(
|
||||
NULL, NULL, named_g_defaultconfig,
|
||||
"allow-query-cache", NULL, actx, named_g_mctx,
|
||||
"allow-query-cache", NULL, actx, isc_g_mctx,
|
||||
&view->cacheacl));
|
||||
}
|
||||
if (view->cacheonacl == NULL) {
|
||||
/* global default only */
|
||||
CHECK(configure_view_acl(
|
||||
NULL, NULL, named_g_defaultconfig,
|
||||
"allow-query-cache-on", NULL, actx,
|
||||
named_g_mctx, &view->cacheonacl));
|
||||
"allow-query-cache-on", NULL, actx, isc_g_mctx,
|
||||
&view->cacheonacl));
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
|
|
@ -5063,8 +5063,8 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
|
|||
if (view->queryacl == NULL) {
|
||||
/* global default only */
|
||||
CHECK(configure_view_acl(NULL, NULL, named_g_defaultconfig,
|
||||
"allow-query", NULL, actx,
|
||||
named_g_mctx, &view->queryacl));
|
||||
"allow-query", NULL, actx, isc_g_mctx,
|
||||
&view->queryacl));
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -5073,7 +5073,7 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
|
|||
* and is needed by some broken clients.
|
||||
*/
|
||||
CHECK(configure_view_acl(vconfig, config, named_g_defaultconfig,
|
||||
"no-case-compress", NULL, actx, named_g_mctx,
|
||||
"no-case-compress", NULL, actx, isc_g_mctx,
|
||||
&view->nocasecompress));
|
||||
|
||||
/*
|
||||
|
|
@ -5090,19 +5090,19 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
|
|||
*/
|
||||
CHECK(configure_view_acl(vconfig, config, named_g_defaultconfig,
|
||||
"deny-answer-addresses", "acl", actx,
|
||||
named_g_mctx, &view->denyansweracl));
|
||||
isc_g_mctx, &view->denyansweracl));
|
||||
CHECK(configure_view_nametable(vconfig, config, "deny-answer-addresses",
|
||||
"except-from", named_g_mctx,
|
||||
"except-from", isc_g_mctx,
|
||||
&view->answeracl_exclude));
|
||||
|
||||
/*
|
||||
* Filter setting on names (CNAME/DNAME targets) in the answer section.
|
||||
*/
|
||||
CHECK(configure_view_nametable(vconfig, config, "deny-answer-aliases",
|
||||
"name", named_g_mctx,
|
||||
"name", isc_g_mctx,
|
||||
&view->denyanswernames));
|
||||
CHECK(configure_view_nametable(vconfig, config, "deny-answer-aliases",
|
||||
"except-from", named_g_mctx,
|
||||
"except-from", isc_g_mctx,
|
||||
&view->answernames_exclude));
|
||||
|
||||
/*
|
||||
|
|
@ -5113,13 +5113,13 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
|
|||
*/
|
||||
if (view->updateacl == NULL) {
|
||||
CHECK(configure_view_acl(NULL, NULL, named_g_defaultconfig,
|
||||
"allow-update", NULL, actx,
|
||||
named_g_mctx, &view->updateacl));
|
||||
"allow-update", NULL, actx, isc_g_mctx,
|
||||
&view->updateacl));
|
||||
}
|
||||
if (view->upfwdacl == NULL) {
|
||||
CHECK(configure_view_acl(NULL, NULL, named_g_defaultconfig,
|
||||
"allow-update-forwarding", NULL, actx,
|
||||
named_g_mctx, &view->upfwdacl));
|
||||
isc_g_mctx, &view->upfwdacl));
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -5129,12 +5129,12 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
|
|||
if (view->transferacl == NULL) {
|
||||
CHECK(configure_view_acl(vconfig, config, named_g_defaultconfig,
|
||||
"allow-transfer", NULL, actx,
|
||||
named_g_mctx, &view->transferacl));
|
||||
isc_g_mctx, &view->transferacl));
|
||||
}
|
||||
if (view->notifyacl == NULL) {
|
||||
CHECK(configure_view_acl(vconfig, config, named_g_defaultconfig,
|
||||
"allow-notify", NULL, actx,
|
||||
named_g_mctx, &view->notifyacl));
|
||||
"allow-notify", NULL, actx, isc_g_mctx,
|
||||
&view->notifyacl));
|
||||
}
|
||||
|
||||
obj = NULL;
|
||||
|
|
@ -5174,7 +5174,7 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
|
|||
padding = 512U;
|
||||
}
|
||||
view->padding = (uint16_t)padding;
|
||||
CHECK(cfg_acl_fromconfig(aclobj, config, actx, named_g_mctx, 0,
|
||||
CHECK(cfg_acl_fromconfig(aclobj, config, actx, isc_g_mctx, 0,
|
||||
&view->pad_acl));
|
||||
}
|
||||
|
||||
|
|
@ -6191,7 +6191,7 @@ create_view(const cfg_obj_t *vconfig, dns_viewlist_t *viewlist,
|
|||
}
|
||||
INSIST(view == NULL);
|
||||
|
||||
dns_view_create(named_g_mctx, named_g_dispatchmgr, viewclass, viewname,
|
||||
dns_view_create(isc_g_mctx, named_g_dispatchmgr, viewclass, viewname,
|
||||
&view);
|
||||
|
||||
isc_nonce_buf(view->secret, sizeof(view->secret));
|
||||
|
|
@ -7859,7 +7859,7 @@ apply_configuration(cfg_parser_t *configparser, cfg_obj_t *config,
|
|||
if (named_g_aclconfctx != NULL) {
|
||||
cfg_aclconfctx_detach(&named_g_aclconfctx);
|
||||
}
|
||||
result = cfg_aclconfctx_create(named_g_mctx, &named_g_aclconfctx);
|
||||
result = cfg_aclconfctx_create(isc_g_mctx, &named_g_aclconfctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup_exclusive;
|
||||
}
|
||||
|
|
@ -7887,13 +7887,13 @@ apply_configuration(cfg_parser_t *configparser, cfg_obj_t *config,
|
|||
isc_tlsctx_cache_detach(&server->tlsctx_server_cache);
|
||||
}
|
||||
|
||||
isc_tlsctx_cache_create(named_g_mctx, &server->tlsctx_server_cache);
|
||||
isc_tlsctx_cache_create(isc_g_mctx, &server->tlsctx_server_cache);
|
||||
|
||||
if (server->tlsctx_client_cache != NULL) {
|
||||
isc_tlsctx_cache_detach(&server->tlsctx_client_cache);
|
||||
}
|
||||
|
||||
isc_tlsctx_cache_create(named_g_mctx, &server->tlsctx_client_cache);
|
||||
isc_tlsctx_cache_create(isc_g_mctx, &server->tlsctx_client_cache);
|
||||
|
||||
dns_zonemgr_set_tlsctx_cache(server->zonemgr,
|
||||
server->tlsctx_client_cache);
|
||||
|
|
@ -7950,7 +7950,7 @@ apply_configuration(cfg_parser_t *configparser, cfg_obj_t *config,
|
|||
"keys instead",
|
||||
server->bindkeysfile);
|
||||
} else {
|
||||
result = cfg_parser_create(named_g_mctx,
|
||||
result = cfg_parser_create(isc_g_mctx,
|
||||
&bindkeys_parser);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup_bindkeys_parser;
|
||||
|
|
@ -8031,7 +8031,7 @@ apply_configuration(cfg_parser_t *configparser, cfg_obj_t *config,
|
|||
result = named_config_get(maps, "sig0checks-quota-exempt", &obj);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
result = cfg_acl_fromconfig(
|
||||
obj, config, named_g_aclconfctx, named_g_mctx, 0,
|
||||
obj, config, named_g_aclconfctx, isc_g_mctx, 0,
|
||||
&server->sctx->sig0checksquota_exempt);
|
||||
INSIST(result == ISC_R_SUCCESS);
|
||||
}
|
||||
|
|
@ -8041,7 +8041,7 @@ apply_configuration(cfg_parser_t *configparser, cfg_obj_t *config,
|
|||
* no default.
|
||||
*/
|
||||
result = configure_view_acl(NULL, config, NULL, "blackhole", NULL,
|
||||
named_g_aclconfctx, named_g_mctx,
|
||||
named_g_aclconfctx, isc_g_mctx,
|
||||
&server->sctx->blackholeacl);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup_bindkeys_parser;
|
||||
|
|
@ -8190,8 +8190,8 @@ apply_configuration(cfg_parser_t *configparser, cfg_obj_t *config,
|
|||
/*
|
||||
* Configure sets of UDP query source ports.
|
||||
*/
|
||||
isc_portset_create(named_g_mctx, &v4portset);
|
||||
isc_portset_create(named_g_mctx, &v6portset);
|
||||
isc_portset_create(isc_g_mctx, &v4portset);
|
||||
isc_portset_create(isc_g_mctx, &v6portset);
|
||||
|
||||
result = isc_net_getudpportrange(AF_INET, &udpport_low, &udpport_high);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
|
|
@ -8343,7 +8343,7 @@ apply_configuration(cfg_parser_t *configparser, cfg_obj_t *config,
|
|||
goto cleanup_portsets;
|
||||
}
|
||||
result = listenlist_fromconfig(
|
||||
clistenon, config, named_g_aclconfctx, named_g_mctx,
|
||||
clistenon, config, named_g_aclconfctx, isc_g_mctx,
|
||||
AF_INET, server->tlsctx_server_cache, &listenon);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup_portsets;
|
||||
|
|
@ -8367,7 +8367,7 @@ apply_configuration(cfg_parser_t *configparser, cfg_obj_t *config,
|
|||
goto cleanup_portsets;
|
||||
}
|
||||
result = listenlist_fromconfig(
|
||||
clistenon, config, named_g_aclconfctx, named_g_mctx,
|
||||
clistenon, config, named_g_aclconfctx, isc_g_mctx,
|
||||
AF_INET6, server->tlsctx_server_cache, &listenon);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup_portsets;
|
||||
|
|
@ -8481,13 +8481,12 @@ apply_configuration(cfg_parser_t *configparser, cfg_obj_t *config,
|
|||
* turns out that a session key is really needed but doesn't exist,
|
||||
* we'll treat it as a fatal error then.
|
||||
*/
|
||||
(void)configure_session_key(maps, server, named_g_mctx, first_time);
|
||||
(void)configure_session_key(maps, server, isc_g_mctx, first_time);
|
||||
|
||||
/*
|
||||
* Create the built-in key store ("key-directory").
|
||||
*/
|
||||
result = cfg_keystore_fromconfig(NULL, named_g_mctx, &keystorelist,
|
||||
NULL);
|
||||
result = cfg_keystore_fromconfig(NULL, isc_g_mctx, &keystorelist, NULL);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup_keystorelist;
|
||||
}
|
||||
|
|
@ -8500,7 +8499,7 @@ apply_configuration(cfg_parser_t *configparser, cfg_obj_t *config,
|
|||
CFG_LIST_FOREACH (keystores, element) {
|
||||
cfg_obj_t *kconfig = cfg_listelt_value(element);
|
||||
|
||||
result = cfg_keystore_fromconfig(kconfig, named_g_mctx,
|
||||
result = cfg_keystore_fromconfig(kconfig, isc_g_mctx,
|
||||
&keystorelist, NULL);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup_keystorelist;
|
||||
|
|
@ -8517,7 +8516,7 @@ apply_configuration(cfg_parser_t *configparser, cfg_obj_t *config,
|
|||
dns_kasp_t *kasp = NULL;
|
||||
|
||||
result = cfg_kasp_fromconfig(kconfig, default_kasp, true,
|
||||
named_g_mctx, &keystorelist,
|
||||
isc_g_mctx, &keystorelist,
|
||||
&kasplist, &kasp);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup_kasplist;
|
||||
|
|
@ -8545,7 +8544,7 @@ apply_configuration(cfg_parser_t *configparser, cfg_obj_t *config,
|
|||
dns_kasp_t *kasp = NULL;
|
||||
|
||||
result = cfg_kasp_fromconfig(kconfig, default_kasp, true,
|
||||
named_g_mctx, &keystorelist,
|
||||
isc_g_mctx, &keystorelist,
|
||||
&kasplist, &kasp);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto cleanup_kasplist;
|
||||
|
|
@ -8636,7 +8635,7 @@ apply_configuration(cfg_parser_t *configparser, cfg_obj_t *config,
|
|||
&cachelist, &server->cachelist,
|
||||
&server->kasplist,
|
||||
&server->keystorelist, bindkeys,
|
||||
named_g_mctx, named_g_aclconfctx, true);
|
||||
isc_g_mctx, named_g_aclconfctx, true);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
dns_view_detach(&view);
|
||||
goto cleanup_cachelist;
|
||||
|
|
@ -8659,7 +8658,7 @@ apply_configuration(cfg_parser_t *configparser, cfg_obj_t *config,
|
|||
&cachelist, &server->cachelist,
|
||||
&server->kasplist,
|
||||
&server->keystorelist, bindkeys,
|
||||
named_g_mctx, named_g_aclconfctx, true);
|
||||
isc_g_mctx, named_g_aclconfctx, true);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
dns_view_detach(&view);
|
||||
goto cleanup_cachelist;
|
||||
|
|
@ -8683,11 +8682,11 @@ apply_configuration(cfg_parser_t *configparser, cfg_obj_t *config,
|
|||
goto cleanup_cachelist;
|
||||
}
|
||||
|
||||
result = configure_view(
|
||||
view, &viewlist, config, vconfig, &cachelist,
|
||||
&server->cachelist, &server->kasplist,
|
||||
&server->keystorelist, bindkeys, named_g_mctx,
|
||||
named_g_aclconfctx, false);
|
||||
result = configure_view(view, &viewlist, config, vconfig,
|
||||
&cachelist, &server->cachelist,
|
||||
&server->kasplist,
|
||||
&server->keystorelist, bindkeys,
|
||||
isc_g_mctx, named_g_aclconfctx, false);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
dns_view_detach(&view);
|
||||
goto cleanup_cachelist;
|
||||
|
|
@ -8726,7 +8725,7 @@ apply_configuration(cfg_parser_t *configparser, cfg_obj_t *config,
|
|||
if (options != NULL) {
|
||||
dns_tkeyctx_t *tkeyctx = NULL;
|
||||
|
||||
result = named_tkeyctx_fromconfig(options, named_g_mctx,
|
||||
result = named_tkeyctx_fromconfig(options, isc_g_mctx,
|
||||
&tkeyctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_log_write(NAMED_LOGCATEGORY_GENERAL,
|
||||
|
|
@ -8919,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;
|
||||
|
|
@ -9177,8 +9176,8 @@ cleanup_keystorelist:
|
|||
}
|
||||
|
||||
cleanup_portsets:
|
||||
isc_portset_destroy(named_g_mctx, &v6portset);
|
||||
isc_portset_destroy(named_g_mctx, &v4portset);
|
||||
isc_portset_destroy(isc_g_mctx, &v6portset);
|
||||
isc_portset_destroy(isc_g_mctx, &v4portset);
|
||||
|
||||
cleanup_bindkeys_parser:
|
||||
if (bindkeys_parser != NULL) {
|
||||
|
|
@ -9209,7 +9208,7 @@ load_configuration(named_server_t *server, bool first_time) {
|
|||
isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_SERVER,
|
||||
ISC_LOG_DEBUG(1), "load_configuration");
|
||||
|
||||
result = cfg_parser_create(named_g_mctx, &parser);
|
||||
result = cfg_parser_create(isc_g_mctx, &parser);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto out;
|
||||
}
|
||||
|
|
@ -9374,9 +9373,9 @@ run_server(void *arg) {
|
|||
named_server_t *server = (named_server_t *)arg;
|
||||
dns_geoip_databases_t *geoip = NULL;
|
||||
|
||||
dns_zonemgr_create(named_g_mctx, &server->zonemgr);
|
||||
dns_zonemgr_create(isc_g_mctx, &server->zonemgr);
|
||||
|
||||
CHECKFATAL(dns_dispatchmgr_create(named_g_mctx, &named_g_dispatchmgr),
|
||||
CHECKFATAL(dns_dispatchmgr_create(isc_g_mctx, &named_g_dispatchmgr),
|
||||
"creating dispatch manager");
|
||||
|
||||
dns_dispatchmgr_setstats(named_g_dispatchmgr, server->resolverstats);
|
||||
|
|
@ -9387,7 +9386,7 @@ run_server(void *arg) {
|
|||
geoip = NULL;
|
||||
#endif /* if defined(HAVE_GEOIP2) */
|
||||
|
||||
CHECKFATAL(ns_interfacemgr_create(named_g_mctx, server->sctx,
|
||||
CHECKFATAL(ns_interfacemgr_create(isc_g_mctx, server->sctx,
|
||||
named_g_dispatchmgr, geoip,
|
||||
&server->interfacemgr),
|
||||
"creating interface manager");
|
||||
|
|
@ -9401,7 +9400,7 @@ run_server(void *arg) {
|
|||
isc_timer_create(isc_loop_main(), pps_timer_tick, server,
|
||||
&server->pps_timer);
|
||||
|
||||
CHECKFATAL(cfg_parser_create(named_g_mctx, &named_g_parser),
|
||||
CHECKFATAL(cfg_parser_create(isc_g_mctx, &named_g_parser),
|
||||
"creating default configuration parser");
|
||||
|
||||
CHECKFATAL(named_config_parsedefaults(named_g_parser,
|
||||
|
|
@ -9412,7 +9411,7 @@ run_server(void *arg) {
|
|||
&named_g_defaultoptions),
|
||||
"missing 'options' in default config");
|
||||
|
||||
CHECKFATAL(cfg_parser_create(named_g_mctx, &named_g_addparser),
|
||||
CHECKFATAL(cfg_parser_create(isc_g_mctx, &named_g_addparser),
|
||||
"creating additional configuration parser");
|
||||
|
||||
CHECKFATAL(load_configuration(server, true), "loading configuration");
|
||||
|
|
@ -9799,10 +9798,10 @@ named_server_create(isc_mem_t *mctx, named_server_t **serverp) {
|
|||
isc_sockstatscounter_max);
|
||||
isc_nm_setstats(server->sockstats);
|
||||
|
||||
isc_stats_create(named_g_mctx, &server->zonestats,
|
||||
isc_stats_create(isc_g_mctx, &server->zonestats,
|
||||
dns_zonestatscounter_max);
|
||||
|
||||
isc_stats_create(named_g_mctx, &server->resolverstats,
|
||||
isc_stats_create(isc_g_mctx, &server->resolverstats,
|
||||
dns_resstatscounter_max);
|
||||
|
||||
CHECKFATAL(named_controls_create(server, &server->controls),
|
||||
|
|
@ -13771,7 +13770,7 @@ rmzone(void *arg) {
|
|||
dns_zone_detach(&raw);
|
||||
}
|
||||
dns_zone_detach(&zone);
|
||||
isc_mem_put(named_g_mctx, dz, sizeof(*dz));
|
||||
isc_mem_put(isc_g_mctx, dz, sizeof(*dz));
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -13836,7 +13835,7 @@ named_server_delzone(named_server_t *server, isc_lex_t *lex,
|
|||
}
|
||||
|
||||
/* Send cleanup event */
|
||||
dz = isc_mem_get(named_g_mctx, sizeof(*dz));
|
||||
dz = isc_mem_get(isc_g_mctx, sizeof(*dz));
|
||||
*dz = (ns_dzctx_t){
|
||||
.cleanup = cleanup,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -175,8 +175,7 @@ configure_zone_acl(const cfg_obj_t *zconfig, const cfg_obj_t *vconfig,
|
|||
}
|
||||
|
||||
parse_acl:
|
||||
result = cfg_acl_fromconfig(aclobj, config, actx, named_g_mctx, 0,
|
||||
&acl);
|
||||
result = cfg_acl_fromconfig(aclobj, config, actx, isc_g_mctx, 0, &acl);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,7 +121,6 @@ static bool use_tls = false;
|
|||
static bool usevc = false;
|
||||
static bool usegsstsig = false;
|
||||
static bool local_only = false;
|
||||
static isc_mem_t *gmctx = NULL;
|
||||
static dns_dispatchmgr_t *dispatchmgr = NULL;
|
||||
static dns_requestmgr_t *requestmgr = NULL;
|
||||
static dns_dispatch_t *dispatchv4 = NULL;
|
||||
|
|
@ -238,7 +237,7 @@ error(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);
|
|||
static void
|
||||
primary_from_servers(void) {
|
||||
if (primary_servers != NULL && primary_servers != servers) {
|
||||
isc_mem_cput(gmctx, primary_servers, primary_alloc,
|
||||
isc_mem_cput(isc_g_mctx, primary_servers, primary_alloc,
|
||||
sizeof(isc_sockaddr_t));
|
||||
}
|
||||
primary_servers = servers;
|
||||
|
|
@ -363,8 +362,8 @@ reset_system(void) {
|
|||
if (updatemsg != NULL) {
|
||||
dns_message_reset(updatemsg, DNS_MESSAGE_INTENTRENDER);
|
||||
} else {
|
||||
dns_message_create(gmctx, NULL, NULL, DNS_MESSAGE_INTENTRENDER,
|
||||
&updatemsg);
|
||||
dns_message_create(isc_g_mctx, NULL, NULL,
|
||||
DNS_MESSAGE_INTENTRENDER, &updatemsg);
|
||||
}
|
||||
updatemsg->opcode = dns_opcode_update;
|
||||
if (usegsstsig) {
|
||||
|
|
@ -524,7 +523,7 @@ setup_keystr(void) {
|
|||
check_result(result, "dns_name_fromtext");
|
||||
|
||||
secretlen = strlen(secretstr) * 3 / 4;
|
||||
secret = isc_mem_allocate(gmctx, secretlen);
|
||||
secret = isc_mem_allocate(isc_g_mctx, secretlen);
|
||||
|
||||
isc_buffer_init(&secretbuf, secret, secretlen);
|
||||
result = isc_base64_decodestring(secretstr, &secretbuf);
|
||||
|
|
@ -538,7 +537,7 @@ setup_keystr(void) {
|
|||
|
||||
debug("keycreate");
|
||||
result = dns_tsigkey_create(mykeyname, hmac_alg, secret, secretlen,
|
||||
gmctx, &tsigkey);
|
||||
isc_g_mctx, &tsigkey);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fprintf(stderr, "could not create key from %s: %s\n", keystr,
|
||||
isc_result_totext(result));
|
||||
|
|
@ -547,7 +546,7 @@ setup_keystr(void) {
|
|||
}
|
||||
failure:
|
||||
if (secret != NULL) {
|
||||
isc_mem_free(gmctx, secret);
|
||||
isc_mem_free(isc_g_mctx, secret);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -683,20 +682,21 @@ doshutdown(void) {
|
|||
* to NULL.
|
||||
*/
|
||||
if (primary_servers != NULL && primary_servers != servers) {
|
||||
isc_mem_cput(gmctx, primary_servers, primary_alloc,
|
||||
isc_mem_cput(isc_g_mctx, primary_servers, primary_alloc,
|
||||
sizeof(isc_sockaddr_t));
|
||||
}
|
||||
|
||||
if (servers != NULL) {
|
||||
isc_mem_cput(gmctx, servers, ns_alloc, sizeof(isc_sockaddr_t));
|
||||
isc_mem_cput(isc_g_mctx, servers, ns_alloc,
|
||||
sizeof(isc_sockaddr_t));
|
||||
}
|
||||
|
||||
if (localaddr4 != NULL) {
|
||||
isc_mem_put(gmctx, localaddr4, sizeof(isc_sockaddr_t));
|
||||
isc_mem_put(isc_g_mctx, localaddr4, sizeof(isc_sockaddr_t));
|
||||
}
|
||||
|
||||
if (localaddr6 != NULL) {
|
||||
isc_mem_put(gmctx, localaddr6, sizeof(isc_sockaddr_t));
|
||||
isc_mem_put(isc_g_mctx, localaddr6, sizeof(isc_sockaddr_t));
|
||||
}
|
||||
|
||||
if (tsigkey != NULL) {
|
||||
|
|
@ -764,12 +764,12 @@ set_source_ports(dns_dispatchmgr_t *manager) {
|
|||
in_port_t udpport_low, udpport_high;
|
||||
isc_result_t result;
|
||||
|
||||
isc_portset_create(gmctx, &v4portset);
|
||||
isc_portset_create(isc_g_mctx, &v4portset);
|
||||
result = isc_net_getudpportrange(AF_INET, &udpport_low, &udpport_high);
|
||||
check_result(result, "isc_net_getudpportrange (v4)");
|
||||
isc_portset_addrange(v4portset, udpport_low, udpport_high);
|
||||
|
||||
isc_portset_create(gmctx, &v6portset);
|
||||
isc_portset_create(isc_g_mctx, &v6portset);
|
||||
result = isc_net_getudpportrange(AF_INET6, &udpport_low, &udpport_high);
|
||||
check_result(result, "isc_net_getudpportrange (v6)");
|
||||
isc_portset_addrange(v6portset, udpport_low, udpport_high);
|
||||
|
|
@ -777,8 +777,8 @@ set_source_ports(dns_dispatchmgr_t *manager) {
|
|||
result = dns_dispatchmgr_setavailports(manager, v4portset, v6portset);
|
||||
check_result(result, "dns_dispatchmgr_setavailports");
|
||||
|
||||
isc_portset_destroy(gmctx, &v4portset);
|
||||
isc_portset_destroy(gmctx, &v6portset);
|
||||
isc_portset_destroy(isc_g_mctx, &v4portset);
|
||||
isc_portset_destroy(isc_g_mctx, &v6portset);
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
|
|
@ -811,7 +811,7 @@ setup_system(void *arg ISC_ATTR_UNUSED) {
|
|||
ISC_LOGMODULE_DEFAULT);
|
||||
isc_log_setdebuglevel(logdebuglevel);
|
||||
|
||||
result = irs_resconf_load(gmctx, resolvconf, &resconf);
|
||||
result = irs_resconf_load(isc_g_mctx, resolvconf, &resconf);
|
||||
if (result != ISC_R_SUCCESS && result != ISC_R_FILENOTFOUND) {
|
||||
fatal("parse of %s failed", resolvconf);
|
||||
}
|
||||
|
|
@ -822,7 +822,8 @@ setup_system(void *arg ISC_ATTR_UNUSED) {
|
|||
if (primary_servers == servers) {
|
||||
primary_servers = NULL;
|
||||
}
|
||||
isc_mem_cput(gmctx, servers, ns_alloc, sizeof(isc_sockaddr_t));
|
||||
isc_mem_cput(isc_g_mctx, servers, ns_alloc,
|
||||
sizeof(isc_sockaddr_t));
|
||||
}
|
||||
|
||||
ns_inuse = 0;
|
||||
|
|
@ -837,7 +838,8 @@ setup_system(void *arg ISC_ATTR_UNUSED) {
|
|||
default_servers = !local_only;
|
||||
|
||||
ns_total = ns_alloc = (have_ipv4 ? 1 : 0) + (have_ipv6 ? 1 : 0);
|
||||
servers = isc_mem_cget(gmctx, ns_alloc, sizeof(isc_sockaddr_t));
|
||||
servers = isc_mem_cget(isc_g_mctx, ns_alloc,
|
||||
sizeof(isc_sockaddr_t));
|
||||
|
||||
if (have_ipv6) {
|
||||
memset(&in6, 0, sizeof(in6));
|
||||
|
|
@ -876,7 +878,8 @@ setup_system(void *arg ISC_ATTR_UNUSED) {
|
|||
}
|
||||
|
||||
ns_alloc = ns_total;
|
||||
servers = isc_mem_cget(gmctx, ns_alloc, sizeof(isc_sockaddr_t));
|
||||
servers = isc_mem_cget(isc_g_mctx, ns_alloc,
|
||||
sizeof(isc_sockaddr_t));
|
||||
|
||||
i = 0;
|
||||
ISC_LIST_FOREACH (*nslist, sa, link) {
|
||||
|
|
@ -906,7 +909,7 @@ setup_system(void *arg ISC_ATTR_UNUSED) {
|
|||
|
||||
irs_resconf_destroy(&resconf);
|
||||
|
||||
result = dns_dispatchmgr_create(gmctx, &dispatchmgr);
|
||||
result = dns_dispatchmgr_create(isc_g_mctx, &dispatchmgr);
|
||||
check_result(result, "dns_dispatchmgr_create");
|
||||
|
||||
set_source_ports(dispatchmgr);
|
||||
|
|
@ -924,9 +927,9 @@ setup_system(void *arg ISC_ATTR_UNUSED) {
|
|||
&dispatchv4);
|
||||
check_result(result, "dns_dispatch_createudp (v4)");
|
||||
}
|
||||
transport_list = dns_transport_list_new(gmctx);
|
||||
transport_list = dns_transport_list_new(isc_g_mctx);
|
||||
|
||||
isc_tlsctx_cache_create(gmctx, &tls_ctx_cache);
|
||||
isc_tlsctx_cache_create(isc_g_mctx, &tls_ctx_cache);
|
||||
|
||||
if (tls_client_key_file == NULL) {
|
||||
result = create_name("tls-non-auth-client", tlsname);
|
||||
|
|
@ -948,20 +951,20 @@ setup_system(void *arg ISC_ATTR_UNUSED) {
|
|||
dns_transport_set_always_verify_remote(transport,
|
||||
tls_always_verify_remote);
|
||||
|
||||
result = dns_requestmgr_create(gmctx, dispatchmgr, dispatchv4,
|
||||
result = dns_requestmgr_create(isc_g_mctx, dispatchmgr, dispatchv4,
|
||||
dispatchv6, &requestmgr);
|
||||
check_result(result, "dns_requestmgr_create");
|
||||
|
||||
if (keystr != NULL) {
|
||||
setup_keystr();
|
||||
} else if (local_only) {
|
||||
result = read_sessionkey(gmctx);
|
||||
result = read_sessionkey(isc_g_mctx);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fatal("can't read key from %s: %s\n", keyfile,
|
||||
isc_result_totext(result));
|
||||
}
|
||||
} else if (keyfile != NULL) {
|
||||
setup_keyfile(gmctx);
|
||||
setup_keyfile(isc_g_mctx);
|
||||
}
|
||||
|
||||
isc_mutex_init(&answer_lock);
|
||||
|
|
@ -999,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':
|
||||
|
|
@ -1328,19 +1331,19 @@ parse_rdata(char **cmdlinep, dns_rdataclass_t rdataclass,
|
|||
|
||||
if (*cmdline != 0) {
|
||||
dns_rdatacallbacks_init(&callbacks);
|
||||
isc_lex_create(gmctx, strlen(cmdline), &lex);
|
||||
isc_lex_create(isc_g_mctx, strlen(cmdline), &lex);
|
||||
isc_buffer_init(&source, cmdline, strlen(cmdline));
|
||||
isc_buffer_add(&source, strlen(cmdline));
|
||||
result = isc_lex_openbuffer(lex, &source);
|
||||
check_result(result, "isc_lex_openbuffer");
|
||||
isc_buffer_allocate(gmctx, &buf, MAXWIRE);
|
||||
isc_buffer_allocate(isc_g_mctx, &buf, MAXWIRE);
|
||||
result = dns_rdata_fromtext(NULL, rdataclass, rdatatype, lex,
|
||||
dns_rootname, 0, gmctx, buf,
|
||||
dns_rootname, 0, isc_g_mctx, buf,
|
||||
&callbacks);
|
||||
isc_lex_destroy(&lex);
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
isc_buffer_usedregion(buf, &r);
|
||||
isc_buffer_allocate(gmctx, &newbuf, r.length);
|
||||
isc_buffer_allocate(isc_g_mctx, &newbuf, r.length);
|
||||
isc_buffer_putmem(newbuf, r.base, r.length);
|
||||
isc_buffer_usedregion(newbuf, &r);
|
||||
dns_rdata_fromregion(rdata, rdataclass, rdatatype, &r);
|
||||
|
|
@ -1619,14 +1622,15 @@ evaluate_server(char *cmdline) {
|
|||
if (primary_servers == servers) {
|
||||
primary_servers = NULL;
|
||||
}
|
||||
isc_mem_cput(gmctx, servers, ns_alloc, sizeof(isc_sockaddr_t));
|
||||
isc_mem_cput(isc_g_mctx, servers, ns_alloc,
|
||||
sizeof(isc_sockaddr_t));
|
||||
}
|
||||
|
||||
default_servers = false;
|
||||
|
||||
ns_alloc = MAX_SERVERADDRS;
|
||||
ns_inuse = 0;
|
||||
servers = isc_mem_cget(gmctx, ns_alloc, sizeof(isc_sockaddr_t));
|
||||
servers = isc_mem_cget(isc_g_mctx, ns_alloc, sizeof(isc_sockaddr_t));
|
||||
ns_total = get_addresses(server, (in_port_t)port, servers, ns_alloc);
|
||||
if (ns_total == 0) {
|
||||
return STATUS_SYNTAX;
|
||||
|
|
@ -1669,12 +1673,14 @@ evaluate_local(char *cmdline) {
|
|||
|
||||
if (have_ipv6 && inet_pton(AF_INET6, local, &in6) == 1) {
|
||||
if (localaddr6 == NULL) {
|
||||
localaddr6 = isc_mem_get(gmctx, sizeof(isc_sockaddr_t));
|
||||
localaddr6 = isc_mem_get(isc_g_mctx,
|
||||
sizeof(isc_sockaddr_t));
|
||||
}
|
||||
isc_sockaddr_fromin6(localaddr6, &in6, (in_port_t)port);
|
||||
} else if (have_ipv4 && inet_pton(AF_INET, local, &in4) == 1) {
|
||||
if (localaddr4 == NULL) {
|
||||
localaddr4 = isc_mem_get(gmctx, sizeof(isc_sockaddr_t));
|
||||
localaddr4 = isc_mem_get(isc_g_mctx,
|
||||
sizeof(isc_sockaddr_t));
|
||||
}
|
||||
isc_sockaddr_fromin(localaddr4, &in4, (in_port_t)port);
|
||||
} else {
|
||||
|
|
@ -1732,14 +1738,14 @@ evaluate_key(char *cmdline) {
|
|||
return STATUS_SYNTAX;
|
||||
}
|
||||
secretlen = strlen(secretstr) * 3 / 4;
|
||||
secret = isc_mem_allocate(gmctx, secretlen);
|
||||
secret = isc_mem_allocate(isc_g_mctx, secretlen);
|
||||
|
||||
isc_buffer_init(&secretbuf, secret, secretlen);
|
||||
result = isc_base64_decodestring(secretstr, &secretbuf);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fprintf(stderr, "could not create key from %s: %s\n", secretstr,
|
||||
isc_result_totext(result));
|
||||
isc_mem_free(gmctx, secret);
|
||||
isc_mem_free(isc_g_mctx, secret);
|
||||
return STATUS_SYNTAX;
|
||||
}
|
||||
secretlen = isc_buffer_usedlength(&secretbuf);
|
||||
|
|
@ -1748,8 +1754,8 @@ evaluate_key(char *cmdline) {
|
|||
dns_tsigkey_detach(&tsigkey);
|
||||
}
|
||||
result = dns_tsigkey_create(mykeyname, hmac_alg, secret, secretlen,
|
||||
gmctx, &tsigkey);
|
||||
isc_mem_free(gmctx, secret);
|
||||
isc_g_mctx, &tsigkey);
|
||||
isc_mem_free(isc_g_mctx, secret);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fprintf(stderr, "could not create key from %s %s: %s\n",
|
||||
namestr, secretstr, isc_result_totext(result));
|
||||
|
|
@ -1792,7 +1798,7 @@ evaluate_realm(char *cmdline) {
|
|||
int n;
|
||||
|
||||
if (realm != NULL) {
|
||||
isc_mem_free(gmctx, realm);
|
||||
isc_mem_free(isc_g_mctx, realm);
|
||||
}
|
||||
|
||||
word = nsu_strsep(&cmdline, " \t\r\n");
|
||||
|
|
@ -1805,7 +1811,7 @@ evaluate_realm(char *cmdline) {
|
|||
error("realm is too long");
|
||||
return STATUS_SYNTAX;
|
||||
}
|
||||
realm = isc_mem_strdup(gmctx, buf);
|
||||
realm = isc_mem_strdup(isc_g_mctx, buf);
|
||||
return STATUS_MORE;
|
||||
#else /* HAVE_GSSAPI */
|
||||
UNUSED(cmdline);
|
||||
|
|
@ -2224,7 +2230,7 @@ show_message(FILE *stream, dns_message_t *msg, const char *description) {
|
|||
if (buf != NULL) {
|
||||
isc_buffer_free(&buf);
|
||||
}
|
||||
isc_buffer_allocate(gmctx, &buf, bufsz);
|
||||
isc_buffer_allocate(isc_g_mctx, &buf, bufsz);
|
||||
result = dns_message_totext(msg, style, 0, buf);
|
||||
bufsz *= 2;
|
||||
} while (result == ISC_R_NOSPACE);
|
||||
|
|
@ -2534,7 +2540,8 @@ update_completed(void *arg) {
|
|||
}
|
||||
|
||||
LOCK(&answer_lock);
|
||||
dns_message_create(gmctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE, &answer);
|
||||
dns_message_create(isc_g_mctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE,
|
||||
&answer);
|
||||
result = dns_request_getresponse(request, answer,
|
||||
DNS_MESSAGEPARSE_PRESERVEORDER);
|
||||
switch (result) {
|
||||
|
|
@ -2595,8 +2602,8 @@ update_completed(void *arg) {
|
|||
done:
|
||||
dns_request_destroy(&request);
|
||||
if (usegsstsig) {
|
||||
dns_name_free(&tmpzonename, gmctx);
|
||||
dns_name_free(&restart_primary, gmctx);
|
||||
dns_name_free(&tmpzonename, isc_g_mctx);
|
||||
dns_name_free(&restart_primary, isc_g_mctx);
|
||||
dns_name_init(&tmpzonename);
|
||||
dns_name_init(&restart_primary);
|
||||
}
|
||||
|
|
@ -2701,7 +2708,7 @@ recvsoa(void *arg) {
|
|||
if (shuttingdown) {
|
||||
dns_request_destroy(&request);
|
||||
dns_message_detach(&soaquery);
|
||||
isc_mem_put(gmctx, reqinfo, sizeof(nsu_requestinfo_t));
|
||||
isc_mem_put(isc_g_mctx, reqinfo, sizeof(nsu_requestinfo_t));
|
||||
maybeshutdown();
|
||||
return;
|
||||
}
|
||||
|
|
@ -2713,15 +2720,16 @@ recvsoa(void *arg) {
|
|||
dns_message_renderreset(soaquery);
|
||||
dns_message_settsigkey(soaquery, NULL);
|
||||
sendrequest(&servers[ns_inuse], soaquery, &request);
|
||||
isc_mem_put(gmctx, reqinfo, sizeof(nsu_requestinfo_t));
|
||||
isc_mem_put(isc_g_mctx, reqinfo, sizeof(nsu_requestinfo_t));
|
||||
setzoneclass(dns_rdataclass_none);
|
||||
return;
|
||||
}
|
||||
|
||||
isc_mem_put(gmctx, reqinfo, sizeof(nsu_requestinfo_t));
|
||||
isc_mem_put(isc_g_mctx, reqinfo, sizeof(nsu_requestinfo_t));
|
||||
|
||||
ddebug("About to create rcvmsg");
|
||||
dns_message_create(gmctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE, &rcvmsg);
|
||||
dns_message_create(isc_g_mctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE,
|
||||
&rcvmsg);
|
||||
result = dns_request_getresponse(request, rcvmsg,
|
||||
DNS_MESSAGEPARSE_PRESERVEORDER);
|
||||
if (result == DNS_R_TSIGERRORSET && servers != NULL) {
|
||||
|
|
@ -2732,7 +2740,7 @@ recvsoa(void *arg) {
|
|||
dns_message_detach(&rcvmsg);
|
||||
ddebug("Destroying request [%p]", request);
|
||||
dns_request_destroy(&request);
|
||||
reqinfo = isc_mem_get(gmctx, sizeof(nsu_requestinfo_t));
|
||||
reqinfo = isc_mem_get(isc_g_mctx, sizeof(nsu_requestinfo_t));
|
||||
reqinfo->msg = soaquery;
|
||||
reqinfo->addr = addr;
|
||||
dns_message_renderreset(soaquery);
|
||||
|
|
@ -2890,11 +2898,11 @@ lookforsoa:
|
|||
serverstr[isc_buffer_usedlength(&buf)] = 0;
|
||||
|
||||
if (primary_servers != NULL && primary_servers != servers) {
|
||||
isc_mem_cput(gmctx, primary_servers, primary_alloc,
|
||||
isc_mem_cput(isc_g_mctx, primary_servers, primary_alloc,
|
||||
sizeof(isc_sockaddr_t));
|
||||
}
|
||||
primary_alloc = MAX_SERVERADDRS;
|
||||
primary_servers = isc_mem_cget(gmctx, primary_alloc,
|
||||
primary_servers = isc_mem_cget(isc_g_mctx, primary_alloc,
|
||||
sizeof(isc_sockaddr_t));
|
||||
primary_total = get_addresses(serverstr, dnsport,
|
||||
primary_servers, primary_alloc);
|
||||
|
|
@ -2917,9 +2925,9 @@ lookforsoa:
|
|||
#if HAVE_GSSAPI
|
||||
if (usegsstsig) {
|
||||
dns_name_init(&tmpzonename);
|
||||
dns_name_dup(zname, gmctx, &tmpzonename);
|
||||
dns_name_dup(zname, isc_g_mctx, &tmpzonename);
|
||||
dns_name_init(&restart_primary);
|
||||
dns_name_dup(&primary, gmctx, &restart_primary);
|
||||
dns_name_dup(&primary, isc_g_mctx, &restart_primary);
|
||||
start_gssrequest(&primary);
|
||||
} else {
|
||||
send_update(zname, &primary_servers[primary_inuse]);
|
||||
|
|
@ -2973,7 +2981,7 @@ sendrequest(isc_sockaddr_t *destaddr, dns_message_t *msg,
|
|||
}
|
||||
}
|
||||
|
||||
reqinfo = isc_mem_get(gmctx, sizeof(nsu_requestinfo_t));
|
||||
reqinfo = isc_mem_get(isc_g_mctx, sizeof(nsu_requestinfo_t));
|
||||
reqinfo->msg = msg;
|
||||
reqinfo->addr = destaddr;
|
||||
|
||||
|
|
@ -3050,8 +3058,8 @@ static void
|
|||
failed_gssrequest(void) {
|
||||
seenerror = true;
|
||||
|
||||
dns_name_free(&tmpzonename, gmctx);
|
||||
dns_name_free(&restart_primary, gmctx);
|
||||
dns_name_free(&tmpzonename, isc_g_mctx);
|
||||
dns_name_free(&restart_primary, isc_g_mctx);
|
||||
dns_name_init(&tmpzonename);
|
||||
dns_name_init(&restart_primary);
|
||||
|
||||
|
|
@ -3079,11 +3087,11 @@ start_gssrequest(dns_name_t *primary) {
|
|||
dns_tsigkeyring_detach(&gssring);
|
||||
}
|
||||
|
||||
dns_tsigkeyring_create(gmctx, &gssring);
|
||||
dns_tsigkeyring_create(isc_g_mctx, &gssring);
|
||||
|
||||
dns_name_format(primary, namestr, sizeof(namestr));
|
||||
if (kserver == NULL) {
|
||||
kserver = isc_mem_get(gmctx, sizeof(isc_sockaddr_t));
|
||||
kserver = isc_mem_get(isc_g_mctx, sizeof(isc_sockaddr_t));
|
||||
}
|
||||
|
||||
memmove(kserver, &primary_servers[primary_inuse],
|
||||
|
|
@ -3092,7 +3100,7 @@ start_gssrequest(dns_name_t *primary) {
|
|||
servname = dns_fixedname_initname(&fname);
|
||||
|
||||
if (realm == NULL) {
|
||||
get_ticket_realm(gmctx);
|
||||
get_ticket_realm(isc_g_mctx);
|
||||
}
|
||||
|
||||
result = snprintf(servicename, sizeof(servicename), "DNS/%s%s", namestr,
|
||||
|
|
@ -3127,12 +3135,13 @@ start_gssrequest(dns_name_t *primary) {
|
|||
keyname->attributes.nocompress = true;
|
||||
|
||||
rmsg = NULL;
|
||||
dns_message_create(gmctx, NULL, NULL, DNS_MESSAGE_INTENTRENDER, &rmsg);
|
||||
dns_message_create(isc_g_mctx, NULL, NULL, DNS_MESSAGE_INTENTRENDER,
|
||||
&rmsg);
|
||||
|
||||
/* Build first request. */
|
||||
context = GSS_C_NO_CONTEXT;
|
||||
result = dns_tkey_buildgssquery(rmsg, keyname, servname, 0, &context,
|
||||
gmctx, &err_message);
|
||||
isc_g_mctx, &err_message);
|
||||
if (result == ISC_R_FAILURE) {
|
||||
fprintf(stderr, "tkey query failed: %s\n",
|
||||
err_message != NULL ? err_message : "unknown error");
|
||||
|
|
@ -3151,7 +3160,7 @@ failure:
|
|||
dns_message_detach(&rmsg);
|
||||
}
|
||||
if (err_message != NULL) {
|
||||
isc_mem_free(gmctx, err_message);
|
||||
isc_mem_free(isc_g_mctx, err_message);
|
||||
}
|
||||
failed_gssrequest();
|
||||
}
|
||||
|
|
@ -3174,7 +3183,7 @@ send_gssrequest(isc_sockaddr_t *destaddr, dns_message_t *msg,
|
|||
debug("send_gssrequest");
|
||||
REQUIRE(destaddr != NULL);
|
||||
|
||||
reqinfo = isc_mem_get(gmctx, sizeof(nsu_gssinfo_t));
|
||||
reqinfo = isc_mem_get(isc_g_mctx, sizeof(nsu_gssinfo_t));
|
||||
*reqinfo = (nsu_gssinfo_t){
|
||||
.msg = msg,
|
||||
.addr = destaddr,
|
||||
|
|
@ -3220,7 +3229,7 @@ recvgss(void *arg) {
|
|||
if (shuttingdown) {
|
||||
dns_request_destroy(&request);
|
||||
dns_message_detach(&tsigquery);
|
||||
isc_mem_put(gmctx, reqinfo, sizeof(nsu_gssinfo_t));
|
||||
isc_mem_put(isc_g_mctx, reqinfo, sizeof(nsu_gssinfo_t));
|
||||
maybeshutdown();
|
||||
return;
|
||||
}
|
||||
|
|
@ -3237,13 +3246,14 @@ recvgss(void *arg) {
|
|||
sizeof(isc_sockaddr_t));
|
||||
send_gssrequest(kserver, tsigquery, &request, context);
|
||||
}
|
||||
isc_mem_put(gmctx, reqinfo, sizeof(nsu_gssinfo_t));
|
||||
isc_mem_put(isc_g_mctx, reqinfo, sizeof(nsu_gssinfo_t));
|
||||
return;
|
||||
}
|
||||
isc_mem_put(gmctx, reqinfo, sizeof(nsu_gssinfo_t));
|
||||
isc_mem_put(isc_g_mctx, reqinfo, sizeof(nsu_gssinfo_t));
|
||||
|
||||
ddebug("recvgss creating rcvmsg");
|
||||
dns_message_create(gmctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE, &rcvmsg);
|
||||
dns_message_create(isc_g_mctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE,
|
||||
&rcvmsg);
|
||||
|
||||
result = dns_request_getresponse(request, rcvmsg,
|
||||
DNS_MESSAGEPARSE_PRESERVEORDER);
|
||||
|
|
@ -3351,7 +3361,7 @@ start_update(void) {
|
|||
return;
|
||||
}
|
||||
|
||||
dns_message_create(gmctx, NULL, NULL, DNS_MESSAGE_INTENTRENDER,
|
||||
dns_message_create(isc_g_mctx, NULL, NULL, DNS_MESSAGE_INTENTRENDER,
|
||||
&soaquery);
|
||||
|
||||
if (default_servers) {
|
||||
|
|
@ -3450,28 +3460,28 @@ cleanup(void) {
|
|||
|
||||
#ifdef HAVE_GSSAPI
|
||||
if (kserver != NULL) {
|
||||
isc_mem_put(gmctx, kserver, sizeof(isc_sockaddr_t));
|
||||
isc_mem_put(isc_g_mctx, kserver, sizeof(isc_sockaddr_t));
|
||||
}
|
||||
if (realm != NULL) {
|
||||
isc_mem_free(gmctx, realm);
|
||||
isc_mem_free(isc_g_mctx, realm);
|
||||
}
|
||||
if (dns_name_dynamic(&tmpzonename)) {
|
||||
dns_name_free(&tmpzonename, gmctx);
|
||||
dns_name_free(&tmpzonename, isc_g_mctx);
|
||||
}
|
||||
if (dns_name_dynamic(&restart_primary)) {
|
||||
dns_name_free(&restart_primary, gmctx);
|
||||
dns_name_free(&restart_primary, isc_g_mctx);
|
||||
}
|
||||
#endif /* ifdef HAVE_GSSAPI */
|
||||
|
||||
ddebug("Destroying memory context");
|
||||
if (memdebugging) {
|
||||
isc_mem_stats(gmctx, stderr);
|
||||
isc_mem_stats(isc_g_mctx, stderr);
|
||||
}
|
||||
|
||||
isc_mutex_destroy(&answer_lock);
|
||||
|
||||
ddebug("Shutting down managers");
|
||||
isc_managers_destroy(&gmctx);
|
||||
isc_managers_destroy();
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -3520,7 +3530,7 @@ main(int argc, char **argv) {
|
|||
|
||||
pre_parse_args(argc, argv);
|
||||
|
||||
isc_managers_create(&gmctx, 1);
|
||||
isc_managers_create(1);
|
||||
|
||||
parse_args(argc, argv);
|
||||
|
||||
|
|
|
|||
|
|
@ -73,7 +73,6 @@ static uint32_t algorithm;
|
|||
static isccc_region_t secret;
|
||||
static bool failed = false;
|
||||
static bool c_flag = false;
|
||||
static isc_mem_t *rndc_mctx = NULL;
|
||||
static char *command = NULL;
|
||||
static char *args = NULL;
|
||||
static uint32_t serial;
|
||||
|
|
@ -495,7 +494,7 @@ rndc_connected(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
|
|||
r.length = databuf->used;
|
||||
|
||||
/* isccc_ccmsg_init() attaches to the handle */
|
||||
isccc_ccmsg_init(rndc_mctx, handle, ccmsg);
|
||||
isccc_ccmsg_init(isc_g_mctx, handle, ccmsg);
|
||||
isccc_ccmsg_setmaxsize(ccmsg, 1024 * 1024);
|
||||
|
||||
isccc_ccmsg_readmessage(ccmsg, rndc_recvnonce, ccmsg);
|
||||
|
|
@ -870,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':
|
||||
|
|
@ -948,7 +947,7 @@ main(int argc, char **argv) {
|
|||
|
||||
serial = isc_random32();
|
||||
|
||||
isc_managers_create(&rndc_mctx, 1);
|
||||
isc_managers_create(1);
|
||||
isc_loopmgr_setup(rndc_start, NULL);
|
||||
|
||||
isc_nm_setinitialtimeout(timeout);
|
||||
|
|
@ -964,9 +963,9 @@ main(int argc, char **argv) {
|
|||
ISC_LOG_PRINTTAG | ISC_LOG_PRINTLEVEL, ISC_LOGCATEGORY_DEFAULT,
|
||||
ISC_LOGMODULE_DEFAULT);
|
||||
|
||||
parse_config(rndc_mctx, keyname, &pctx, &config);
|
||||
parse_config(isc_g_mctx, keyname, &pctx, &config);
|
||||
|
||||
isc_buffer_allocate(rndc_mctx, &databuf, 2048);
|
||||
isc_buffer_allocate(isc_g_mctx, &databuf, 2048);
|
||||
|
||||
/*
|
||||
* Convert argc/argv into a space-delimited command string
|
||||
|
|
@ -978,7 +977,7 @@ main(int argc, char **argv) {
|
|||
argslen += strlen(argv[i]) + 1;
|
||||
}
|
||||
|
||||
args = isc_mem_get(rndc_mctx, argslen);
|
||||
args = isc_mem_get(isc_g_mctx, argslen);
|
||||
|
||||
p = args;
|
||||
for (i = 0; i < argc; i++) {
|
||||
|
|
@ -1003,15 +1002,15 @@ main(int argc, char **argv) {
|
|||
cfg_obj_destroy(pctx, &config);
|
||||
cfg_parser_destroy(&pctx);
|
||||
|
||||
isc_mem_put(rndc_mctx, args, argslen);
|
||||
isc_mem_put(isc_g_mctx, args, argslen);
|
||||
|
||||
isc_buffer_free(&databuf);
|
||||
|
||||
if (show_final_mem) {
|
||||
isc_mem_stats(rndc_mctx, stderr);
|
||||
isc_mem_stats(isc_g_mctx, stderr);
|
||||
}
|
||||
|
||||
isc_managers_destroy(&rndc_mctx);
|
||||
isc_managers_destroy();
|
||||
|
||||
if (failed) {
|
||||
return 1;
|
||||
|
|
|
|||
|
|
@ -57,7 +57,6 @@
|
|||
#define PORT 5300
|
||||
#define TIMEOUT 30
|
||||
|
||||
static isc_mem_t *mctx = NULL;
|
||||
static dns_requestmgr_t *requestmgr = NULL;
|
||||
static bool have_src = false;
|
||||
static isc_sockaddr_t srcaddr;
|
||||
|
|
@ -80,7 +79,7 @@ recvresponse(void *arg) {
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
dns_message_create(mctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE,
|
||||
dns_message_create(isc_g_mctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE,
|
||||
&response);
|
||||
|
||||
result = dns_request_getresponse(request, response,
|
||||
|
|
@ -143,7 +142,7 @@ sendquery(void) {
|
|||
dns_rootname, 0);
|
||||
CHECK("dns_name_fromtext", result);
|
||||
|
||||
dns_message_create(mctx, NULL, NULL, DNS_MESSAGE_INTENTRENDER,
|
||||
dns_message_create(isc_g_mctx, NULL, NULL, DNS_MESSAGE_INTENTRENDER,
|
||||
&message);
|
||||
|
||||
message->opcode = dns_opcode_query;
|
||||
|
|
@ -269,16 +268,16 @@ main(int argc, char *argv[]) {
|
|||
}
|
||||
isc_sockaddr_fromin(&dstaddr, &inaddr, port);
|
||||
|
||||
isc_managers_create(&mctx, 1);
|
||||
isc_managers_create(1);
|
||||
|
||||
RUNCHECK(dns_dispatchmgr_create(mctx, &dispatchmgr));
|
||||
RUNCHECK(dns_dispatchmgr_create(isc_g_mctx, &dispatchmgr));
|
||||
|
||||
RUNCHECK(dns_dispatch_createudp(
|
||||
dispatchmgr, have_src ? &srcaddr : &bind_any, &dispatchv4));
|
||||
RUNCHECK(dns_requestmgr_create(mctx, dispatchmgr, dispatchv4, NULL,
|
||||
&requestmgr));
|
||||
RUNCHECK(dns_requestmgr_create(isc_g_mctx, dispatchmgr, dispatchv4,
|
||||
NULL, &requestmgr));
|
||||
|
||||
dns_view_create(mctx, NULL, 0, "_test", &view);
|
||||
dns_view_create(isc_g_mctx, NULL, 0, "_test", &view);
|
||||
|
||||
isc_loopmgr_setup(sendqueries, NULL);
|
||||
isc_loopmgr_teardown(teardown_view, view);
|
||||
|
|
@ -288,7 +287,7 @@ main(int argc, char *argv[]) {
|
|||
|
||||
isc_loopmgr_run();
|
||||
|
||||
isc_managers_destroy(&mctx);
|
||||
isc_managers_destroy();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@ dst_key_t *key;
|
|||
dns_fixedname_t fname;
|
||||
dns_name_t *name;
|
||||
unsigned int bits = 2048U;
|
||||
isc_mem_t *mctx;
|
||||
isc_logconfig_t *logconfig;
|
||||
int level = ISC_LOG_WARNING;
|
||||
char filename[255];
|
||||
|
|
@ -105,8 +104,6 @@ main(int argc, char **argv) {
|
|||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
isc_mem_create(argv[0], &mctx);
|
||||
|
||||
logconfig = isc_logconfig_get();
|
||||
isc_log_settag(logconfig, "bigkey");
|
||||
|
||||
|
|
@ -126,7 +123,7 @@ main(int argc, char **argv) {
|
|||
|
||||
CHECK(dst_key_buildinternal(name, DNS_KEYALG_RSASHA256, bits,
|
||||
DNS_KEYOWNER_ZONE, DNS_KEYPROTO_DNSSEC,
|
||||
dns_rdataclass_in, pkey, mctx, &key),
|
||||
dns_rdataclass_in, pkey, isc_g_mctx, &key),
|
||||
"dst_key_buildinternal(...)");
|
||||
|
||||
CHECK(dst_key_tofile(key, DST_TYPE_PRIVATE | DST_TYPE_PUBLIC, NULL),
|
||||
|
|
@ -138,7 +135,6 @@ main(int argc, char **argv) {
|
|||
printf("%s\n", filename);
|
||||
dst_key_free(&key);
|
||||
|
||||
isc_mem_detach(&mctx);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
#include <dns/message.h>
|
||||
|
||||
int parseflags = 0;
|
||||
isc_mem_t *mctx = NULL;
|
||||
bool printmemstats = false;
|
||||
bool dorender = false;
|
||||
|
||||
|
|
@ -81,13 +80,13 @@ printmessage(dns_message_t *msg) {
|
|||
isc_result_t result = ISC_R_SUCCESS;
|
||||
|
||||
do {
|
||||
buf = isc_mem_get(mctx, len);
|
||||
buf = isc_mem_get(isc_g_mctx, len);
|
||||
|
||||
isc_buffer_init(&b, buf, len);
|
||||
result = dns_message_totext(msg, &dns_master_style_debug, 0,
|
||||
&b);
|
||||
if (result == ISC_R_NOSPACE) {
|
||||
isc_mem_put(mctx, buf, len);
|
||||
isc_mem_put(isc_g_mctx, buf, len);
|
||||
len *= 2;
|
||||
} else if (result == ISC_R_SUCCESS) {
|
||||
printf("%.*s\n", (int)isc_buffer_usedlength(&b), buf);
|
||||
|
|
@ -95,7 +94,7 @@ printmessage(dns_message_t *msg) {
|
|||
} while (result == ISC_R_NOSPACE);
|
||||
|
||||
if (buf != NULL) {
|
||||
isc_mem_put(mctx, buf, len);
|
||||
isc_mem_put(isc_g_mctx, buf, len);
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
@ -121,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:
|
||||
|
|
@ -138,8 +137,6 @@ main(int argc, char *argv[]) {
|
|||
}
|
||||
isc_commandline_reset = true;
|
||||
|
||||
isc_mem_create(argv[0], &mctx);
|
||||
|
||||
while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) {
|
||||
switch (ch) {
|
||||
case 'b':
|
||||
|
|
@ -182,7 +179,7 @@ main(int argc, char *argv[]) {
|
|||
f = stdin;
|
||||
}
|
||||
|
||||
isc_buffer_allocate(mctx, &input, 64 * 1024);
|
||||
isc_buffer_allocate(isc_g_mctx, &input, 64 * 1024);
|
||||
|
||||
if (rawdata) {
|
||||
while (fread(&c, 1, 1, f) != 0) {
|
||||
|
|
@ -257,9 +254,8 @@ main(int argc, char *argv[]) {
|
|||
isc_buffer_free(&input);
|
||||
|
||||
if (printmemstats) {
|
||||
isc_mem_stats(mctx, stdout);
|
||||
isc_mem_stats(isc_g_mctx, stdout);
|
||||
}
|
||||
isc_mem_detach(&mctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -271,7 +267,8 @@ process_message(isc_buffer_t *source) {
|
|||
int i;
|
||||
|
||||
message = NULL;
|
||||
dns_message_create(mctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE, &message);
|
||||
dns_message_create(isc_g_mctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE,
|
||||
&message);
|
||||
|
||||
result = dns_message_parse(message, source, parseflags);
|
||||
if (result == DNS_R_RECOVERABLE) {
|
||||
|
|
@ -283,7 +280,7 @@ process_message(isc_buffer_t *source) {
|
|||
CHECKRESULT(result, "printmessage() failed");
|
||||
|
||||
if (printmemstats) {
|
||||
isc_mem_stats(mctx, stdout);
|
||||
isc_mem_stats(isc_g_mctx, stdout);
|
||||
}
|
||||
|
||||
if (dorender) {
|
||||
|
|
@ -304,7 +301,7 @@ process_message(isc_buffer_t *source) {
|
|||
message->counts[i] = 0; /* Another hack XXX */
|
||||
}
|
||||
|
||||
dns_compress_init(&cctx, mctx, 0);
|
||||
dns_compress_init(&cctx, isc_g_mctx, 0);
|
||||
|
||||
result = dns_message_renderbegin(message, &cctx, &buffer);
|
||||
CHECKRESULT(result, "dns_message_renderbegin() failed");
|
||||
|
|
@ -337,11 +334,11 @@ process_message(isc_buffer_t *source) {
|
|||
|
||||
printf("Message rendered.\n");
|
||||
if (printmemstats) {
|
||||
isc_mem_stats(mctx, stdout);
|
||||
isc_mem_stats(isc_g_mctx, stdout);
|
||||
}
|
||||
|
||||
dns_message_create(mctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE,
|
||||
&message);
|
||||
dns_message_create(isc_g_mctx, NULL, NULL,
|
||||
DNS_MESSAGE_INTENTPARSE, &message);
|
||||
|
||||
result = dns_message_parse(message, &buffer, parseflags);
|
||||
CHECKRESULT(result, "dns_message_parse failed");
|
||||
|
|
|
|||
|
|
@ -51,8 +51,6 @@ static const char *protocols[] = { "udp", "tcp",
|
|||
"https-get", "http-plain-post",
|
||||
"http-plain-get" };
|
||||
|
||||
static isc_mem_t *mctx = NULL;
|
||||
|
||||
static protocol_t protocol;
|
||||
static const char *address;
|
||||
static const char *port;
|
||||
|
|
@ -285,7 +283,7 @@ parse_options(int argc, char **argv) {
|
|||
|
||||
static void
|
||||
setup(void) {
|
||||
isc_managers_create(&mctx, workers);
|
||||
isc_managers_create(workers);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -298,7 +296,7 @@ teardown(void) {
|
|||
isc_tlsctx_free(&tls_ctx);
|
||||
}
|
||||
|
||||
isc_managers_destroy(&mctx);
|
||||
isc_managers_destroy();
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -33,8 +33,6 @@ typedef enum { UDP, TCP, DOT, HTTPS, HTTP } protocol_t;
|
|||
|
||||
static const char *protocols[] = { "udp", "tcp", "dot", "https", "http-plain" };
|
||||
|
||||
static isc_mem_t *mctx = NULL;
|
||||
|
||||
static protocol_t protocol;
|
||||
static in_port_t port;
|
||||
static isc_netaddr_t netaddr;
|
||||
|
|
@ -166,7 +164,7 @@ parse_options(int argc, char **argv) {
|
|||
|
||||
static void
|
||||
setup(void) {
|
||||
isc_managers_create(&mctx, workers);
|
||||
isc_managers_create(workers);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -175,7 +173,7 @@ teardown(void) {
|
|||
isc_tlsctx_free(&tls_ctx);
|
||||
}
|
||||
|
||||
isc_managers_destroy(&mctx);
|
||||
isc_managers_destroy();
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -208,7 +206,7 @@ read_cb(isc_nmhandle_t *handle, isc_result_t eresult, isc_region_t *region,
|
|||
((uint8_t *)region->base)[2] ^= 0x80;
|
||||
}
|
||||
|
||||
reply = isc_mem_get(mctx, sizeof(isc_region_t) + region->length);
|
||||
reply = isc_mem_get(isc_g_mctx, sizeof(isc_region_t) + region->length);
|
||||
reply->length = region->length;
|
||||
reply->base = (uint8_t *)reply + sizeof(isc_region_t);
|
||||
memmove(reply->base, region->base, region->length);
|
||||
|
|
@ -224,7 +222,7 @@ send_cb(isc_nmhandle_t *handle, isc_result_t eresult, void *cbarg) {
|
|||
REQUIRE(handle != NULL);
|
||||
REQUIRE(eresult == ISC_R_SUCCESS);
|
||||
|
||||
isc_mem_put(mctx, cbarg, sizeof(isc_region_t) + reply->length);
|
||||
isc_mem_put(isc_g_mctx, cbarg, sizeof(isc_region_t) + reply->length);
|
||||
}
|
||||
|
||||
static isc_result_t
|
||||
|
|
@ -267,7 +265,7 @@ run(void) {
|
|||
if (is_https) {
|
||||
isc_tlsctx_createserver(NULL, NULL, &tls_ctx);
|
||||
}
|
||||
eps = isc_nm_http_endpoints_new(mctx);
|
||||
eps = isc_nm_http_endpoints_new(isc_g_mctx);
|
||||
result = isc_nm_http_endpoints_add(
|
||||
eps, ISC_NM_HTTP_DEFAULT_PATH, read_cb, NULL);
|
||||
|
||||
|
|
|
|||
|
|
@ -55,8 +55,6 @@
|
|||
|
||||
#include "dnstap.pb-c.h"
|
||||
|
||||
isc_mem_t *mctx = NULL;
|
||||
bool memrecord = false;
|
||||
bool printmessage = false;
|
||||
bool hexmessage = false;
|
||||
bool yaml = false;
|
||||
|
|
@ -104,7 +102,7 @@ print_dtdata(dns_dtdata_t *dt) {
|
|||
isc_result_t result;
|
||||
isc_buffer_t *b = NULL;
|
||||
|
||||
isc_buffer_allocate(mctx, &b, 2048);
|
||||
isc_buffer_allocate(isc_g_mctx, &b, 2048);
|
||||
if (b == NULL) {
|
||||
fatal("out of memory");
|
||||
}
|
||||
|
|
@ -130,7 +128,7 @@ print_hex(dns_dtdata_t *dt) {
|
|||
}
|
||||
|
||||
textlen = (dt->msgdata.length * 2) + 1;
|
||||
isc_buffer_allocate(mctx, &b, textlen);
|
||||
isc_buffer_allocate(isc_g_mctx, &b, textlen);
|
||||
if (b == NULL) {
|
||||
fatal("out of memory");
|
||||
}
|
||||
|
|
@ -155,7 +153,7 @@ print_packet(dns_dtdata_t *dt, const dns_master_style_t *style) {
|
|||
if (dt->msg != NULL) {
|
||||
size_t textlen = 2048;
|
||||
|
||||
isc_buffer_allocate(mctx, &b, textlen);
|
||||
isc_buffer_allocate(isc_g_mctx, &b, textlen);
|
||||
if (b == NULL) {
|
||||
fatal("out of memory");
|
||||
}
|
||||
|
|
@ -348,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;
|
||||
|
|
@ -376,9 +373,7 @@ main(int argc, char *argv[]) {
|
|||
fatal("no file specified");
|
||||
}
|
||||
|
||||
isc_mem_create(isc_commandline_progname, &mctx);
|
||||
|
||||
CHECKM(dns_dt_open(argv[0], dns_dtmode_file, mctx, &handle),
|
||||
CHECKM(dns_dt_open(argv[0], dns_dtmode_file, isc_g_mctx, &handle),
|
||||
"dns_dt_openfile");
|
||||
|
||||
for (;;) {
|
||||
|
|
@ -396,7 +391,7 @@ main(int argc, char *argv[]) {
|
|||
input.base = data;
|
||||
input.length = datalen;
|
||||
|
||||
result = dns_dt_parse(mctx, &input, &dt);
|
||||
result = dns_dt_parse(isc_g_mctx, &input, &dt);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
continue;
|
||||
}
|
||||
|
|
@ -426,7 +421,6 @@ cleanup:
|
|||
if (message != NULL) {
|
||||
dns_message_detach(&message);
|
||||
}
|
||||
isc_mem_detach(&mctx);
|
||||
|
||||
exit(rv);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -82,7 +82,6 @@
|
|||
#define UDPTIMEOUT 5
|
||||
#define MAXTRIES 0xffffffff
|
||||
|
||||
static isc_mem_t *mctx = NULL;
|
||||
static dns_requestmgr_t *requestmgr = NULL;
|
||||
static const char *batchname = NULL;
|
||||
static FILE *batchfp = NULL;
|
||||
|
|
@ -211,7 +210,7 @@ recvresponse(void *arg) {
|
|||
}
|
||||
}
|
||||
|
||||
dns_message_create(mctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE,
|
||||
dns_message_create(isc_g_mctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE,
|
||||
&response);
|
||||
|
||||
parseflags |= DNS_MESSAGEPARSE_PRESERVEORDER;
|
||||
|
|
@ -268,15 +267,15 @@ recvresponse(void *arg) {
|
|||
if (display_multiline || (!display_ttl && !display_class)) {
|
||||
result = dns_master_stylecreate(&style, styleflags, 24, 24, 24,
|
||||
32, 80, 8, display_splitwidth,
|
||||
mctx);
|
||||
isc_g_mctx);
|
||||
} else if (!display_ttl || !display_class) {
|
||||
result = dns_master_stylecreate(&style, styleflags, 24, 24, 32,
|
||||
40, 80, 8, display_splitwidth,
|
||||
mctx);
|
||||
isc_g_mctx);
|
||||
} else {
|
||||
result = dns_master_stylecreate(&style, styleflags, 24, 32, 40,
|
||||
48, 80, 8, display_splitwidth,
|
||||
mctx);
|
||||
isc_g_mctx);
|
||||
}
|
||||
CHECK("dns_master_stylecreate2", result);
|
||||
|
||||
|
|
@ -289,7 +288,7 @@ recvresponse(void *arg) {
|
|||
flags |= DNS_MESSAGETEXTFLAG_NOCOMMENTS;
|
||||
}
|
||||
|
||||
isc_buffer_allocate(mctx, &buf, len);
|
||||
isc_buffer_allocate(isc_g_mctx, &buf, len);
|
||||
|
||||
if (yaml) {
|
||||
char sockstr[ISC_SOCKADDR_FORMATSIZE];
|
||||
|
|
@ -402,7 +401,7 @@ repopulate_buffer:
|
|||
buftoosmall:
|
||||
len += OUTPUTBUF;
|
||||
isc_buffer_free(&buf);
|
||||
isc_buffer_allocate(mctx, &buf, len);
|
||||
isc_buffer_allocate(isc_g_mctx, &buf, len);
|
||||
goto repopulate_buffer;
|
||||
}
|
||||
CHECK("dns_message_pseudosectiontotext", result);
|
||||
|
|
@ -509,7 +508,7 @@ repopulate_buffer:
|
|||
cleanup:
|
||||
fflush(stdout);
|
||||
if (style != NULL) {
|
||||
dns_master_styledestroy(&style, mctx);
|
||||
dns_master_styledestroy(&style, isc_g_mctx);
|
||||
}
|
||||
if (query != NULL) {
|
||||
dns_message_detach(&query);
|
||||
|
|
@ -570,7 +569,7 @@ sendquery(struct query *query) {
|
|||
dns_rootname, 0);
|
||||
CHECK("dns_name_fromtext", result);
|
||||
|
||||
dns_message_create(mctx, NULL, NULL, DNS_MESSAGE_INTENTRENDER,
|
||||
dns_message_create(isc_g_mctx, NULL, NULL, DNS_MESSAGE_INTENTRENDER,
|
||||
&message);
|
||||
|
||||
message->opcode = dns_opcode_query;
|
||||
|
|
@ -908,7 +907,7 @@ newopts(struct query *query) {
|
|||
size_t len = sizeof(query->ednsopts[0]) * EDNSOPTS;
|
||||
size_t i;
|
||||
|
||||
query->ednsopts = isc_mem_allocate(mctx, len);
|
||||
query->ednsopts = isc_mem_allocate(isc_g_mctx, len);
|
||||
|
||||
for (i = 0; i < EDNSOPTS; i++) {
|
||||
query->ednsopts[i].code = 0;
|
||||
|
|
@ -942,7 +941,7 @@ save_opt(struct query *query, char *code, char *value) {
|
|||
|
||||
if (value != NULL) {
|
||||
char *buf;
|
||||
buf = isc_mem_allocate(mctx, strlen(value) / 2 + 1);
|
||||
buf = isc_mem_allocate(isc_g_mctx, strlen(value) / 2 + 1);
|
||||
isc_buffer_init(&b, buf, strlen(value) / 2 + 1);
|
||||
result = isc_hex_decodestring(value, &b);
|
||||
CHECK("isc_hex_decodestring", result);
|
||||
|
|
@ -981,7 +980,7 @@ parse_netprefix(isc_sockaddr_t **sap, const char *value) {
|
|||
netmask = 0;
|
||||
}
|
||||
|
||||
sa = isc_mem_allocate(mctx, sizeof(*sa));
|
||||
sa = isc_mem_allocate(isc_g_mctx, sizeof(*sa));
|
||||
if (inet_pton(AF_INET6, buf, &in6) == 1) {
|
||||
parsed = true;
|
||||
isc_sockaddr_fromin6(sa, &in6, 0);
|
||||
|
|
@ -1484,7 +1483,8 @@ plus_option(char *option, struct query *query, bool global) {
|
|||
}
|
||||
if (!state) {
|
||||
if (query->ecs_addr != NULL) {
|
||||
isc_mem_free(mctx, query->ecs_addr);
|
||||
isc_mem_free(isc_g_mctx,
|
||||
query->ecs_addr);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
|
@ -1776,12 +1776,12 @@ static struct query *
|
|||
clone_default_query(void) {
|
||||
struct query *query;
|
||||
|
||||
query = isc_mem_allocate(mctx, sizeof(struct query));
|
||||
query = isc_mem_allocate(isc_g_mctx, sizeof(struct query));
|
||||
memmove(query, &default_query, sizeof(struct query));
|
||||
if (default_query.ecs_addr != NULL) {
|
||||
size_t len = sizeof(isc_sockaddr_t);
|
||||
|
||||
query->ecs_addr = isc_mem_allocate(mctx, len);
|
||||
query->ecs_addr = isc_mem_allocate(isc_g_mctx, len);
|
||||
memmove(query->ecs_addr, default_query.ecs_addr, len);
|
||||
}
|
||||
|
||||
|
|
@ -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) {
|
||||
|
|
@ -2005,9 +2005,9 @@ parse_args(bool is_batchfile, int argc, char **argv) {
|
|||
}
|
||||
if (query != &default_query) {
|
||||
if (query->ecs_addr != NULL) {
|
||||
isc_mem_free(mctx, query->ecs_addr);
|
||||
isc_mem_free(isc_g_mctx, query->ecs_addr);
|
||||
}
|
||||
isc_mem_free(mctx, query);
|
||||
isc_mem_free(isc_g_mctx, query);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2020,7 +2020,7 @@ set_source_ports(dns_dispatchmgr_t *manager) {
|
|||
in_port_t udpport_low, udpport_high;
|
||||
isc_result_t result;
|
||||
|
||||
isc_portset_create(mctx, &v4portset);
|
||||
isc_portset_create(isc_g_mctx, &v4portset);
|
||||
result = isc_net_getudpportrange(AF_INET, &udpport_low, &udpport_high);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fatal("isc_net_getudpportrange (v4) failed");
|
||||
|
|
@ -2028,7 +2028,7 @@ set_source_ports(dns_dispatchmgr_t *manager) {
|
|||
|
||||
isc_portset_addrange(v4portset, udpport_low, udpport_high);
|
||||
|
||||
isc_portset_create(mctx, &v6portset);
|
||||
isc_portset_create(isc_g_mctx, &v6portset);
|
||||
result = isc_net_getudpportrange(AF_INET6, &udpport_low, &udpport_high);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fatal("isc_net_getudpportrange (v6) failed");
|
||||
|
|
@ -2041,8 +2041,8 @@ set_source_ports(dns_dispatchmgr_t *manager) {
|
|||
fatal("dns_dispatchmgr_setavailports failed");
|
||||
}
|
||||
|
||||
isc_portset_destroy(mctx, &v4portset);
|
||||
isc_portset_destroy(mctx, &v6portset);
|
||||
isc_portset_destroy(isc_g_mctx, &v4portset);
|
||||
isc_portset_destroy(isc_g_mctx, &v6portset);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -2056,7 +2056,7 @@ teardown(void *arg ISC_ATTR_UNUSED) {
|
|||
|
||||
static void
|
||||
setup(void *arg ISC_ATTR_UNUSED) {
|
||||
RUNCHECK(dns_dispatchmgr_create(mctx, &dispatchmgr));
|
||||
RUNCHECK(dns_dispatchmgr_create(isc_g_mctx, &dispatchmgr));
|
||||
|
||||
set_source_ports(dispatchmgr);
|
||||
|
||||
|
|
@ -2069,10 +2069,10 @@ setup(void *arg ISC_ATTR_UNUSED) {
|
|||
dispatchmgr, have_src ? &srcaddr : &bind_any, &dispatchvx));
|
||||
|
||||
RUNCHECK(dns_requestmgr_create(
|
||||
mctx, dispatchmgr, have_ipv4 ? dispatchvx : NULL,
|
||||
isc_g_mctx, dispatchmgr, have_ipv4 ? dispatchvx : NULL,
|
||||
have_ipv6 ? dispatchvx : NULL, &requestmgr));
|
||||
|
||||
dns_view_create(mctx, NULL, 0, "_mdig", &view);
|
||||
dns_view_create(isc_g_mctx, NULL, 0, "_mdig", &view);
|
||||
}
|
||||
|
||||
/*% Main processing routine for mdig */
|
||||
|
|
@ -2094,7 +2094,7 @@ main(int argc, char *argv[]) {
|
|||
|
||||
preparse_args(argc, argv);
|
||||
|
||||
isc_managers_create(&mctx, 1);
|
||||
isc_managers_create(1);
|
||||
|
||||
isc_nonce_buf(cookie_secret, sizeof(cookie_secret));
|
||||
|
||||
|
|
@ -2158,22 +2158,22 @@ main(int argc, char *argv[]) {
|
|||
if (query->ednsopts != NULL) {
|
||||
for (i = 0; i < EDNSOPTS; i++) {
|
||||
if (query->ednsopts[i].value != NULL) {
|
||||
isc_mem_free(mctx,
|
||||
isc_mem_free(isc_g_mctx,
|
||||
query->ednsopts[i].value);
|
||||
}
|
||||
}
|
||||
isc_mem_free(mctx, query->ednsopts);
|
||||
isc_mem_free(isc_g_mctx, query->ednsopts);
|
||||
}
|
||||
if (query->ecs_addr != NULL) {
|
||||
isc_mem_free(mctx, query->ecs_addr);
|
||||
isc_mem_free(isc_g_mctx, query->ecs_addr);
|
||||
}
|
||||
isc_mem_free(mctx, query);
|
||||
isc_mem_free(isc_g_mctx, query);
|
||||
}
|
||||
|
||||
if (default_query.ecs_addr != NULL) {
|
||||
isc_mem_free(mctx, default_query.ecs_addr);
|
||||
isc_mem_free(isc_g_mctx, default_query.ecs_addr);
|
||||
}
|
||||
|
||||
isc_managers_destroy(&mctx);
|
||||
isc_managers_destroy();
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,6 @@ setup_logging(FILE *errout) {
|
|||
int
|
||||
main(int argc, char **argv) {
|
||||
char *file;
|
||||
isc_mem_t *mctx = NULL;
|
||||
isc_result_t result;
|
||||
uint32_t flags = 0U;
|
||||
int ch;
|
||||
|
|
@ -92,24 +91,24 @@ main(int argc, char **argv) {
|
|||
}
|
||||
file = argv[0];
|
||||
|
||||
isc_mem_create(isc_commandline_progname, &mctx);
|
||||
setup_logging(stderr);
|
||||
|
||||
if (upgrade) {
|
||||
flags = DNS_JOURNAL_COMPACTALL;
|
||||
result = dns_journal_compact(mctx, file, 0, flags, 0);
|
||||
result = dns_journal_compact(isc_g_mctx, file, 0, flags, 0);
|
||||
} else if (downgrade) {
|
||||
flags = DNS_JOURNAL_COMPACTALL | DNS_JOURNAL_VERSION1;
|
||||
result = dns_journal_compact(mctx, file, 0, flags, 0);
|
||||
result = dns_journal_compact(isc_g_mctx, file, 0, flags, 0);
|
||||
} else if (compact) {
|
||||
flags = 0;
|
||||
result = dns_journal_compact(mctx, file, serial, flags, 0);
|
||||
result = dns_journal_compact(isc_g_mctx, file, serial, flags,
|
||||
0);
|
||||
} else {
|
||||
result = dns_journal_print(mctx, flags, file, stdout);
|
||||
result = dns_journal_print(isc_g_mctx, flags, file, stdout);
|
||||
if (result == DNS_R_NOJOURNAL) {
|
||||
fprintf(stderr, "%s\n", isc_result_totext(result));
|
||||
}
|
||||
}
|
||||
isc_mem_detach(&mctx);
|
||||
|
||||
return result != ISC_R_SUCCESS ? 1 : 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
#include <dns/name.h>
|
||||
#include <dns/types.h>
|
||||
|
||||
isc_mem_t *mctx = NULL;
|
||||
char jbuf[PATH_MAX];
|
||||
|
||||
static void
|
||||
|
|
@ -55,8 +54,8 @@ loadzone(dns_db_t **db, const char *origin, const char *filename) {
|
|||
return result;
|
||||
}
|
||||
|
||||
result = dns_db_create(mctx, ZONEDB_DEFAULT, name, dns_dbtype_zone,
|
||||
dns_rdataclass_in, 0, NULL, db);
|
||||
result = dns_db_create(isc_g_mctx, ZONEDB_DEFAULT, name,
|
||||
dns_dbtype_zone, dns_rdataclass_in, 0, NULL, db);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return result;
|
||||
}
|
||||
|
|
@ -73,7 +72,7 @@ loadjournal(dns_db_t *db, const char *file) {
|
|||
dns_journal_t *jnl = NULL;
|
||||
isc_result_t result;
|
||||
|
||||
result = dns_journal_open(mctx, file, DNS_JOURNAL_READ, &jnl);
|
||||
result = dns_journal_open(isc_g_mctx, file, DNS_JOURNAL_READ, &jnl);
|
||||
if (result == ISC_R_NOTFOUND) {
|
||||
return ISC_R_SUCCESS;
|
||||
} else if (result != ISC_R_SUCCESS) {
|
||||
|
|
@ -129,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);
|
||||
|
|
@ -152,8 +151,6 @@ main(int argc, char **argv) {
|
|||
journal = (const char *)jbuf;
|
||||
}
|
||||
|
||||
isc_mem_create(isc_commandline_progname, &mctx);
|
||||
|
||||
logconfig = isc_logconfig_get();
|
||||
isc_log_createandusechannel(
|
||||
logconfig, "default_stderr", ISC_LOG_TOFILEDESC,
|
||||
|
|
@ -205,7 +202,7 @@ main(int argc, char **argv) {
|
|||
goto cleanup;
|
||||
}
|
||||
|
||||
result = dns_db_diff(mctx, newdb, NULL, olddb, NULL, journal);
|
||||
result = dns_db_diff(isc_g_mctx, newdb, NULL, olddb, NULL, journal);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fprintf(stderr, "Comparison failed: %s\n",
|
||||
isc_result_totext(result));
|
||||
|
|
@ -219,9 +216,5 @@ cleanup:
|
|||
dns_db_detach(&olddb);
|
||||
}
|
||||
|
||||
if (mctx != NULL) {
|
||||
isc_mem_detach(&mctx);
|
||||
}
|
||||
|
||||
return (result != ISC_R_SUCCESS) ? 1 : 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@
|
|||
#include <dns/rdataclass.h>
|
||||
#include <dns/rdatatype.h>
|
||||
|
||||
static isc_mem_t *mctx;
|
||||
static isc_lex_t *lex;
|
||||
|
||||
static isc_lexspecials_t specials;
|
||||
|
|
@ -60,9 +59,6 @@ cleanup(void) {
|
|||
isc_lex_close(lex);
|
||||
isc_lex_destroy(&lex);
|
||||
}
|
||||
if (mctx != NULL) {
|
||||
isc_mem_detach(&mctx);
|
||||
}
|
||||
}
|
||||
|
||||
ISC_NORETURN static void
|
||||
|
|
@ -170,8 +166,7 @@ main(int argc, char *argv[]) {
|
|||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
isc_mem_create(argv[0], &mctx);
|
||||
isc_lex_create(mctx, 256, &lex);
|
||||
isc_lex_create(isc_g_mctx, 256, &lex);
|
||||
|
||||
/*
|
||||
* Set up to lex DNS master file.
|
||||
|
|
@ -280,7 +275,7 @@ main(int argc, char *argv[]) {
|
|||
|
||||
isc_buffer_init(&dbuf, data, sizeof(data));
|
||||
result = dns_rdata_fromtext(&rdata, rdclass, rdtype, lex, name,
|
||||
0, mctx, &dbuf, NULL);
|
||||
0, isc_g_mctx, &dbuf, NULL);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
fatal("dns_rdata_fromtext: %s",
|
||||
isc_result_totext(result));
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -13,14 +13,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <isc/netmgr.h>
|
||||
#include <isc/result.h>
|
||||
#include <isc/timer.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
typedef struct isc_managers isc_managers_t;
|
||||
|
||||
void
|
||||
isc_managers_create(isc_mem_t **mctx, uint32_t workers);
|
||||
isc_managers_create(uint32_t workers);
|
||||
|
||||
void
|
||||
isc_managers_destroy(isc_mem_t **mctx);
|
||||
isc_managers_destroy(void);
|
||||
|
|
|
|||
|
|
@ -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).
|
||||
*/
|
||||
/*@}*/
|
||||
|
||||
|
|
@ -90,6 +94,12 @@ extern unsigned int isc_mem_defaultflags;
|
|||
#define ISC_MEMFLAG_DEFAULT 0
|
||||
#endif /* if !ISC_MEM_USE_INTERNAL_MALLOC */
|
||||
|
||||
/*%
|
||||
* A global 'default' memory context that can be used when we don't need more
|
||||
* specific memory context. It is always available.
|
||||
*/
|
||||
extern isc_mem_t *isc_g_mctx;
|
||||
|
||||
/*%
|
||||
* isc_mem_putanddetach() is a convenience function for use where you
|
||||
* have a structure with an attached memory context.
|
||||
|
|
@ -211,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.
|
||||
*
|
||||
|
|
@ -219,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){
|
||||
|
|
@ -1572,6 +1573,14 @@ isc__log_initialize(void) {
|
|||
|
||||
void
|
||||
isc__log_shutdown(void) {
|
||||
/*
|
||||
* There is a data race when the QP database reclaims chunks on the
|
||||
* call_rcu threads and tries to log the number of reclaimed chunks
|
||||
* while the server is shutting down. Work around this by adding
|
||||
* an rcu_barrier() before shutting down the global logging context.
|
||||
*/
|
||||
rcu_barrier();
|
||||
|
||||
REQUIRE(VALID_CONTEXT(isc__lctx));
|
||||
|
||||
isc_mem_t *mctx = isc__lctx->mctx;
|
||||
|
|
|
|||
|
|
@ -13,32 +13,22 @@
|
|||
|
||||
#include <isc/loop.h>
|
||||
#include <isc/managers.h>
|
||||
#include <isc/mem.h>
|
||||
#include <isc/netmgr.h>
|
||||
#include <isc/rwlock.h>
|
||||
#include <isc/util.h>
|
||||
#include <isc/uv.h>
|
||||
|
||||
void
|
||||
isc_managers_create(isc_mem_t **mctxp, uint32_t workers) {
|
||||
REQUIRE(mctxp != NULL && *mctxp == NULL);
|
||||
isc_mem_create("managers", mctxp);
|
||||
INSIST(*mctxp != NULL);
|
||||
|
||||
isc_loopmgr_create(*mctxp, workers);
|
||||
|
||||
isc_netmgr_create(*mctxp);
|
||||
|
||||
isc_managers_create(uint32_t workers) {
|
||||
isc_loopmgr_create(isc_g_mctx, workers);
|
||||
isc_netmgr_create(isc_g_mctx);
|
||||
isc_rwlock_setworkers(workers);
|
||||
}
|
||||
|
||||
void
|
||||
isc_managers_destroy(isc_mem_t **mctxp) {
|
||||
REQUIRE(mctxp != NULL && *mctxp != NULL);
|
||||
|
||||
isc_managers_destroy(void) {
|
||||
/*
|
||||
* The sequence of operations here is important:
|
||||
*/
|
||||
|
||||
isc_netmgr_destroy();
|
||||
isc_loopmgr_destroy();
|
||||
isc_mem_detach(mctxp);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,11 +65,14 @@
|
|||
#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;
|
||||
|
||||
isc_mem_t *isc_g_mctx = NULL;
|
||||
|
||||
/*
|
||||
* Constants.
|
||||
*/
|
||||
|
|
@ -382,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) {
|
||||
/*
|
||||
|
|
@ -393,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
|
||||
|
|
@ -401,6 +436,8 @@ isc__mem_shutdown(void) {
|
|||
|
||||
rcu_barrier();
|
||||
|
||||
isc_mem_detach(&isc_g_mctx);
|
||||
|
||||
isc__mem_checkdestroyed();
|
||||
|
||||
LOCK(&contextslock);
|
||||
|
|
@ -412,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) {
|
||||
|
|
@ -843,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);
|
||||
|
|
@ -863,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);
|
||||
|
|
@ -1156,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 */
|
||||
|
|
@ -1376,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", &mctx);
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr,
|
||||
"usage: load-names <filename.csv> <nthreads>\n");
|
||||
|
|
@ -439,7 +437,7 @@ main(int argc, char *argv[]) {
|
|||
}
|
||||
filesize = (size_t)fileoff;
|
||||
|
||||
filetext = isc_mem_get(mctx, filesize + 1);
|
||||
filetext = isc_mem_get(isc_g_mctx, filesize + 1);
|
||||
fp = fopen(filename, "r");
|
||||
if (fp == NULL || fread(filetext, 1, filesize, fp) < filesize) {
|
||||
fprintf(stderr, "read(%s): %s\n", filename, strerror(errno));
|
||||
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
#include <dns/types.h>
|
||||
|
||||
#include "dns/name.h"
|
||||
#include "tests/isc.h"
|
||||
|
||||
#include <tests/dns.h>
|
||||
#include <tests/qp.h>
|
||||
|
|
@ -58,7 +59,7 @@ static void
|
|||
smallname_from_name(const dns_name_t *name, void **valp, uint32_t *ctxp) {
|
||||
uint8_t labels = dns_name_countlabels(name);
|
||||
size_t size = sizeof(isc_refcount_t) + name->length + labels;
|
||||
*valp = isc_mem_get(mctx, size);
|
||||
*valp = isc_mem_get(isc_g_mctx, size);
|
||||
*ctxp = labels << 8 | name->length;
|
||||
isc_refcount_init(smallname_refcount(*valp, *ctxp), 0);
|
||||
memmove(smallname_ndata(*valp, *ctxp), name->ndata, name->length);
|
||||
|
|
@ -68,7 +69,7 @@ static void
|
|||
smallname_free(void *pval, uint32_t ival) {
|
||||
size_t size = sizeof(isc_refcount_t);
|
||||
size += smallname_length(pval, ival) + smallname_labels(pval, ival);
|
||||
isc_mem_put(mctx, pval, size);
|
||||
isc_mem_put(isc_g_mctx, pval, size);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -161,8 +162,6 @@ main(int argc, char *argv[]) {
|
|||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
isc_mem_create("test", &mctx);
|
||||
|
||||
filename = argv[0];
|
||||
result = isc_file_getsize(filename, &fileoff);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
|
|
@ -172,7 +171,7 @@ main(int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
filesize = (size_t)fileoff;
|
||||
filetext = isc_mem_get(mctx, filesize + 1);
|
||||
filetext = isc_mem_get(isc_g_mctx, filesize + 1);
|
||||
fp = fopen(filename, "r");
|
||||
if (fp == NULL || fread(filetext, 1, filesize, fp) < filesize) {
|
||||
fprintf(stderr, "read(%s): %s\n", filename, strerror(errno));
|
||||
|
|
@ -181,7 +180,7 @@ main(int argc, char *argv[]) {
|
|||
fclose(fp);
|
||||
filetext[filesize] = '\0';
|
||||
|
||||
dns_qp_create(mctx, &methods, NULL, &qp);
|
||||
dns_qp_create(isc_g_mctx, &methods, NULL, &qp);
|
||||
|
||||
pos = filetext;
|
||||
file_end = pos + filesize;
|
||||
|
|
@ -258,7 +257,7 @@ main(int argc, char *argv[]) {
|
|||
print_megabytes("qp-trie", bytes);
|
||||
print_megabytes("qp-trie + smallnames", bytes + smallbytes);
|
||||
print_megabytes("calculated", bytes + smallbytes + filesize);
|
||||
print_megabytes("allocated", isc_mem_inuse(mctx));
|
||||
print_megabytes("allocated", isc_mem_inuse(isc_g_mctx));
|
||||
printf("%6zu - height\n", qp_test_getheight(qp));
|
||||
printf("%6zu - max key len\n", qp_test_maxkeylen(qp));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ smallname_ndata(void *pval, uint32_t ival) {
|
|||
static void
|
||||
smallname_from_name(const dns_name_t *name, void **valp, uint32_t *ctxp) {
|
||||
size_t size = sizeof(isc_refcount_t) + name->length;
|
||||
*valp = isc_mem_get(mctx, size);
|
||||
*valp = isc_mem_get(isc_g_mctx, size);
|
||||
*ctxp = name->length;
|
||||
isc_refcount_init(smallname_refcount(*valp, *ctxp), 0);
|
||||
memmove(smallname_ndata(*valp, *ctxp), name->ndata, name->length);
|
||||
|
|
@ -62,7 +62,7 @@ static void
|
|||
smallname_free(void *pval, uint32_t ival) {
|
||||
size_t size = sizeof(isc_refcount_t);
|
||||
size += smallname_length(pval, ival);
|
||||
isc_mem_put(mctx, pval, size);
|
||||
isc_mem_put(isc_g_mctx, pval, size);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -133,7 +133,7 @@ load_qp(dns_qp_t *qp, const char *filename) {
|
|||
}
|
||||
|
||||
filesize = (size_t)fileoff;
|
||||
filetext = isc_mem_get(mctx, filesize + 1);
|
||||
filetext = isc_mem_get(isc_g_mctx, filesize + 1);
|
||||
fp = fopen(filename, "r");
|
||||
if (fp == NULL || fread(filetext, 1, filesize, fp) < filesize) {
|
||||
fprintf(stderr, "read(%s): %s\n", filename, strerror(errno));
|
||||
|
|
@ -197,9 +197,7 @@ main(int argc, char **argv) {
|
|||
usage();
|
||||
}
|
||||
|
||||
isc_mem_create("test", &mctx);
|
||||
|
||||
dns_qp_create(mctx, &methods, NULL, &qp);
|
||||
dns_qp_create(isc_g_mctx, &methods, NULL, &qp);
|
||||
|
||||
start = isc_time_monotonic();
|
||||
n = load_qp(qp, argv[1]);
|
||||
|
|
@ -209,7 +207,7 @@ main(int argc, char **argv) {
|
|||
snprintf(buf, sizeof(buf), "load %zd names:", n);
|
||||
printf("%-57s%7.3fsec\n", buf, (stop - start) / (double)NS_PER_SEC);
|
||||
|
||||
items = isc_mem_cget(mctx, n, sizeof(dns_fixedname_t));
|
||||
items = isc_mem_cget(isc_g_mctx, n, sizeof(dns_fixedname_t));
|
||||
dns_qpiter_init(qp, &it);
|
||||
|
||||
start = isc_time_monotonic();
|
||||
|
|
@ -273,6 +271,6 @@ main(int argc, char **argv) {
|
|||
"look up %zd wrong names (dns_qp_lookup):", n);
|
||||
printf("%-57s%7.3fsec\n", buf, (stop - start) / (double)NS_PER_SEC);
|
||||
|
||||
isc_mem_cput(mctx, items, n, sizeof(dns_fixedname_t));
|
||||
isc_mem_cput(isc_g_mctx, items, n, sizeof(dns_fixedname_t));
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,15 +52,15 @@ ISC_RUN_TEST_IMPL(dns_acl_isinsecure) {
|
|||
|
||||
UNUSED(state);
|
||||
|
||||
result = dns_acl_any(mctx, &any);
|
||||
result = dns_acl_any(isc_g_mctx, &any);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
result = dns_acl_none(mctx, &none);
|
||||
result = dns_acl_none(isc_g_mctx, &none);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
dns_acl_create(mctx, 1, ¬none);
|
||||
dns_acl_create(isc_g_mctx, 1, ¬none);
|
||||
|
||||
dns_acl_create(mctx, 1, ¬any);
|
||||
dns_acl_create(isc_g_mctx, 1, ¬any);
|
||||
|
||||
result = dns_acl_merge(notnone, none, false);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
|
@ -69,7 +69,7 @@ ISC_RUN_TEST_IMPL(dns_acl_isinsecure) {
|
|||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
#if defined(HAVE_GEOIP2)
|
||||
dns_acl_create(mctx, 1, &geoip);
|
||||
dns_acl_create(isc_g_mctx, 1, &geoip);
|
||||
|
||||
de = geoip->elements;
|
||||
assert_non_null(de);
|
||||
|
|
@ -83,7 +83,7 @@ ISC_RUN_TEST_IMPL(dns_acl_isinsecure) {
|
|||
de->node_num = dns_acl_node_count(geoip);
|
||||
geoip->length++;
|
||||
|
||||
dns_acl_create(mctx, 1, ¬geoip);
|
||||
dns_acl_create(isc_g_mctx, 1, ¬geoip);
|
||||
|
||||
result = dns_acl_merge(notgeoip, geoip, false);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ ISC_LOOP_TEST_IMPL(basic) {
|
|||
|
||||
dns_name_fromstring(name, "example.com.", NULL, 0, NULL);
|
||||
|
||||
bc = dns_badcache_new(mctx);
|
||||
bc = dns_badcache_new(isc_g_mctx);
|
||||
dns_badcache_add(bc, name, dns_rdatatype_aaaa, flags, now + 60);
|
||||
|
||||
flags = 0;
|
||||
|
|
@ -85,7 +85,7 @@ ISC_LOOP_TEST_IMPL(expire) {
|
|||
|
||||
dns_name_fromstring(name, "example.com.", NULL, 0, NULL);
|
||||
|
||||
bc = dns_badcache_new(mctx);
|
||||
bc = dns_badcache_new(isc_g_mctx);
|
||||
dns_badcache_add(bc, name, dns_rdatatype_aaaa, flags, now + 60);
|
||||
dns_badcache_add(bc, name, dns_rdatatype_a, flags, now + 60);
|
||||
|
||||
|
|
@ -137,7 +137,7 @@ ISC_LOOP_TEST_IMPL(print) {
|
|||
|
||||
dns_name_fromstring(name, "example.com.", NULL, 0, NULL);
|
||||
|
||||
bc = dns_badcache_new(mctx);
|
||||
bc = dns_badcache_new(isc_g_mctx);
|
||||
dns_badcache_add(bc, name, dns_rdatatype_a, flags, expire);
|
||||
dns_badcache_add(bc, name, dns_rdatatype_aaaa, flags, expire);
|
||||
|
||||
|
|
@ -210,7 +210,7 @@ ISC_LOOP_TEST_IMPL(flush) {
|
|||
|
||||
dns_name_fromstring(name, "example.com.", NULL, 0, NULL);
|
||||
|
||||
bc = dns_badcache_new(mctx);
|
||||
bc = dns_badcache_new(isc_g_mctx);
|
||||
dns_badcache_add(bc, name, dns_rdatatype_aaaa, flags, now + 60);
|
||||
|
||||
result = dns_badcache_find(bc, name, dns_rdatatype_aaaa, &flags, now);
|
||||
|
|
@ -234,7 +234,7 @@ ISC_LOOP_TEST_IMPL(flushname) {
|
|||
isc_result_t result;
|
||||
uint32_t flags = BADCACHE_TEST_FLAG;
|
||||
|
||||
bc = dns_badcache_new(mctx);
|
||||
bc = dns_badcache_new(isc_g_mctx);
|
||||
|
||||
dns_name_fromstring(name, "example.com.", NULL, 0, NULL);
|
||||
dns_badcache_add(bc, name, dns_rdatatype_aaaa, flags, now + 60);
|
||||
|
|
@ -280,7 +280,7 @@ ISC_LOOP_TEST_IMPL(flushtree) {
|
|||
isc_result_t result;
|
||||
uint32_t flags = BADCACHE_TEST_FLAG;
|
||||
|
||||
bc = dns_badcache_new(mctx);
|
||||
bc = dns_badcache_new(isc_g_mctx);
|
||||
|
||||
dns_name_fromstring(name, "example.com.", NULL, 0, NULL);
|
||||
dns_badcache_add(bc, name, dns_rdatatype_aaaa, flags, now + 60);
|
||||
|
|
@ -329,7 +329,7 @@ ISC_LOOP_TEST_IMPL(purge) {
|
|||
isc_result_t result;
|
||||
uint32_t flags = BADCACHE_TEST_FLAG;
|
||||
|
||||
bc = dns_badcache_new(mctx);
|
||||
bc = dns_badcache_new(isc_g_mctx);
|
||||
|
||||
dns_name_fromstring(name, "example.com.", NULL, 0, NULL);
|
||||
dns_badcache_add(bc, name, dns_rdatatype_aaaa, flags, now);
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ ISC_LOOP_TEST_IMPL(getoriginnode) {
|
|||
dns_dbnode_t *node = NULL;
|
||||
isc_result_t result;
|
||||
|
||||
result = dns_db_create(mctx, ZONEDB_DEFAULT, dns_rootname,
|
||||
result = dns_db_create(isc_g_mctx, ZONEDB_DEFAULT, dns_rootname,
|
||||
dns_dbtype_zone, dns_rdataclass_in, 0, NULL,
|
||||
&db);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
|
@ -70,7 +70,7 @@ ISC_LOOP_TEST_IMPL(getsetservestalettl) {
|
|||
isc_result_t result;
|
||||
dns_ttl_t ttl;
|
||||
|
||||
result = dns_db_create(mctx, CACHEDB_DEFAULT, dns_rootname,
|
||||
result = dns_db_create(isc_g_mctx, CACHEDB_DEFAULT, dns_rootname,
|
||||
dns_dbtype_cache, dns_rdataclass_in, 0, NULL,
|
||||
&db);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
|
@ -108,7 +108,7 @@ ISC_LOOP_TEST_IMPL(dns_dbfind_staleok) {
|
|||
isc_result_t result;
|
||||
unsigned char data[] = { 0x0a, 0x00, 0x00, 0x01 };
|
||||
|
||||
result = dns_db_create(mctx, CACHEDB_DEFAULT, dns_rootname,
|
||||
result = dns_db_create(isc_g_mctx, CACHEDB_DEFAULT, dns_rootname,
|
||||
dns_dbtype_cache, dns_rdataclass_in, 0, NULL,
|
||||
&db);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
|
@ -247,7 +247,7 @@ ISC_LOOP_TEST_IMPL(class) {
|
|||
isc_result_t result;
|
||||
dns_db_t *db = NULL;
|
||||
|
||||
result = dns_db_create(mctx, ZONEDB_DEFAULT, dns_rootname,
|
||||
result = dns_db_create(isc_g_mctx, ZONEDB_DEFAULT, dns_rootname,
|
||||
dns_dbtype_zone, dns_rdataclass_in, 0, NULL,
|
||||
&db);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
|
@ -268,7 +268,7 @@ ISC_LOOP_TEST_IMPL(dbtype) {
|
|||
dns_db_t *db = NULL;
|
||||
|
||||
/* DB has zone semantics */
|
||||
result = dns_db_create(mctx, ZONEDB_DEFAULT, dns_rootname,
|
||||
result = dns_db_create(isc_g_mctx, ZONEDB_DEFAULT, dns_rootname,
|
||||
dns_dbtype_zone, dns_rdataclass_in, 0, NULL,
|
||||
&db);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
|
@ -280,7 +280,7 @@ ISC_LOOP_TEST_IMPL(dbtype) {
|
|||
dns_db_detach(&db);
|
||||
|
||||
/* DB has cache semantics */
|
||||
result = dns_db_create(mctx, CACHEDB_DEFAULT, dns_rootname,
|
||||
result = dns_db_create(isc_g_mctx, CACHEDB_DEFAULT, dns_rootname,
|
||||
dns_dbtype_cache, dns_rdataclass_in, 0, NULL,
|
||||
&db);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ ISC_RUN_TEST_IMPL(diffx_same) {
|
|||
test_create(TESTS_DIR "/testdata/diff/zone1.data", &olddb,
|
||||
TESTS_DIR "/testdata/diff/zone1.data", &newdb);
|
||||
|
||||
dns_diff_init(mctx, &diff);
|
||||
dns_diff_init(isc_g_mctx, &diff);
|
||||
|
||||
result = dns_db_diffx(&diff, newdb, NULL, olddb, NULL, NULL);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
|
@ -85,7 +85,7 @@ ISC_RUN_TEST_IMPL(diffx_add) {
|
|||
test_create(TESTS_DIR "/testdata/diff/zone1.data", &olddb,
|
||||
TESTS_DIR "/testdata/diff/zone2.data", &newdb);
|
||||
|
||||
dns_diff_init(mctx, &diff);
|
||||
dns_diff_init(isc_g_mctx, &diff);
|
||||
|
||||
result = dns_db_diffx(&diff, newdb, NULL, olddb, NULL, NULL);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
|
@ -114,7 +114,7 @@ ISC_RUN_TEST_IMPL(diffx_remove) {
|
|||
test_create(TESTS_DIR "/testdata/diff/zone1.data", &olddb,
|
||||
TESTS_DIR "/testdata/diff/zone3.data", &newdb);
|
||||
|
||||
dns_diff_init(mctx, &diff);
|
||||
dns_diff_init(isc_g_mctx, &diff);
|
||||
|
||||
result = dns_db_diffx(&diff, newdb, NULL, olddb, NULL, NULL);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
|
|
|||
|
|
@ -80,14 +80,14 @@ setup_test(void **state) {
|
|||
|
||||
isc_assertion_setcallback(local_callback);
|
||||
|
||||
res = dns_db_create(mctx, ZONEDB_DEFAULT, dns_rootname, dns_dbtype_zone,
|
||||
dns_rdataclass_in, 0, NULL, &db1);
|
||||
res = dns_db_create(isc_g_mctx, ZONEDB_DEFAULT, dns_rootname,
|
||||
dns_dbtype_zone, dns_rdataclass_in, 0, NULL, &db1);
|
||||
assert_int_equal(res, ISC_R_SUCCESS);
|
||||
dns_db_newversion(db1, &v1);
|
||||
assert_non_null(v1);
|
||||
|
||||
res = dns_db_create(mctx, ZONEDB_DEFAULT, dns_rootname, dns_dbtype_zone,
|
||||
dns_rdataclass_in, 0, NULL, &db2);
|
||||
res = dns_db_create(isc_g_mctx, ZONEDB_DEFAULT, dns_rootname,
|
||||
dns_dbtype_zone, dns_rdataclass_in, 0, NULL, &db2);
|
||||
assert_int_equal(res, ISC_R_SUCCESS);
|
||||
dns_db_newversion(db2, &v2);
|
||||
assert_non_null(v1);
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ prepare_rdata(dns_rdata_t *rdata, unsigned char *dest, size_t dest_size) {
|
|||
|
||||
ISC_RUN_TEST_IMPL(dns_diff_size) {
|
||||
dns_diff_t diff;
|
||||
dns_diff_init(mctx, &diff);
|
||||
dns_diff_init(isc_g_mctx, &diff);
|
||||
|
||||
assert_true(dns_diff_size(&diff) == 0);
|
||||
|
||||
|
|
@ -84,18 +84,18 @@ ISC_RUN_TEST_IMPL(dns_diff_size) {
|
|||
}
|
||||
|
||||
dns_difftuple_t *tup_1 = NULL, *tup_2 = NULL, *tup_3 = NULL;
|
||||
dns_difftuple_create(mctx, DNS_DIFFOP_ADD, &name_1, 1, &rdatas[0],
|
||||
dns_difftuple_create(isc_g_mctx, DNS_DIFFOP_ADD, &name_1, 1, &rdatas[0],
|
||||
&tup_1);
|
||||
dns_difftuple_create(mctx, DNS_DIFFOP_DEL, &name_2, 1, &rdatas[1],
|
||||
dns_difftuple_create(isc_g_mctx, DNS_DIFFOP_DEL, &name_2, 1, &rdatas[1],
|
||||
&tup_2);
|
||||
dns_difftuple_create(mctx, DNS_DIFFOP_DEL, &name_3, 1, &rdatas[2],
|
||||
dns_difftuple_create(isc_g_mctx, DNS_DIFFOP_DEL, &name_3, 1, &rdatas[2],
|
||||
&tup_3);
|
||||
|
||||
dns_difftuple_t *tup_dup = NULL, *tup_nodup = NULL;
|
||||
dns_difftuple_create(mctx, DNS_DIFFOP_DEL, &name_dup, 1, &rdatas[3],
|
||||
&tup_dup);
|
||||
dns_difftuple_create(mctx, DNS_DIFFOP_ADD, &name_nodup, 1, &rdatas[4],
|
||||
&tup_nodup);
|
||||
dns_difftuple_create(isc_g_mctx, DNS_DIFFOP_DEL, &name_dup, 1,
|
||||
&rdatas[3], &tup_dup);
|
||||
dns_difftuple_create(isc_g_mctx, DNS_DIFFOP_ADD, &name_nodup, 1,
|
||||
&rdatas[4], &tup_nodup);
|
||||
|
||||
dns_diff_append(&diff, &tup_1);
|
||||
assert_true(dns_diff_size(&diff) == 1);
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ test_dispatch_done(test_dispatch_t *test) {
|
|||
dns_dispatch_done(&test->dispentry);
|
||||
dns_dispatch_detach(&test->dispatch);
|
||||
dns_dispatchmgr_detach(&test->dispatchmgr);
|
||||
isc_mem_put(mctx, test, sizeof(*test));
|
||||
isc_mem_put(isc_g_mctx, test, sizeof(*test));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -156,7 +156,7 @@ setup_test(void **state) {
|
|||
uv_os_sock_t socket = -1;
|
||||
|
||||
/* Create just 1 loop for this test */
|
||||
isc_loopmgr_create(mctx, 1);
|
||||
isc_loopmgr_create(isc_g_mctx, 1);
|
||||
|
||||
setup_netmgr(state);
|
||||
|
||||
|
|
@ -215,7 +215,7 @@ setup_test(void **state) {
|
|||
testdata.region.length = sizeof(testdata.rbuf);
|
||||
memset(testdata.message, 0, sizeof(testdata.message));
|
||||
|
||||
isc_tlsctx_cache_create(mctx, &tls_tlsctx_client_cache);
|
||||
isc_tlsctx_cache_create(isc_g_mctx, &tls_tlsctx_client_cache);
|
||||
|
||||
if (isc_tlsctx_createserver(NULL, NULL, &tls_listen_tlsctx) !=
|
||||
ISC_R_SUCCESS)
|
||||
|
|
@ -230,7 +230,7 @@ setup_test(void **state) {
|
|||
{
|
||||
return -1;
|
||||
}
|
||||
transport_list = dns_transport_list_new(mctx);
|
||||
transport_list = dns_transport_list_new(isc_g_mctx);
|
||||
tls_transport = dns_transport_new(tls_name, DNS_TRANSPORT_TLS,
|
||||
transport_list);
|
||||
dns_transport_set_tlsname(tls_transport, tls_name_str);
|
||||
|
|
@ -263,7 +263,7 @@ make_dispatchset(dns_dispatchmgr_t *dispatchmgr, unsigned int ndisps,
|
|||
return result;
|
||||
}
|
||||
|
||||
result = dns_dispatchset_create(mctx, disp, dsetp, ndisps);
|
||||
result = dns_dispatchset_create(isc_g_mctx, disp, dsetp, ndisps);
|
||||
dns_dispatch_detach(&disp);
|
||||
|
||||
return result;
|
||||
|
|
@ -277,7 +277,7 @@ ISC_LOOP_TEST_IMPL(dispatchset_create) {
|
|||
|
||||
UNUSED(arg);
|
||||
|
||||
result = dns_dispatchmgr_create(mctx, &dispatchmgr);
|
||||
result = dns_dispatchmgr_create(isc_g_mctx, &dispatchmgr);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
result = make_dispatchset(dispatchmgr, 1, &dset);
|
||||
|
|
@ -303,7 +303,7 @@ ISC_LOOP_TEST_IMPL(dispatchset_get) {
|
|||
|
||||
UNUSED(arg);
|
||||
|
||||
result = dns_dispatchmgr_create(mctx, &dispatchmgr);
|
||||
result = dns_dispatchmgr_create(isc_g_mctx, &dispatchmgr);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
result = make_dispatchset(dispatchmgr, 1, &dset);
|
||||
|
|
@ -505,7 +505,7 @@ connected_gettcp(isc_result_t eresult ISC_ATTR_UNUSED,
|
|||
|
||||
/* Client 2 */
|
||||
isc_result_t result;
|
||||
test_dispatch_t *test2 = isc_mem_get(mctx, sizeof(*test2));
|
||||
test_dispatch_t *test2 = isc_mem_get(isc_g_mctx, sizeof(*test2));
|
||||
*test2 = (test_dispatch_t){
|
||||
.dispatchmgr = dns_dispatchmgr_ref(test1->dispatchmgr),
|
||||
};
|
||||
|
|
@ -535,7 +535,7 @@ connected_newtcp(isc_result_t eresult ISC_ATTR_UNUSED,
|
|||
|
||||
/* Client - unshared */
|
||||
isc_result_t result;
|
||||
test_dispatch_t *test4 = isc_mem_get(mctx, sizeof(*test4));
|
||||
test_dispatch_t *test4 = isc_mem_get(isc_g_mctx, sizeof(*test4));
|
||||
*test4 = (test_dispatch_t){
|
||||
.dispatchmgr = dns_dispatchmgr_ref(test3->dispatchmgr),
|
||||
};
|
||||
|
|
@ -581,7 +581,7 @@ timeout_connected(isc_result_t eresult, isc_region_t *region ISC_ATTR_UNUSED,
|
|||
|
||||
ISC_LOOP_TEST_IMPL(dispatch_timeout_tcp_connect) {
|
||||
isc_result_t result;
|
||||
test_dispatch_t *test = isc_mem_get(mctx, sizeof(*test));
|
||||
test_dispatch_t *test = isc_mem_get(isc_g_mctx, sizeof(*test));
|
||||
*test = (test_dispatch_t){ 0 };
|
||||
|
||||
/* Client */
|
||||
|
|
@ -591,7 +591,7 @@ ISC_LOOP_TEST_IMPL(dispatch_timeout_tcp_connect) {
|
|||
testdata.region.base = testdata.message;
|
||||
testdata.region.length = sizeof(testdata.message);
|
||||
|
||||
result = dns_dispatchmgr_create(mctx, &test->dispatchmgr);
|
||||
result = dns_dispatchmgr_create(isc_g_mctx, &test->dispatchmgr);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
result = dns_dispatch_createtcp(test->dispatchmgr, &tcp_connect_addr,
|
||||
|
|
@ -623,7 +623,7 @@ stop_listening(void *arg) {
|
|||
|
||||
ISC_LOOP_TEST_IMPL(dispatch_timeout_tcp_response) {
|
||||
isc_result_t result;
|
||||
test_dispatch_t *test = isc_mem_get(mctx, sizeof(*test));
|
||||
test_dispatch_t *test = isc_mem_get(isc_g_mctx, sizeof(*test));
|
||||
*test = (test_dispatch_t){ 0 };
|
||||
|
||||
/* Server */
|
||||
|
|
@ -636,7 +636,7 @@ ISC_LOOP_TEST_IMPL(dispatch_timeout_tcp_response) {
|
|||
isc_loop_teardown(isc_loop_main(), stop_listening, sock);
|
||||
|
||||
/* Client */
|
||||
result = dns_dispatchmgr_create(mctx, &test->dispatchmgr);
|
||||
result = dns_dispatchmgr_create(isc_g_mctx, &test->dispatchmgr);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
result = dns_dispatch_createtcp(test->dispatchmgr, &tcp_connect_addr,
|
||||
|
|
@ -656,7 +656,7 @@ ISC_LOOP_TEST_IMPL(dispatch_timeout_tcp_response) {
|
|||
|
||||
ISC_LOOP_TEST_IMPL(dispatch_tcp_response) {
|
||||
isc_result_t result;
|
||||
test_dispatch_t *test = isc_mem_get(mctx, sizeof(*test));
|
||||
test_dispatch_t *test = isc_mem_get(isc_g_mctx, sizeof(*test));
|
||||
*test = (test_dispatch_t){ 0 };
|
||||
|
||||
/* Server */
|
||||
|
|
@ -671,7 +671,7 @@ ISC_LOOP_TEST_IMPL(dispatch_tcp_response) {
|
|||
testdata.region.base = testdata.message;
|
||||
testdata.region.length = sizeof(testdata.message);
|
||||
|
||||
result = dns_dispatchmgr_create(mctx, &test->dispatchmgr);
|
||||
result = dns_dispatchmgr_create(isc_g_mctx, &test->dispatchmgr);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
result = dns_dispatch_createtcp(test->dispatchmgr, &tcp_connect_addr,
|
||||
|
|
@ -694,7 +694,7 @@ ISC_LOOP_TEST_IMPL(dispatch_tcp_response) {
|
|||
|
||||
ISC_LOOP_TEST_IMPL(dispatch_tls_response) {
|
||||
isc_result_t result;
|
||||
test_dispatch_t *test = isc_mem_get(mctx, sizeof(*test));
|
||||
test_dispatch_t *test = isc_mem_get(isc_g_mctx, sizeof(*test));
|
||||
*test = (test_dispatch_t){ 0 };
|
||||
|
||||
/* Server */
|
||||
|
|
@ -710,7 +710,7 @@ ISC_LOOP_TEST_IMPL(dispatch_tls_response) {
|
|||
testdata.region.base = testdata.message;
|
||||
testdata.region.length = sizeof(testdata.message);
|
||||
|
||||
result = dns_dispatchmgr_create(mctx, &test->dispatchmgr);
|
||||
result = dns_dispatchmgr_create(isc_g_mctx, &test->dispatchmgr);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
result = dns_dispatch_createtcp(test->dispatchmgr, &tls_connect_addr,
|
||||
|
|
@ -733,7 +733,7 @@ ISC_LOOP_TEST_IMPL(dispatch_tls_response) {
|
|||
|
||||
ISC_LOOP_TEST_IMPL(dispatch_timeout_udp_response) {
|
||||
isc_result_t result;
|
||||
test_dispatch_t *test = isc_mem_get(mctx, sizeof(*test));
|
||||
test_dispatch_t *test = isc_mem_get(isc_g_mctx, sizeof(*test));
|
||||
*test = (test_dispatch_t){ 0 };
|
||||
|
||||
/* Server */
|
||||
|
|
@ -745,7 +745,7 @@ ISC_LOOP_TEST_IMPL(dispatch_timeout_udp_response) {
|
|||
isc_loop_teardown(isc_loop_main(), stop_listening, sock);
|
||||
|
||||
/* Client */
|
||||
result = dns_dispatchmgr_create(mctx, &test->dispatchmgr);
|
||||
result = dns_dispatchmgr_create(isc_g_mctx, &test->dispatchmgr);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
result = dns_dispatch_createudp(test->dispatchmgr, &udp_connect_addr,
|
||||
|
|
@ -765,7 +765,7 @@ ISC_LOOP_TEST_IMPL(dispatch_timeout_udp_response) {
|
|||
/* test dispatch getnext */
|
||||
ISC_LOOP_TEST_IMPL(dispatch_getnext) {
|
||||
isc_result_t result;
|
||||
test_dispatch_t *test = isc_mem_get(mctx, sizeof(*test));
|
||||
test_dispatch_t *test = isc_mem_get(isc_g_mctx, sizeof(*test));
|
||||
*test = (test_dispatch_t){ 0 };
|
||||
|
||||
/* Server */
|
||||
|
|
@ -779,7 +779,7 @@ ISC_LOOP_TEST_IMPL(dispatch_getnext) {
|
|||
testdata.region.base = testdata.message;
|
||||
testdata.region.length = sizeof(testdata.message);
|
||||
|
||||
result = dns_dispatchmgr_create(mctx, &test->dispatchmgr);
|
||||
result = dns_dispatchmgr_create(isc_g_mctx, &test->dispatchmgr);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
result = dns_dispatch_createudp(test->dispatchmgr, &udp_connect_addr,
|
||||
|
|
@ -801,7 +801,7 @@ ISC_LOOP_TEST_IMPL(dispatch_getnext) {
|
|||
|
||||
ISC_LOOP_TEST_IMPL(dispatch_gettcp) {
|
||||
isc_result_t result;
|
||||
test_dispatch_t *test = isc_mem_get(mctx, sizeof(*test));
|
||||
test_dispatch_t *test = isc_mem_get(isc_g_mctx, sizeof(*test));
|
||||
*test = (test_dispatch_t){ 0 };
|
||||
|
||||
/* Server */
|
||||
|
|
@ -813,7 +813,7 @@ ISC_LOOP_TEST_IMPL(dispatch_gettcp) {
|
|||
/* ensure we stop listening after the test is done */
|
||||
isc_loop_teardown(isc_loop_main(), stop_listening, sock);
|
||||
|
||||
result = dns_dispatchmgr_create(mctx, &test->dispatchmgr);
|
||||
result = dns_dispatchmgr_create(isc_g_mctx, &test->dispatchmgr);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
/* Client */
|
||||
|
|
@ -834,7 +834,7 @@ ISC_LOOP_TEST_IMPL(dispatch_gettcp) {
|
|||
|
||||
ISC_LOOP_TEST_IMPL(dispatch_newtcp) {
|
||||
isc_result_t result;
|
||||
test_dispatch_t *test = isc_mem_get(mctx, sizeof(*test));
|
||||
test_dispatch_t *test = isc_mem_get(isc_g_mctx, sizeof(*test));
|
||||
*test = (test_dispatch_t){ 0 };
|
||||
|
||||
/* Server */
|
||||
|
|
@ -847,7 +847,7 @@ ISC_LOOP_TEST_IMPL(dispatch_newtcp) {
|
|||
isc_loop_teardown(isc_loop_main(), stop_listening, sock);
|
||||
|
||||
/* Client - unshared */
|
||||
result = dns_dispatchmgr_create(mctx, &test->dispatchmgr);
|
||||
result = dns_dispatchmgr_create(isc_g_mctx, &test->dispatchmgr);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
result = dns_dispatch_createtcp(
|
||||
|
|
|
|||
|
|
@ -88,8 +88,8 @@ ISC_LOOP_TEST_IMPL(dns_dt_create) {
|
|||
assert_non_null(fopt);
|
||||
fstrm_iothr_options_set_num_input_queues(fopt, 1);
|
||||
|
||||
result = dns_dt_create(mctx, dns_dtmode_file, TAPFILE, &fopt, NULL,
|
||||
&dtenv);
|
||||
result = dns_dt_create(isc_g_mctx, dns_dtmode_file, TAPFILE, &fopt,
|
||||
NULL, &dtenv);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
if (dtenv != NULL) {
|
||||
dns_dt_detach(&dtenv);
|
||||
|
|
@ -104,8 +104,8 @@ ISC_LOOP_TEST_IMPL(dns_dt_create) {
|
|||
assert_non_null(fopt);
|
||||
fstrm_iothr_options_set_num_input_queues(fopt, 1);
|
||||
|
||||
result = dns_dt_create(mctx, dns_dtmode_unix, TAPSOCK, &fopt, NULL,
|
||||
&dtenv);
|
||||
result = dns_dt_create(isc_g_mctx, dns_dtmode_unix, TAPSOCK, &fopt,
|
||||
NULL, &dtenv);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
if (dtenv != NULL) {
|
||||
dns_dt_detach(&dtenv);
|
||||
|
|
@ -121,7 +121,7 @@ ISC_LOOP_TEST_IMPL(dns_dt_create) {
|
|||
assert_non_null(fopt);
|
||||
fstrm_iothr_options_set_num_input_queues(fopt, 1);
|
||||
|
||||
result = dns_dt_create(mctx, 33, TAPSOCK, &fopt, NULL, &dtenv);
|
||||
result = dns_dt_create(isc_g_mctx, 33, TAPSOCK, &fopt, NULL, &dtenv);
|
||||
assert_int_equal(result, ISC_R_FAILURE);
|
||||
assert_null(dtenv);
|
||||
if (dtenv != NULL) {
|
||||
|
|
@ -167,8 +167,8 @@ ISC_LOOP_TEST_IMPL(dns_dt_send) {
|
|||
assert_non_null(fopt);
|
||||
fstrm_iothr_options_set_num_input_queues(fopt, 1);
|
||||
|
||||
result = dns_dt_create(mctx, dns_dtmode_file, TAPFILE, &fopt, NULL,
|
||||
&dtenv);
|
||||
result = dns_dt_create(isc_g_mctx, dns_dtmode_file, TAPFILE, &fopt,
|
||||
NULL, &dtenv);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
dns_dt_attach(dtenv, &view->dtenv);
|
||||
|
|
@ -185,7 +185,7 @@ ISC_LOOP_TEST_IMPL(dns_dt_send) {
|
|||
|
||||
memset(&zr, 0, sizeof(zr));
|
||||
isc_buffer_init(&zb, zone, sizeof(zone));
|
||||
dns_compress_init(&cctx, mctx, 0);
|
||||
dns_compress_init(&cctx, isc_g_mctx, 0);
|
||||
dns_compress_setpermitted(&cctx, false);
|
||||
result = dns_name_towire(zname, &cctx, &zb);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
|
@ -264,7 +264,7 @@ ISC_LOOP_TEST_IMPL(dns_dt_send) {
|
|||
dns_dt_detach(&dtenv);
|
||||
dns_view_detach(&view);
|
||||
|
||||
result = dns_dt_open(TAPFILE, dns_dtmode_file, mctx, &handle);
|
||||
result = dns_dt_open(TAPFILE, dns_dtmode_file, isc_g_mctx, &handle);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
while (dns_dt_getframe(handle, &data, &dsize) == ISC_R_SUCCESS) {
|
||||
|
|
@ -276,7 +276,7 @@ ISC_LOOP_TEST_IMPL(dns_dt_send) {
|
|||
r.base = data;
|
||||
r.length = dsize;
|
||||
|
||||
result = dns_dt_parse(mctx, &r, &dtdata);
|
||||
result = dns_dt_parse(isc_g_mctx, &r, &dtdata);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
n++;
|
||||
|
|
@ -309,7 +309,7 @@ ISC_LOOP_TEST_IMPL(dns_dt_totext) {
|
|||
size_t dsize;
|
||||
FILE *fp = NULL;
|
||||
|
||||
result = dns_dt_open(TAPSAVED, dns_dtmode_file, mctx, &handle);
|
||||
result = dns_dt_open(TAPSAVED, dns_dtmode_file, isc_g_mctx, &handle);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
result = isc_stdio_open(TAPTEXT, "r", &fp);
|
||||
|
|
@ -337,13 +337,13 @@ ISC_LOOP_TEST_IMPL(dns_dt_totext) {
|
|||
}
|
||||
|
||||
/* parse dnstap frame */
|
||||
result = dns_dt_parse(mctx, &r, &dtdata);
|
||||
result = dns_dt_parse(isc_g_mctx, &r, &dtdata);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
continue;
|
||||
}
|
||||
|
||||
isc_buffer_allocate(mctx, &b, 2048);
|
||||
isc_buffer_allocate(isc_g_mctx, &b, 2048);
|
||||
assert_non_null(b);
|
||||
if (b == NULL) {
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ sig_fromfile(const char *path, isc_buffer_t *buf) {
|
|||
result = isc_file_getsizefd(fileno(fp), &size);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
data = isc_mem_get(mctx, size + 1);
|
||||
data = isc_mem_get(isc_g_mctx, size + 1);
|
||||
assert_non_null(data);
|
||||
|
||||
len = (size_t)size;
|
||||
|
|
@ -113,7 +113,7 @@ sig_fromfile(const char *path, isc_buffer_t *buf) {
|
|||
result = ISC_R_SUCCESS;
|
||||
|
||||
err:
|
||||
isc_mem_put(mctx, data, size + 1);
|
||||
isc_mem_put(isc_g_mctx, data, size + 1);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ check_sig(const char *datapath, const char *sigpath, const char *keyname,
|
|||
result = isc_file_getsizefd(fileno(fp), &size);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
data = isc_mem_get(mctx, size + 1);
|
||||
data = isc_mem_get(isc_g_mctx, size + 1);
|
||||
assert_non_null(data);
|
||||
|
||||
p = data;
|
||||
|
|
@ -166,7 +166,7 @@ check_sig(const char *datapath, const char *sigpath, const char *keyname,
|
|||
result = dns_name_fromtext(name, &b, dns_rootname, 0);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
result = dst_key_fromfile(name, id, alg, type,
|
||||
TESTS_DIR "/testdata/dst", mctx, &key);
|
||||
TESTS_DIR "/testdata/dst", isc_g_mctx, &key);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
isc_buffer_init(&databuf, data, (unsigned int)size);
|
||||
|
|
@ -187,8 +187,8 @@ check_sig(const char *datapath, const char *sigpath, const char *keyname,
|
|||
*/
|
||||
isc_buffer_remainingregion(&sigbuf, &sigreg);
|
||||
|
||||
result = dst_context_create(key, mctx, DNS_LOGCATEGORY_GENERAL, false,
|
||||
&ctx);
|
||||
result = dst_context_create(key, isc_g_mctx, DNS_LOGCATEGORY_GENERAL,
|
||||
false, &ctx);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
result = dst_context_adddata(ctx, &datareg);
|
||||
|
|
@ -205,8 +205,8 @@ check_sig(const char *datapath, const char *sigpath, const char *keyname,
|
|||
isc_result_t result2;
|
||||
|
||||
dst_context_destroy(&ctx);
|
||||
result2 = dst_context_create(key, mctx, DNS_LOGCATEGORY_GENERAL,
|
||||
false, &ctx);
|
||||
result2 = dst_context_create(
|
||||
key, isc_g_mctx, DNS_LOGCATEGORY_GENERAL, false, &ctx);
|
||||
assert_int_equal(result2, ISC_R_SUCCESS);
|
||||
|
||||
result2 = dst_context_adddata(ctx, &datareg);
|
||||
|
|
@ -231,7 +231,7 @@ check_sig(const char *datapath, const char *sigpath, const char *keyname,
|
|||
fprintf(stderr, "# %s:\n# %s\n", sigpath, hexbuf);
|
||||
}
|
||||
|
||||
isc_mem_put(mctx, data, size + 1);
|
||||
isc_mem_put(isc_g_mctx, data, size + 1);
|
||||
dst_context_destroy(&ctx);
|
||||
dst_key_free(&key);
|
||||
|
||||
|
|
@ -301,7 +301,7 @@ check_cmp(const char *key1_name, dns_keytag_t key1_id, const char *key2_name,
|
|||
result = dns_name_fromtext(name1, &b1, dns_rootname, 0);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
result = dst_key_fromfile(name1, key1_id, alg, type,
|
||||
TESTS_DIR "/comparekeys", mctx, &key1);
|
||||
TESTS_DIR "/comparekeys", isc_g_mctx, &key1);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
/*
|
||||
|
|
@ -313,7 +313,7 @@ check_cmp(const char *key1_name, dns_keytag_t key1_id, const char *key2_name,
|
|||
result = dns_name_fromtext(name2, &b2, dns_rootname, 0);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
result = dst_key_fromfile(name2, key2_id, alg, type,
|
||||
TESTS_DIR "/comparekeys", mctx, &key2);
|
||||
TESTS_DIR "/comparekeys", isc_g_mctx, &key2);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
/*
|
||||
|
|
@ -449,22 +449,22 @@ ISC_RUN_TEST_IMPL(ecdsa_determinism_test) {
|
|||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
result = dst_key_fromfile(name, 19786, DST_ALG_ECDSA256,
|
||||
DST_TYPE_PUBLIC | DST_TYPE_PRIVATE,
|
||||
TESTS_DIR "/comparekeys", mctx, &key);
|
||||
TESTS_DIR "/comparekeys", isc_g_mctx, &key);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
result = dst_key_sigsize(key, &siglen);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
isc_buffer_allocate(mctx, &sigbuf1, siglen);
|
||||
result = dst_context_create(key, mctx, DNS_LOGCATEGORY_GENERAL, true,
|
||||
&ctx);
|
||||
isc_buffer_allocate(isc_g_mctx, &sigbuf1, siglen);
|
||||
result = dst_context_create(key, isc_g_mctx, DNS_LOGCATEGORY_GENERAL,
|
||||
true, &ctx);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
result = dst_context_sign(ctx, sigbuf1);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
dst_context_destroy(&ctx);
|
||||
|
||||
isc_buffer_allocate(mctx, &sigbuf2, siglen);
|
||||
result = dst_context_create(key, mctx, DNS_LOGCATEGORY_GENERAL, true,
|
||||
&ctx);
|
||||
isc_buffer_allocate(isc_g_mctx, &sigbuf2, siglen);
|
||||
result = dst_context_create(key, isc_g_mctx, DNS_LOGCATEGORY_GENERAL,
|
||||
true, &ctx);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
result = dst_context_sign(ctx, sigbuf2);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ dns_ede_test_equals(const ede_test_expected_t *expected, size_t expected_count,
|
|||
ISC_RUN_TEST_IMPL(dns_ede_test_text_max_count) {
|
||||
dns_edectx_t edectx;
|
||||
|
||||
dns_ede_init(mctx, &edectx);
|
||||
dns_ede_init(isc_g_mctx, &edectx);
|
||||
|
||||
const char *txt1 = "foobar";
|
||||
const char *txt2 = "It's been a long time since I rock-and-rolled"
|
||||
|
|
@ -103,7 +103,7 @@ ISC_RUN_TEST_IMPL(dns_ede_test_text_max_count) {
|
|||
ISC_RUN_TEST_IMPL(dns_ede_test_max_count) {
|
||||
dns_edectx_t edectx;
|
||||
|
||||
dns_ede_init(mctx, &edectx);
|
||||
dns_ede_init(isc_g_mctx, &edectx);
|
||||
|
||||
dns_ede_add(&edectx, 1, NULL);
|
||||
dns_ede_add(&edectx, 22, "two");
|
||||
|
|
@ -125,7 +125,7 @@ ISC_RUN_TEST_IMPL(dns_ede_test_max_count) {
|
|||
ISC_RUN_TEST_IMPL(dns_ede_test_duplicates) {
|
||||
dns_edectx_t edectx;
|
||||
|
||||
dns_ede_init(mctx, &edectx);
|
||||
dns_ede_init(isc_g_mctx, &edectx);
|
||||
|
||||
dns_ede_add(&edectx, 1, NULL);
|
||||
dns_ede_add(&edectx, 1, "two");
|
||||
|
|
@ -145,7 +145,7 @@ ISC_RUN_TEST_IMPL(dns_ede_test_duplicates) {
|
|||
ISC_RUN_TEST_IMPL(dns_ede_test_infocode_range) {
|
||||
dns_edectx_t edectx;
|
||||
|
||||
dns_ede_init(mctx, &edectx);
|
||||
dns_ede_init(isc_g_mctx, &edectx);
|
||||
|
||||
dns_ede_add(&edectx, 1, NULL);
|
||||
expect_assert_failure(dns_ede_add(&edectx, 32, NULL));
|
||||
|
|
@ -163,8 +163,8 @@ ISC_RUN_TEST_IMPL(dns_ede_test_copy) {
|
|||
dns_edectx_t edectx2;
|
||||
dns_edectx_t edectx3;
|
||||
|
||||
dns_ede_init(mctx, &edectx1);
|
||||
dns_ede_init(mctx, &edectx2);
|
||||
dns_ede_init(isc_g_mctx, &edectx1);
|
||||
dns_ede_init(isc_g_mctx, &edectx2);
|
||||
|
||||
dns_ede_add(&edectx1, 1, NULL);
|
||||
dns_ede_add(&edectx1, 2, "two-the-first");
|
||||
|
|
@ -195,7 +195,7 @@ ISC_RUN_TEST_IMPL(dns_ede_test_copy) {
|
|||
dns_ede_test_equals(expected2, 3, &edectx2);
|
||||
dns_ede_test_equals(expected, 3, &edectx1);
|
||||
|
||||
dns_ede_init(mctx, &edectx3);
|
||||
dns_ede_init(isc_g_mctx, &edectx3);
|
||||
dns_ede_add(&edectx3, 2, "two-the-third");
|
||||
dns_ede_copy(&edectx3, &edectx2);
|
||||
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ create_keystruct(uint16_t flags, uint8_t proto, uint8_t alg, const char *keystr,
|
|||
|
||||
keystruct->common.rdclass = rdclass;
|
||||
keystruct->common.rdtype = dns_rdatatype_dnskey;
|
||||
keystruct->mctx = mctx;
|
||||
keystruct->mctx = isc_g_mctx;
|
||||
keystruct->flags = flags;
|
||||
keystruct->protocol = proto;
|
||||
keystruct->algorithm = alg;
|
||||
|
|
@ -125,7 +125,7 @@ create_keystruct(uint16_t flags, uint8_t proto, uint8_t alg, const char *keystr,
|
|||
ISC_R_SUCCESS);
|
||||
isc_buffer_usedregion(&keydatabuf, &r);
|
||||
keystruct->datalen = r.length;
|
||||
keystruct->data = isc_mem_allocate(mctx, r.length);
|
||||
keystruct->data = isc_mem_allocate(isc_g_mctx, r.length);
|
||||
memmove(keystruct->data, r.base, r.length);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ test_master(const char *workdir, const char *testfile,
|
|||
|
||||
result = dns_master_loadfile(testfile, dns_origin, dns_origin,
|
||||
dns_rdataclass_in, true, 0, &callbacks,
|
||||
NULL, NULL, mctx, format, 0);
|
||||
NULL, NULL, isc_g_mctx, format, 0);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
@ -159,7 +159,7 @@ test_master(const char *workdir, const char *testfile,
|
|||
static void
|
||||
include_callback(const char *filename, void *arg) {
|
||||
char **argp = (char **)arg;
|
||||
*argp = isc_mem_strdup(mctx, filename);
|
||||
*argp = isc_mem_strdup(isc_g_mctx, filename);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -327,12 +327,13 @@ ISC_RUN_TEST_IMPL(master_includelist) {
|
|||
result = dns_master_loadfile(TESTS_DIR "/testdata/master/master8.data",
|
||||
dns_origin, dns_origin, dns_rdataclass_in,
|
||||
0, true, &callbacks, include_callback,
|
||||
&filename, mctx, dns_masterformat_text, 0);
|
||||
&filename, isc_g_mctx,
|
||||
dns_masterformat_text, 0);
|
||||
assert_int_equal(result, DNS_R_SEENINCLUDE);
|
||||
assert_non_null(filename);
|
||||
if (filename != NULL) {
|
||||
assert_string_equal(filename, "testdata/master/master6.data");
|
||||
isc_mem_free(mctx, filename);
|
||||
isc_mem_free(isc_g_mctx, filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -458,7 +459,7 @@ ISC_RUN_TEST_IMPL(dumpraw) {
|
|||
result = setup_master(nullmsg, nullmsg);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
result = dns_db_create(mctx, ZONEDB_DEFAULT, dns_origin,
|
||||
result = dns_db_create(isc_g_mctx, ZONEDB_DEFAULT, dns_origin,
|
||||
dns_dbtype_zone, dns_rdataclass_in, 0, NULL,
|
||||
&db);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
|
@ -475,8 +476,9 @@ ISC_RUN_TEST_IMPL(dumpraw) {
|
|||
|
||||
dns_db_currentversion(db, &version);
|
||||
|
||||
result = dns_master_dump(mctx, db, version, &dns_master_style_default,
|
||||
"test.dump", dns_masterformat_raw, NULL);
|
||||
result = dns_master_dump(isc_g_mctx, db, version,
|
||||
&dns_master_style_default, "test.dump",
|
||||
dns_masterformat_raw, NULL);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
result = test_master(NULL, "test.dump", dns_masterformat_raw, nullmsg,
|
||||
|
|
@ -490,8 +492,9 @@ ISC_RUN_TEST_IMPL(dumpraw) {
|
|||
header.flags |= DNS_MASTERRAW_SOURCESERIALSET;
|
||||
|
||||
unlink("test.dump");
|
||||
result = dns_master_dump(mctx, db, version, &dns_master_style_default,
|
||||
"test.dump", dns_masterformat_raw, &header);
|
||||
result = dns_master_dump(isc_g_mctx, db, version,
|
||||
&dns_master_style_default, "test.dump",
|
||||
dns_masterformat_raw, &header);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
result = test_master(NULL, "test.dump", dns_masterformat_raw, nullmsg,
|
||||
|
|
|
|||
|
|
@ -270,7 +270,7 @@ ISC_RUN_TEST_IMPL(compression) {
|
|||
|
||||
/* Test 1: off, rdata */
|
||||
permitted = false;
|
||||
dns_compress_init(&cctx, mctx, 0);
|
||||
dns_compress_init(&cctx, isc_g_mctx, 0);
|
||||
dns_compress_setpermitted(&cctx, permitted);
|
||||
dctx = dns_decompress_setpermitted(DNS_DECOMPRESS_DEFAULT, permitted);
|
||||
|
||||
|
|
@ -282,7 +282,7 @@ ISC_RUN_TEST_IMPL(compression) {
|
|||
|
||||
/* Test2: on, rdata */
|
||||
permitted = true;
|
||||
dns_compress_init(&cctx, mctx, 0);
|
||||
dns_compress_init(&cctx, isc_g_mctx, 0);
|
||||
dns_compress_setpermitted(&cctx, permitted);
|
||||
dctx = dns_decompress_setpermitted(DNS_DECOMPRESS_DEFAULT, permitted);
|
||||
|
||||
|
|
@ -294,7 +294,7 @@ ISC_RUN_TEST_IMPL(compression) {
|
|||
|
||||
/* Test3: off, disabled, rdata */
|
||||
permitted = false;
|
||||
dns_compress_init(&cctx, mctx, DNS_COMPRESS_DISABLED);
|
||||
dns_compress_init(&cctx, isc_g_mctx, DNS_COMPRESS_DISABLED);
|
||||
dns_compress_setpermitted(&cctx, permitted);
|
||||
dctx = dns_decompress_setpermitted(DNS_DECOMPRESS_DEFAULT, permitted);
|
||||
|
||||
|
|
@ -306,7 +306,7 @@ ISC_RUN_TEST_IMPL(compression) {
|
|||
|
||||
/* Test4: on, disabled, rdata */
|
||||
permitted = true;
|
||||
dns_compress_init(&cctx, mctx, DNS_COMPRESS_DISABLED);
|
||||
dns_compress_init(&cctx, isc_g_mctx, DNS_COMPRESS_DISABLED);
|
||||
dns_compress_setpermitted(&cctx, permitted);
|
||||
dctx = dns_decompress_setpermitted(DNS_DECOMPRESS_DEFAULT, permitted);
|
||||
|
||||
|
|
@ -318,7 +318,7 @@ ISC_RUN_TEST_IMPL(compression) {
|
|||
|
||||
/* Test5: on, rdata */
|
||||
permitted = true;
|
||||
dns_compress_init(&cctx, mctx, 0);
|
||||
dns_compress_init(&cctx, isc_g_mctx, 0);
|
||||
dns_compress_setpermitted(&cctx, permitted);
|
||||
dctx = dns_decompress_setpermitted(DNS_DECOMPRESS_DEFAULT, permitted);
|
||||
|
||||
|
|
@ -331,7 +331,7 @@ ISC_RUN_TEST_IMPL(compression) {
|
|||
|
||||
/* Test 6: off, owner */
|
||||
permitted = false;
|
||||
dns_compress_init(&cctx, mctx, 0);
|
||||
dns_compress_init(&cctx, isc_g_mctx, 0);
|
||||
dns_compress_setpermitted(&cctx, permitted);
|
||||
dctx = dns_decompress_setpermitted(DNS_DECOMPRESS_DEFAULT, permitted);
|
||||
|
||||
|
|
@ -343,7 +343,7 @@ ISC_RUN_TEST_IMPL(compression) {
|
|||
|
||||
/* Test7: on, owner */
|
||||
permitted = true;
|
||||
dns_compress_init(&cctx, mctx, 0);
|
||||
dns_compress_init(&cctx, isc_g_mctx, 0);
|
||||
dns_compress_setpermitted(&cctx, permitted);
|
||||
dctx = dns_decompress_setpermitted(DNS_DECOMPRESS_DEFAULT, permitted);
|
||||
|
||||
|
|
@ -355,7 +355,7 @@ ISC_RUN_TEST_IMPL(compression) {
|
|||
|
||||
/* Test8: off, disabled, owner */
|
||||
permitted = false;
|
||||
dns_compress_init(&cctx, mctx, DNS_COMPRESS_DISABLED);
|
||||
dns_compress_init(&cctx, isc_g_mctx, DNS_COMPRESS_DISABLED);
|
||||
dns_compress_setpermitted(&cctx, permitted);
|
||||
dctx = dns_decompress_setpermitted(DNS_DECOMPRESS_DEFAULT, permitted);
|
||||
|
||||
|
|
@ -367,7 +367,7 @@ ISC_RUN_TEST_IMPL(compression) {
|
|||
|
||||
/* Test9: on, disabled, owner */
|
||||
permitted = true;
|
||||
dns_compress_init(&cctx, mctx, DNS_COMPRESS_DISABLED);
|
||||
dns_compress_init(&cctx, isc_g_mctx, DNS_COMPRESS_DISABLED);
|
||||
dns_compress_setpermitted(&cctx, permitted);
|
||||
dctx = dns_decompress_setpermitted(DNS_DECOMPRESS_DEFAULT, permitted);
|
||||
|
||||
|
|
@ -380,7 +380,7 @@ ISC_RUN_TEST_IMPL(compression) {
|
|||
|
||||
/* Test10: on, owner */
|
||||
permitted = true;
|
||||
dns_compress_init(&cctx, mctx, 0);
|
||||
dns_compress_init(&cctx, isc_g_mctx, 0);
|
||||
dns_compress_setpermitted(&cctx, permitted);
|
||||
dctx = dns_decompress_setpermitted(DNS_DECOMPRESS_DEFAULT, permitted);
|
||||
|
||||
|
|
@ -407,7 +407,7 @@ ISC_RUN_TEST_IMPL(collision) {
|
|||
dns_name_t name;
|
||||
char namebuf[256];
|
||||
|
||||
dns_compress_init(&cctx, mctx, DNS_COMPRESS_LARGE);
|
||||
dns_compress_init(&cctx, isc_g_mctx, DNS_COMPRESS_LARGE);
|
||||
isc_buffer_init(&message, msgbuf, sizeof(msgbuf));
|
||||
dns_name_init(&name);
|
||||
|
||||
|
|
|
|||
|
|
@ -56,9 +56,12 @@ setup(void **state ISC_ATTR_UNUSED) {
|
|||
dns_fixedname_t fn;
|
||||
dns_name_t *name = dns_fixedname_name(&fn);
|
||||
|
||||
dns_nametree_create(mctx, DNS_NAMETREE_BOOL, "bool test", &booltree);
|
||||
dns_nametree_create(mctx, DNS_NAMETREE_BITS, "bits test", &bitstree);
|
||||
dns_nametree_create(mctx, DNS_NAMETREE_COUNT, "count test", &counttree);
|
||||
dns_nametree_create(isc_g_mctx, DNS_NAMETREE_BOOL, "bool test",
|
||||
&booltree);
|
||||
dns_nametree_create(isc_g_mctx, DNS_NAMETREE_BITS, "bits test",
|
||||
&bitstree);
|
||||
dns_nametree_create(isc_g_mctx, DNS_NAMETREE_COUNT, "count test",
|
||||
&counttree);
|
||||
|
||||
/* Add a positive boolean node */
|
||||
dns_test_namefromstring("example.com.", &fn);
|
||||
|
|
|
|||
|
|
@ -260,7 +260,7 @@ ISC_RUN_TEST_IMPL(qpiter) {
|
|||
void *pval = NULL;
|
||||
isc_result_t result;
|
||||
|
||||
dns_qp_create(mctx, &qpiter_methods, item, &qp);
|
||||
dns_qp_create(isc_g_mctx, &qpiter_methods, item, &qp);
|
||||
for (size_t tests = 0; tests < 1234; tests++) {
|
||||
ival = isc_random_uniform(ITER_ITEMS - 1) + 1;
|
||||
pval = &item[ival];
|
||||
|
|
@ -483,7 +483,7 @@ ISC_RUN_TEST_IMPL(partialmatch) {
|
|||
dns_qp_t *qp = NULL;
|
||||
int i = 0;
|
||||
|
||||
dns_qp_create(mctx, &string_methods, NULL, &qp);
|
||||
dns_qp_create(isc_g_mctx, &string_methods, NULL, &qp);
|
||||
|
||||
/*
|
||||
* Fixed size strings [16] should ensure leaf-compatible alignment.
|
||||
|
|
@ -626,7 +626,7 @@ ISC_RUN_TEST_IMPL(qpchain) {
|
|||
"b.a.", "x.k.c.d.", "" };
|
||||
int i = 0;
|
||||
|
||||
dns_qp_create(mctx, &string_methods, NULL, &qp);
|
||||
dns_qp_create(isc_g_mctx, &string_methods, NULL, &qp);
|
||||
|
||||
while (insert[i][0] != '\0') {
|
||||
insert_name(qp, insert[i], DNS_DBNAMESPACE_NORMAL);
|
||||
|
|
@ -738,7 +738,7 @@ ISC_RUN_TEST_IMPL(qpchain) {
|
|||
|
||||
i = 0;
|
||||
|
||||
dns_qp_create(mctx, &string_methods, NULL, &qp);
|
||||
dns_qp_create(isc_g_mctx, &string_methods, NULL, &qp);
|
||||
|
||||
while (insert2[i][0] != '\0') {
|
||||
insert_name(qp, insert2[i], DNS_DBNAMESPACE_NORMAL);
|
||||
|
|
@ -803,7 +803,7 @@ check_predecessors_withchain(dns_qp_t *qp, struct check_predecessors check[],
|
|||
dns_name_t *expred = dns_fixedname_initname(&fn3);
|
||||
char *predstr = NULL;
|
||||
dns_test_namefromstring(check[i].predecessor, &fn3);
|
||||
result = dns_name_tostring(expred, &predstr, mctx);
|
||||
result = dns_name_tostring(expred, &predstr, isc_g_mctx);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
result = dns_qp_lookup(qp, name, check[i].space, NULL, &it,
|
||||
|
|
@ -839,7 +839,7 @@ check_predecessors_withchain(dns_qp_t *qp, struct check_predecessors check[],
|
|||
}
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
result = dns_name_tostring(pred, &namestr, mctx);
|
||||
result = dns_name_tostring(pred, &namestr, isc_g_mctx);
|
||||
#if 0
|
||||
fprintf(stderr, "... expected predecessor %s %u got %s %u\n",
|
||||
predstr, check[i].pspace, namestr, ival);
|
||||
|
|
@ -851,17 +851,17 @@ check_predecessors_withchain(dns_qp_t *qp, struct check_predecessors check[],
|
|||
#if 0
|
||||
fprintf(stderr, "%d: remaining names after %s:\n", i, namestr);
|
||||
#endif
|
||||
isc_mem_free(mctx, namestr);
|
||||
isc_mem_free(mctx, predstr);
|
||||
isc_mem_free(isc_g_mctx, namestr);
|
||||
isc_mem_free(isc_g_mctx, predstr);
|
||||
|
||||
int j = 0;
|
||||
while (dns_qpiter_next(&it, name, NULL, NULL) == ISC_R_SUCCESS)
|
||||
{
|
||||
#if 0
|
||||
result = dns_name_tostring(name, &namestr, mctx);
|
||||
result = dns_name_tostring(name, &namestr, isc_g_mctx);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
fprintf(stderr, "%s%s", j > 0 ? "->" : "", namestr);
|
||||
isc_mem_free(mctx, namestr);
|
||||
isc_mem_free(isc_g_mctx, namestr);
|
||||
#endif
|
||||
j++;
|
||||
}
|
||||
|
|
@ -893,7 +893,7 @@ ISC_RUN_TEST_IMPL(predecessors) {
|
|||
};
|
||||
int i = 0;
|
||||
|
||||
dns_qp_create(mctx, &string_methods, NULL, &qp);
|
||||
dns_qp_create(isc_g_mctx, &string_methods, NULL, &qp);
|
||||
while (insert[i][0] != '\0') {
|
||||
insert_name(qp, insert[i], DNS_DBNAMESPACE_NORMAL);
|
||||
insert_name(qp, insert[i], DNS_DBNAMESPACE_NSEC);
|
||||
|
|
@ -1412,7 +1412,7 @@ ISC_RUN_TEST_IMPL(fixiterator) {
|
|||
"" };
|
||||
int i = 0;
|
||||
|
||||
dns_qp_create(mctx, &string_methods, NULL, &qp);
|
||||
dns_qp_create(isc_g_mctx, &string_methods, NULL, &qp);
|
||||
while (insert1[i][0] != '\0') {
|
||||
insert_name(qp, insert1[i], DNS_DBNAMESPACE_NORMAL);
|
||||
insert_name(qp, insert1[i], DNS_DBNAMESPACE_NSEC);
|
||||
|
|
@ -1479,7 +1479,7 @@ ISC_RUN_TEST_IMPL(fixiterator) {
|
|||
const char insert2[][64] = { ".", "abb.", "abc.", "" };
|
||||
i = 0;
|
||||
|
||||
dns_qp_create(mctx, &string_methods, NULL, &qp);
|
||||
dns_qp_create(isc_g_mctx, &string_methods, NULL, &qp);
|
||||
while (insert2[i][0] != '\0') {
|
||||
insert_name(qp, insert2[i], DNS_DBNAMESPACE_NORMAL);
|
||||
insert_name(qp, insert2[i], DNS_DBNAMESPACE_NSEC);
|
||||
|
|
@ -1530,7 +1530,7 @@ ISC_RUN_TEST_IMPL(fixiterator) {
|
|||
"" };
|
||||
i = 0;
|
||||
|
||||
dns_qp_create(mctx, &string_methods, NULL, &qp);
|
||||
dns_qp_create(isc_g_mctx, &string_methods, NULL, &qp);
|
||||
while (insert3[i][0] != '\0') {
|
||||
insert_name(qp, insert3[i], DNS_DBNAMESPACE_NORMAL);
|
||||
insert_name(qp, insert3[i], DNS_DBNAMESPACE_NSEC);
|
||||
|
|
@ -1558,7 +1558,7 @@ ISC_RUN_TEST_IMPL(fixiterator) {
|
|||
"\\000\\009.", "" };
|
||||
i = 0;
|
||||
|
||||
dns_qp_create(mctx, &string_methods, NULL, &qp);
|
||||
dns_qp_create(isc_g_mctx, &string_methods, NULL, &qp);
|
||||
while (insert4[i][0] != '\0') {
|
||||
insert_name(qp, insert4[i], DNS_DBNAMESPACE_NORMAL);
|
||||
insert_name(qp, insert4[i], DNS_DBNAMESPACE_NSEC);
|
||||
|
|
@ -1682,7 +1682,7 @@ ISC_RUN_TEST_IMPL(qpkey_delete) {
|
|||
* NSEC3: c.d.
|
||||
*/
|
||||
|
||||
dns_qp_create(mctx, &string_methods, NULL, &qp);
|
||||
dns_qp_create(isc_g_mctx, &string_methods, NULL, &qp);
|
||||
|
||||
while (insert1[i].name[0] != '\0') {
|
||||
insert_name(qp, insert1[i].name, insert1[i].space);
|
||||
|
|
|
|||
|
|
@ -128,18 +128,18 @@ ISC_LOOP_TEST_IMPL(overmempurge_bigrdata) {
|
|||
size_t lowater = maxcache - (maxcache >> 2); /* ditto */
|
||||
isc_result_t result;
|
||||
dns_db_t *db = NULL;
|
||||
isc_mem_t *mctx2 = NULL;
|
||||
isc_mem_t *mctx = NULL;
|
||||
isc_stdtime_t now = isc_stdtime_now();
|
||||
size_t i;
|
||||
|
||||
isc_mem_create("test", &mctx2);
|
||||
isc_mem_create("test", &mctx);
|
||||
|
||||
result = dns_db_create(mctx2, CACHEDB_DEFAULT, dns_rootname,
|
||||
result = dns_db_create(mctx, CACHEDB_DEFAULT, dns_rootname,
|
||||
dns_dbtype_cache, dns_rdataclass_in, 0, NULL,
|
||||
&db);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
isc_mem_setwater(mctx2, hiwater, lowater);
|
||||
isc_mem_setwater(mctx, hiwater, lowater);
|
||||
|
||||
/*
|
||||
* Add cache entries with minimum size of data until 'overmem'
|
||||
|
|
@ -147,10 +147,10 @@ ISC_LOOP_TEST_IMPL(overmempurge_bigrdata) {
|
|||
* This should eventually happen, but we also limit the number of
|
||||
* iteration to avoid an infinite loop in case something gets wrong.
|
||||
*/
|
||||
for (i = 0; !isc_mem_isovermem(mctx2) && i < (maxcache / 10); i++) {
|
||||
for (i = 0; !isc_mem_isovermem(mctx) && i < (maxcache / 10); i++) {
|
||||
overmempurge_addrdataset(db, now, i, 50053, 0, false);
|
||||
}
|
||||
assert_true(isc_mem_isovermem(mctx2));
|
||||
assert_true(isc_mem_isovermem(mctx));
|
||||
|
||||
/*
|
||||
* Then try to add the same number of entries, each has very large data.
|
||||
|
|
@ -163,13 +163,13 @@ ISC_LOOP_TEST_IMPL(overmempurge_bigrdata) {
|
|||
cleanup_all_deadnodes(db);
|
||||
if (verbose) {
|
||||
print_message("# inuse: %zd max: %zd\n",
|
||||
isc_mem_inuse(mctx2), maxcache);
|
||||
isc_mem_inuse(mctx), maxcache);
|
||||
}
|
||||
assert_true(isc_mem_inuse(mctx2) < maxcache);
|
||||
assert_true(isc_mem_inuse(mctx) < maxcache);
|
||||
}
|
||||
|
||||
dns_db_detach(&db);
|
||||
isc_mem_detach(&mctx2);
|
||||
isc_mem_detach(&mctx);
|
||||
isc_loopmgr_shutdown();
|
||||
}
|
||||
|
||||
|
|
@ -179,18 +179,18 @@ ISC_LOOP_TEST_IMPL(overmempurge_longname) {
|
|||
size_t lowater = maxcache - (maxcache >> 2); /* ditto */
|
||||
isc_result_t result;
|
||||
dns_db_t *db = NULL;
|
||||
isc_mem_t *mctx2 = NULL;
|
||||
isc_mem_t *mctx = NULL;
|
||||
isc_stdtime_t now = isc_stdtime_now();
|
||||
size_t i;
|
||||
|
||||
isc_mem_create("test", &mctx2);
|
||||
isc_mem_create("test", &mctx);
|
||||
|
||||
result = dns_db_create(mctx2, CACHEDB_DEFAULT, dns_rootname,
|
||||
result = dns_db_create(mctx, CACHEDB_DEFAULT, dns_rootname,
|
||||
dns_dbtype_cache, dns_rdataclass_in, 0, NULL,
|
||||
&db);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
isc_mem_setwater(mctx2, hiwater, lowater);
|
||||
isc_mem_setwater(mctx, hiwater, lowater);
|
||||
|
||||
/*
|
||||
* Add cache entries with minimum size of data until 'overmem'
|
||||
|
|
@ -198,10 +198,10 @@ ISC_LOOP_TEST_IMPL(overmempurge_longname) {
|
|||
* This should eventually happen, but we also limit the number of
|
||||
* iteration to avoid an infinite loop in case something gets wrong.
|
||||
*/
|
||||
for (i = 0; !isc_mem_isovermem(mctx2) && i < (maxcache / 10); i++) {
|
||||
for (i = 0; !isc_mem_isovermem(mctx) && i < (maxcache / 10); i++) {
|
||||
overmempurge_addrdataset(db, now, i, 50053, 0, false);
|
||||
}
|
||||
assert_true(isc_mem_isovermem(mctx2));
|
||||
assert_true(isc_mem_isovermem(mctx));
|
||||
|
||||
/*
|
||||
* Then try to add the same number of entries, each has very long name.
|
||||
|
|
@ -214,13 +214,13 @@ ISC_LOOP_TEST_IMPL(overmempurge_longname) {
|
|||
cleanup_all_deadnodes(db);
|
||||
if (verbose) {
|
||||
print_message("# inuse: %zd max: %zd\n",
|
||||
isc_mem_inuse(mctx2), maxcache);
|
||||
isc_mem_inuse(mctx), maxcache);
|
||||
}
|
||||
assert_true(isc_mem_inuse(mctx2) < maxcache);
|
||||
assert_true(isc_mem_inuse(mctx) < maxcache);
|
||||
}
|
||||
|
||||
dns_db_detach(&db);
|
||||
isc_mem_detach(&mctx2);
|
||||
isc_mem_detach(&mctx);
|
||||
isc_loopmgr_shutdown();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ static void
|
|||
setup_items(void) {
|
||||
void *pval = NULL;
|
||||
dns_qp_t *qp = NULL;
|
||||
dns_qp_create(mctx, &test_methods, NULL, &qp);
|
||||
dns_qp_create(isc_g_mctx, &test_methods, NULL, &qp);
|
||||
for (size_t i = 0; i < ARRAY_SIZE(item); i++) {
|
||||
do {
|
||||
size_t len = isc_random_uniform(16) + 4;
|
||||
|
|
@ -355,7 +355,7 @@ many_transactions(void *arg) {
|
|||
UNUSED(arg);
|
||||
|
||||
dns_qpmulti_t *qpm = NULL;
|
||||
dns_qpmulti_create(mctx, &test_methods, NULL, &qpm);
|
||||
dns_qpmulti_create(isc_g_mctx, &test_methods, NULL, &qpm);
|
||||
qpm->writer.write_protect = true;
|
||||
|
||||
for (size_t n = 0; n < TRANSACTION_COUNT; n++) {
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ ownercase_test_one(const char *str1, const char *str2) {
|
|||
qpzonedb_t *qpdb = (qpzonedb_t *)&qpdb_s;
|
||||
*qpdb = (qpzonedb_t){
|
||||
.common.methods = &qpdb_zonemethods,
|
||||
.common.mctx = mctx,
|
||||
.common.mctx = isc_g_mctx,
|
||||
};
|
||||
qpznode_t node = { .locknum = 0 };
|
||||
dns_slabheader_t header = {
|
||||
|
|
@ -170,7 +170,7 @@ ISC_RUN_TEST_IMPL(setownercase) {
|
|||
qpzonedb_t *qpdb = (qpzonedb_t *)&qpdb_s;
|
||||
*qpdb = (qpzonedb_t){
|
||||
.common.methods = &qpdb_zonemethods,
|
||||
.common.mctx = mctx,
|
||||
.common.mctx = isc_g_mctx,
|
||||
};
|
||||
qpznode_t node = { .locknum = 0 };
|
||||
dns_slabheader_t header = {
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ rdata_towire(dns_rdata_t *rdata, unsigned char *dst, size_t dstlen,
|
|||
/*
|
||||
* Try converting input data into uncompressed wire form.
|
||||
*/
|
||||
dns_compress_init(&cctx, mctx, 0);
|
||||
dns_compress_init(&cctx, isc_g_mctx, 0);
|
||||
result = dns_rdata_towire(rdata, &cctx, &target);
|
||||
detect_uncleared_libcrypto_error();
|
||||
dns_compress_invalidate(&cctx);
|
||||
|
|
@ -264,7 +264,7 @@ check_struct_conversions(dns_rdata_t *rdata, size_t structsize,
|
|||
char buf[1024];
|
||||
unsigned int count = 0;
|
||||
|
||||
rdata_struct = isc_mem_allocate(mctx, structsize);
|
||||
rdata_struct = isc_mem_allocate(isc_g_mctx, structsize);
|
||||
assert_non_null(rdata_struct);
|
||||
|
||||
/*
|
||||
|
|
@ -345,7 +345,7 @@ check_struct_conversions(dns_rdata_t *rdata, size_t structsize,
|
|||
}
|
||||
}
|
||||
|
||||
isc_mem_free(mctx, rdata_struct);
|
||||
isc_mem_free(isc_g_mctx, rdata_struct);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ rdatasetstats(void **state ISC_ATTR_UNUSED, bool servestale) {
|
|||
unsigned int from = 0;
|
||||
dns_stats_t *stats = NULL;
|
||||
|
||||
dns_rdatasetstats_create(mctx, &stats);
|
||||
dns_rdatasetstats_create(isc_g_mctx, &stats);
|
||||
|
||||
/* First 255 types. */
|
||||
for (i = 1; i <= 255; i++) {
|
||||
|
|
|
|||
|
|
@ -174,7 +174,7 @@ ISC_RUN_TEST_IMPL(irs_resconf_load) {
|
|||
if (debug) {
|
||||
fprintf(stderr, "# testing '%s'\n", tests[i].file);
|
||||
}
|
||||
result = irs_resconf_load(mctx, tests[i].file, &resconf);
|
||||
result = irs_resconf_load(isc_g_mctx, tests[i].file, &resconf);
|
||||
if (result != tests[i].loadres) {
|
||||
fail_msg("# unexpected result %s loading %s",
|
||||
isc_result_totext(result), tests[i].file);
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ static void
|
|||
mkres(dns_resolver_t **resolverp) {
|
||||
isc_result_t result;
|
||||
|
||||
isc_tlsctx_cache_create(mctx, &tlsctx_cache);
|
||||
isc_tlsctx_cache_create(isc_g_mctx, &tlsctx_cache);
|
||||
result = dns_resolver_create(view, 0, tlsctx_cache, dispatch, NULL,
|
||||
resolverp);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
|
|
|||
|
|
@ -137,15 +137,15 @@ ISC_RUN_TEST_IMPL(isc_rsa_verify) {
|
|||
assert_int_equal(ret, ISC_R_SUCCESS);
|
||||
|
||||
ret = dst_key_fromfile(name, 29238, DST_ALG_RSASHA256, DST_TYPE_PUBLIC,
|
||||
TESTS_DIR, mctx, &key);
|
||||
TESTS_DIR, isc_g_mctx, &key);
|
||||
assert_int_equal(ret, ISC_R_SUCCESS);
|
||||
|
||||
/* RSASHA1 - May not be supported by the OS */
|
||||
if (dst_algorithm_supported(DST_ALG_RSASHA1)) {
|
||||
key->key_alg = DST_ALG_RSASHA1;
|
||||
|
||||
ret = dst_context_create(key, mctx, DNS_LOGCATEGORY_DNSSEC,
|
||||
false, &ctx);
|
||||
ret = dst_context_create(key, isc_g_mctx,
|
||||
DNS_LOGCATEGORY_DNSSEC, false, &ctx);
|
||||
assert_int_equal(ret, ISC_R_SUCCESS);
|
||||
|
||||
r.base = d;
|
||||
|
|
@ -165,7 +165,7 @@ ISC_RUN_TEST_IMPL(isc_rsa_verify) {
|
|||
|
||||
key->key_alg = DST_ALG_RSASHA256;
|
||||
|
||||
ret = dst_context_create(key, mctx, DNS_LOGCATEGORY_DNSSEC, false,
|
||||
ret = dst_context_create(key, isc_g_mctx, DNS_LOGCATEGORY_DNSSEC, false,
|
||||
&ctx);
|
||||
assert_int_equal(ret, ISC_R_SUCCESS);
|
||||
|
||||
|
|
@ -185,7 +185,7 @@ ISC_RUN_TEST_IMPL(isc_rsa_verify) {
|
|||
|
||||
key->key_alg = DST_ALG_RSASHA512;
|
||||
|
||||
ret = dst_context_create(key, mctx, DNS_LOGCATEGORY_DNSSEC, false,
|
||||
ret = dst_context_create(key, isc_g_mctx, DNS_LOGCATEGORY_DNSSEC, false,
|
||||
&ctx);
|
||||
assert_int_equal(ret, ISC_R_SUCCESS);
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ compare_tuples(const zonediff_t *expected, dns_difftuple_t *found,
|
|||
*/
|
||||
expected_name = dns_fixedname_initname(&expected_fname);
|
||||
result = dns_name_fromstring(expected_name, expected->owner,
|
||||
dns_rootname, 0, mctx);
|
||||
dns_rootname, 0, isc_g_mctx);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
dns_name_format(&found->name, found_name, sizeof(found_name));
|
||||
assert_true(dns_name_equal(expected_name, &found->name));
|
||||
|
|
@ -212,7 +212,7 @@ updatesigs_test(const updatesigs_test_params_t *test, dns_zone_t *zone,
|
|||
/*
|
||||
* Initialize the structure dns__zone_updatesigs() will modify.
|
||||
*/
|
||||
dns_diff_init(mctx, &zone_diff);
|
||||
dns_diff_init(isc_g_mctx, &zone_diff);
|
||||
|
||||
/*
|
||||
* Check whether dns__zone_updatesigs() behaves as expected.
|
||||
|
|
@ -284,8 +284,8 @@ ISC_RUN_TEST_IMPL(updatesigs_next) {
|
|||
|
||||
dns_zone_setkeydirectory(zone, TESTS_DIR "/testkeys");
|
||||
|
||||
result = dns_zone_findkeys(zone, db, NULL, now, mctx, DNS_MAXZONEKEYS,
|
||||
zone_keys, &nkeys);
|
||||
result = dns_zone_findkeys(zone, db, NULL, now, isc_g_mctx,
|
||||
DNS_MAXZONEKEYS, zone_keys, &nkeys);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
assert_int_equal(nkeys, 2);
|
||||
|
||||
|
|
|
|||
|
|
@ -109,7 +109,8 @@ static void
|
|||
print_rdata(FILE *fp, dns_rdata_t *rdata) {
|
||||
dns_rdataset_t rrset = DNS_RDATASET_INIT;
|
||||
|
||||
dns_rdatalist_t *rdatalist = isc_mem_get(mctx, sizeof(*rdatalist));
|
||||
dns_rdatalist_t *rdatalist = isc_mem_get(isc_g_mctx,
|
||||
sizeof(*rdatalist));
|
||||
dns_rdatalist_init(rdatalist);
|
||||
rdatalist->rdclass = dns_rdataclass_in;
|
||||
rdatalist->type = rdata->type;
|
||||
|
|
@ -132,7 +133,7 @@ print_rdata(FILE *fp, dns_rdata_t *rdata) {
|
|||
ISC_LIST_FOREACH (rdatalist->rdata, rd, link) {
|
||||
ISC_LIST_UNLINK(rdatalist->rdata, rdata, link);
|
||||
}
|
||||
isc_mem_put(mctx, rdatalist, sizeof(*rdatalist));
|
||||
isc_mem_put(isc_g_mctx, rdatalist, sizeof(*rdatalist));
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -145,7 +146,7 @@ sign_rrset(FILE *fp, isc_stdtime_t inception, isc_stdtime_t expiration,
|
|||
|
||||
isc_buffer_init(&target, target_mem, 1024);
|
||||
ret = dns_dnssec_sign(dname, rrset, ksk->key, &clockskew, &expiration,
|
||||
mctx, &target, rrsig);
|
||||
isc_g_mctx, &target, rrsig);
|
||||
assert_int_equal(ret, ISC_R_SUCCESS);
|
||||
|
||||
print_rdata(fp, rrsig);
|
||||
|
|
@ -165,7 +166,7 @@ write_record(FILE *fp, dns_rdatatype_t rdtype, const char *rdatastr,
|
|||
isc_buffer_add(&source, strlen(rdatastr));
|
||||
|
||||
/* Create a lexer as one is required by dns_rdata_fromtext(). */
|
||||
isc_lex_create(mctx, 64, &lex);
|
||||
isc_lex_create(isc_g_mctx, 64, &lex);
|
||||
specials[0] = 1;
|
||||
specials['('] = 1;
|
||||
specials[')'] = 1;
|
||||
|
|
@ -176,7 +177,7 @@ write_record(FILE *fp, dns_rdatatype_t rdtype, const char *rdatastr,
|
|||
assert_int_equal(ret, ISC_R_SUCCESS);
|
||||
|
||||
ret = dns_rdata_fromtext(rdata, dns_rdataclass_in, rdtype, lex, dname,
|
||||
0, mctx, &target, NULL);
|
||||
0, isc_g_mctx, &target, NULL);
|
||||
assert_int_equal(ret, ISC_R_SUCCESS);
|
||||
|
||||
print_rdata(fp, rdata);
|
||||
|
|
@ -226,8 +227,8 @@ create_bundle(FILE *fp, isc_stdtime_t btime, int bnum) {
|
|||
&test_bundles[bnum].zsk2);
|
||||
}
|
||||
/* Create the DNSKEY signature. */
|
||||
dnskeylist = isc_mem_get(mctx, sizeof(*dnskeylist));
|
||||
dnskeyset = isc_mem_get(mctx, sizeof(*dnskeyset));
|
||||
dnskeylist = isc_mem_get(isc_g_mctx, sizeof(*dnskeylist));
|
||||
dnskeyset = isc_mem_get(isc_g_mctx, sizeof(*dnskeyset));
|
||||
dns_rdatalist_init(dnskeylist);
|
||||
dns_rdataset_init(dnskeyset);
|
||||
dnskeylist->rdclass = dns_rdataclass_in;
|
||||
|
|
@ -242,8 +243,8 @@ create_bundle(FILE *fp, isc_stdtime_t btime, int bnum) {
|
|||
ISC_LIST_FOREACH (dnskeylist->rdata, rd, link) {
|
||||
ISC_LIST_UNLINK(dnskeylist->rdata, rd, link);
|
||||
}
|
||||
isc_mem_put(mctx, dnskeylist, sizeof(*dnskeylist));
|
||||
isc_mem_put(mctx, dnskeyset, sizeof(*dnskeyset));
|
||||
isc_mem_put(isc_g_mctx, dnskeylist, sizeof(*dnskeylist));
|
||||
isc_mem_put(isc_g_mctx, dnskeyset, sizeof(*dnskeyset));
|
||||
|
||||
/* CDNSKEY */
|
||||
dns_rdata_init(&test_bundles[bnum].cdnskey);
|
||||
|
|
@ -251,8 +252,8 @@ create_bundle(FILE *fp, isc_stdtime_t btime, int bnum) {
|
|||
test_bundles[bnum].cdnskeybuf,
|
||||
&test_bundles[bnum].cdnskey);
|
||||
|
||||
cdnskeylist = isc_mem_get(mctx, sizeof(*cdnskeylist));
|
||||
cdnskeyset = isc_mem_get(mctx, sizeof(*cdnskeyset));
|
||||
cdnskeylist = isc_mem_get(isc_g_mctx, sizeof(*cdnskeylist));
|
||||
cdnskeyset = isc_mem_get(isc_g_mctx, sizeof(*cdnskeyset));
|
||||
dns_rdatalist_init(cdnskeylist);
|
||||
dns_rdataset_init(cdnskeyset);
|
||||
cdnskeylist->rdclass = dns_rdataclass_in;
|
||||
|
|
@ -267,16 +268,16 @@ create_bundle(FILE *fp, isc_stdtime_t btime, int bnum) {
|
|||
ISC_LIST_FOREACH (cdnskeylist->rdata, rd, link) {
|
||||
ISC_LIST_UNLINK(cdnskeylist->rdata, rd, link);
|
||||
}
|
||||
isc_mem_put(mctx, cdnskeylist, sizeof(*cdnskeylist));
|
||||
isc_mem_put(mctx, cdnskeyset, sizeof(*cdnskeyset));
|
||||
isc_mem_put(isc_g_mctx, cdnskeylist, sizeof(*cdnskeylist));
|
||||
isc_mem_put(isc_g_mctx, cdnskeyset, sizeof(*cdnskeyset));
|
||||
|
||||
/* CDS */
|
||||
dns_rdata_init(&test_bundles[bnum].cds);
|
||||
write_record(fp, dns_rdatatype_cds, cdsstr, test_bundles[bnum].cdsbuf,
|
||||
&test_bundles[bnum].cds);
|
||||
|
||||
cdslist = isc_mem_get(mctx, sizeof(*cdslist));
|
||||
cdsset = isc_mem_get(mctx, sizeof(*cdsset));
|
||||
cdslist = isc_mem_get(isc_g_mctx, sizeof(*cdslist));
|
||||
cdsset = isc_mem_get(isc_g_mctx, sizeof(*cdsset));
|
||||
dns_rdatalist_init(cdslist);
|
||||
dns_rdataset_init(cdsset);
|
||||
cdslist->rdclass = dns_rdataclass_in;
|
||||
|
|
@ -290,8 +291,8 @@ create_bundle(FILE *fp, isc_stdtime_t btime, int bnum) {
|
|||
ISC_LIST_FOREACH (cdslist->rdata, rd, link) {
|
||||
ISC_LIST_UNLINK(cdslist->rdata, rd, link);
|
||||
}
|
||||
isc_mem_put(mctx, cdslist, sizeof(*cdslist));
|
||||
isc_mem_put(mctx, cdsset, sizeof(*cdsset));
|
||||
isc_mem_put(isc_g_mctx, cdslist, sizeof(*cdslist));
|
||||
isc_mem_put(isc_g_mctx, cdsset, sizeof(*cdsset));
|
||||
|
||||
/* Signature times. */
|
||||
test_bundles[bnum].btime = btime;
|
||||
|
|
@ -405,7 +406,7 @@ create_skr_file(void) {
|
|||
|
||||
/* Set up output file */
|
||||
tempfilelen = strlen(TESTS_DIR "/testdata/skr/") + 20;
|
||||
tempfile = isc_mem_get(mctx, tempfilelen);
|
||||
tempfile = isc_mem_get(isc_g_mctx, tempfilelen);
|
||||
ret = isc_file_mktemplate(testskr, tempfile, tempfilelen);
|
||||
assert_int_equal(ret, ISC_R_SUCCESS);
|
||||
ret = isc_file_openunique(tempfile, &outfp);
|
||||
|
|
@ -425,7 +426,7 @@ create_skr_file(void) {
|
|||
assert_int_equal(ret, ISC_R_SUCCESS);
|
||||
|
||||
isc_file_remove(tempfile);
|
||||
isc_mem_put(mctx, tempfile, tempfilelen);
|
||||
isc_mem_put(isc_g_mctx, tempfile, tempfilelen);
|
||||
}
|
||||
|
||||
ISC_RUN_TEST_IMPL(skr_read) {
|
||||
|
|
@ -445,15 +446,16 @@ ISC_RUN_TEST_IMPL(skr_read) {
|
|||
|
||||
/* Get the KSK */
|
||||
ISC_LIST_INIT(keys);
|
||||
result = dns_dnssec_findmatchingkeys(
|
||||
dname, NULL, TESTS_DIR "/testdata/skr/", NULL, 0, mctx, &keys);
|
||||
result = dns_dnssec_findmatchingkeys(dname, NULL,
|
||||
TESTS_DIR "/testdata/skr/", NULL,
|
||||
0, isc_g_mctx, &keys);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
/* Create/read the SKR file */
|
||||
create_skr_file();
|
||||
dns_skr_create(mctx, testskr, dname, dns_rdataclass_in, &skr);
|
||||
result = dns_skr_read(mctx, testskr, dname, dns_rdataclass_in, TTL,
|
||||
&skr);
|
||||
dns_skr_create(isc_g_mctx, testskr, dname, dns_rdataclass_in, &skr);
|
||||
result = dns_skr_read(isc_g_mctx, testskr, dname, dns_rdataclass_in,
|
||||
TTL, &skr);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
isc_file_remove(testskr);
|
||||
|
|
@ -482,7 +484,7 @@ ISC_RUN_TEST_IMPL(skr_read) {
|
|||
dns_dnsseckey_t *key = ISC_LIST_HEAD(keys);
|
||||
ISC_LIST_UNLINK(keys, key, link);
|
||||
dst_key_free(&key->key);
|
||||
dns_dnsseckey_destroy(mctx, &key);
|
||||
dns_dnsseckey_destroy(isc_g_mctx, &key);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ ISC_RUN_TEST_IMPL(dns_transport_totext) {
|
|||
dns_transport_t *tls = NULL, *http = NULL;
|
||||
dns_transport_list_t *tlist = NULL;
|
||||
|
||||
tlist = dns_transport_list_new(mctx);
|
||||
tlist = dns_transport_list_new(isc_g_mctx);
|
||||
udp = dns_transport_new(dns_rootname, DNS_TRANSPORT_UDP, tlist);
|
||||
tcp = dns_transport_new(dns_rootname, DNS_TRANSPORT_TCP, tlist);
|
||||
tls = dns_transport_new(dns_rootname, DNS_TRANSPORT_TLS, tlist);
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ add_tsig(dst_context_t *tsigctx, dns_tsigkey_t *key, isc_buffer_t *target,
|
|||
|
||||
memset(&tsig, 0, sizeof(tsig));
|
||||
|
||||
dns_compress_init(&cctx, mctx, 0);
|
||||
dns_compress_init(&cctx, isc_g_mctx, 0);
|
||||
|
||||
tsig.common.rdclass = dns_rdataclass_any;
|
||||
tsig.common.rdtype = dns_rdatatype_tsig;
|
||||
|
|
@ -111,7 +111,7 @@ add_tsig(dst_context_t *tsigctx, dns_tsigkey_t *key, isc_buffer_t *target,
|
|||
CHECK(dst_context_adddata(tsigctx, &r));
|
||||
|
||||
CHECK(dst_key_sigsize(key->key, &sigsize));
|
||||
tsig.signature = isc_mem_get(mctx, sigsize);
|
||||
tsig.signature = isc_mem_get(isc_g_mctx, sigsize);
|
||||
isc_buffer_init(&sigbuf, tsig.signature, sigsize);
|
||||
CHECK(dst_context_sign(tsigctx, &sigbuf));
|
||||
tsig.siglen = isc_buffer_usedlength(&sigbuf);
|
||||
|
|
@ -120,7 +120,7 @@ add_tsig(dst_context_t *tsigctx, dns_tsigkey_t *key, isc_buffer_t *target,
|
|||
isc_random_buf(tsig.signature, tsig.siglen);
|
||||
}
|
||||
|
||||
isc_buffer_allocate(mctx, &dynbuf, 512);
|
||||
isc_buffer_allocate(isc_g_mctx, &dynbuf, 512);
|
||||
CHECK(dns_rdata_fromstruct(&rdata, dns_rdataclass_any,
|
||||
dns_rdatatype_tsig, &tsig, dynbuf));
|
||||
dns_rdatalist_init(&rdatalist);
|
||||
|
|
@ -141,7 +141,7 @@ add_tsig(dst_context_t *tsigctx, dns_tsigkey_t *key, isc_buffer_t *target,
|
|||
}
|
||||
cleanup:
|
||||
if (tsig.signature != NULL) {
|
||||
isc_mem_put(mctx, tsig.signature, sigsize);
|
||||
isc_mem_put(isc_g_mctx, tsig.signature, sigsize);
|
||||
}
|
||||
if (dynbuf != NULL) {
|
||||
isc_buffer_free(&dynbuf);
|
||||
|
|
@ -163,13 +163,13 @@ printmessage(dns_message_t *msg) {
|
|||
}
|
||||
|
||||
do {
|
||||
buf = isc_mem_get(mctx, len);
|
||||
buf = isc_mem_get(isc_g_mctx, len);
|
||||
|
||||
isc_buffer_init(&b, buf, len);
|
||||
result = dns_message_totext(msg, &dns_master_style_debug, 0,
|
||||
&b);
|
||||
if (result == ISC_R_NOSPACE) {
|
||||
isc_mem_put(mctx, buf, len);
|
||||
isc_mem_put(isc_g_mctx, buf, len);
|
||||
len *= 2;
|
||||
} else if (result == ISC_R_SUCCESS) {
|
||||
printf("%.*s\n", (int)isc_buffer_usedlength(&b), buf);
|
||||
|
|
@ -177,7 +177,7 @@ printmessage(dns_message_t *msg) {
|
|||
} while (result == ISC_R_NOSPACE);
|
||||
|
||||
if (buf != NULL) {
|
||||
isc_mem_put(mctx, buf, len);
|
||||
isc_mem_put(isc_g_mctx, buf, len);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -188,7 +188,8 @@ render(isc_buffer_t *buf, unsigned int flags, dns_tsigkey_t *key,
|
|||
dns_compress_t cctx;
|
||||
isc_result_t result;
|
||||
|
||||
dns_message_create(mctx, NULL, NULL, DNS_MESSAGE_INTENTRENDER, &msg);
|
||||
dns_message_create(isc_g_mctx, NULL, NULL, DNS_MESSAGE_INTENTRENDER,
|
||||
&msg);
|
||||
assert_non_null(msg);
|
||||
|
||||
msg->id = 50;
|
||||
|
|
@ -214,7 +215,7 @@ render(isc_buffer_t *buf, unsigned int flags, dns_tsigkey_t *key,
|
|||
dns_message_setquerytsig(msg, *tsigin);
|
||||
}
|
||||
|
||||
dns_compress_init(&cctx, mctx, 0);
|
||||
dns_compress_init(&cctx, isc_g_mctx, 0);
|
||||
|
||||
result = dns_message_renderbegin(msg, &cctx, buf);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
|
@ -233,7 +234,7 @@ render(isc_buffer_t *buf, unsigned int flags, dns_tsigkey_t *key,
|
|||
isc_buffer_free(tsigin);
|
||||
}
|
||||
|
||||
result = dns_message_getquerytsig(msg, mctx, tsigout);
|
||||
result = dns_message_getquerytsig(msg, isc_g_mctx, tsigout);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
|
|
@ -264,11 +265,11 @@ tsig_tcp(isc_stdtime_t now, isc_result_t expected_result, bool mangle_sig) {
|
|||
result = dns_name_fromstring(keyname, "test", dns_rootname, 0, NULL);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
dns_tsigkeyring_create(mctx, &ring);
|
||||
dns_tsigkeyring_create(isc_g_mctx, &ring);
|
||||
assert_non_null(ring);
|
||||
|
||||
result = dns_tsigkey_create(keyname, DST_ALG_HMACSHA256, secret,
|
||||
sizeof(secret), mctx, &key);
|
||||
sizeof(secret), isc_g_mctx, &key);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
result = dns_tsigkeyring_add(ring, key);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
|
@ -277,21 +278,22 @@ tsig_tcp(isc_stdtime_t now, isc_result_t expected_result, bool mangle_sig) {
|
|||
/*
|
||||
* Create request.
|
||||
*/
|
||||
isc_buffer_allocate(mctx, &buf, 65535);
|
||||
isc_buffer_allocate(isc_g_mctx, &buf, 65535);
|
||||
render(buf, 0, key, &tsigout, &querytsig, NULL);
|
||||
isc_buffer_free(&buf);
|
||||
|
||||
/*
|
||||
* Create response message 1.
|
||||
*/
|
||||
isc_buffer_allocate(mctx, &buf, 65535);
|
||||
isc_buffer_allocate(isc_g_mctx, &buf, 65535);
|
||||
render(buf, DNS_MESSAGEFLAG_QR, key, &querytsig, &tsigout, NULL);
|
||||
assert_non_null(tsigout);
|
||||
|
||||
/*
|
||||
* Process response message 1.
|
||||
*/
|
||||
dns_message_create(mctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE, &msg);
|
||||
dns_message_create(isc_g_mctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE,
|
||||
&msg);
|
||||
assert_non_null(msg);
|
||||
|
||||
result = dns_message_settsigkey(msg, key);
|
||||
|
|
@ -314,7 +316,7 @@ tsig_tcp(isc_stdtime_t now, isc_result_t expected_result, bool mangle_sig) {
|
|||
*/
|
||||
assert_non_null(dns_message_gettsig(msg, &tsigowner));
|
||||
|
||||
result = dns_message_getquerytsig(msg, mctx, &tsigin);
|
||||
result = dns_message_getquerytsig(msg, isc_g_mctx, &tsigin);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
tsigctx = msg->tsigctx;
|
||||
|
|
@ -322,8 +324,8 @@ tsig_tcp(isc_stdtime_t now, isc_result_t expected_result, bool mangle_sig) {
|
|||
isc_buffer_free(&buf);
|
||||
dns_message_detach(&msg);
|
||||
|
||||
result = dst_context_create(key->key, mctx, DNS_LOGCATEGORY_DNSSEC,
|
||||
false, &outctx);
|
||||
result = dst_context_create(key->key, isc_g_mctx,
|
||||
DNS_LOGCATEGORY_DNSSEC, false, &outctx);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
assert_non_null(outctx);
|
||||
|
||||
|
|
@ -336,7 +338,7 @@ tsig_tcp(isc_stdtime_t now, isc_result_t expected_result, bool mangle_sig) {
|
|||
/*
|
||||
* Create response message 2.
|
||||
*/
|
||||
isc_buffer_allocate(mctx, &buf, 65535);
|
||||
isc_buffer_allocate(isc_g_mctx, &buf, 65535);
|
||||
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
render(buf, DNS_MESSAGEFLAG_QR, key, &tsigout, &tsigout, outctx);
|
||||
|
|
@ -344,7 +346,8 @@ tsig_tcp(isc_stdtime_t now, isc_result_t expected_result, bool mangle_sig) {
|
|||
/*
|
||||
* Process response message 2.
|
||||
*/
|
||||
dns_message_create(mctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE, &msg);
|
||||
dns_message_create(isc_g_mctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE,
|
||||
&msg);
|
||||
assert_non_null(msg);
|
||||
|
||||
msg->tcp_continuation = 1;
|
||||
|
|
@ -380,7 +383,7 @@ tsig_tcp(isc_stdtime_t now, isc_result_t expected_result, bool mangle_sig) {
|
|||
/*
|
||||
* Create response message 3.
|
||||
*/
|
||||
isc_buffer_allocate(mctx, &buf, 65535);
|
||||
isc_buffer_allocate(isc_g_mctx, &buf, 65535);
|
||||
render(buf, DNS_MESSAGEFLAG_QR, key, &tsigout, &tsigout, outctx);
|
||||
|
||||
result = add_tsig(outctx, key, buf, now, mangle_sig);
|
||||
|
|
@ -389,7 +392,8 @@ tsig_tcp(isc_stdtime_t now, isc_result_t expected_result, bool mangle_sig) {
|
|||
/*
|
||||
* Process response message 3.
|
||||
*/
|
||||
dns_message_create(mctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE, &msg);
|
||||
dns_message_create(isc_g_mctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE,
|
||||
&msg);
|
||||
assert_non_null(msg);
|
||||
|
||||
msg->tcp_continuation = 1;
|
||||
|
|
@ -431,7 +435,7 @@ tsig_tcp(isc_stdtime_t now, isc_result_t expected_result, bool mangle_sig) {
|
|||
isc_buffer_free(&tsigin);
|
||||
}
|
||||
|
||||
result = dns_message_getquerytsig(msg, mctx, &tsigin);
|
||||
result = dns_message_getquerytsig(msg, isc_g_mctx, &tsigin);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
isc_buffer_free(&buf);
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ ISC_LOOP_TEST_IMPL(basic) {
|
|||
isc_sockaddr_fromin6(&src_addrv6, &in6addr_loopback, src_port);
|
||||
isc_sockaddr_fromin6(&dst_addrv6, &in6addr_loopback, dst_port);
|
||||
|
||||
uc = dns_unreachcache_new(mctx, EXPIRE_MIN_S, EXPIRE_MAX_S,
|
||||
uc = dns_unreachcache_new(isc_g_mctx, EXPIRE_MIN_S, EXPIRE_MAX_S,
|
||||
BACKOFF_ELGIBLE_S);
|
||||
dns_unreachcache_add(uc, &dst_addrv4, &src_addrv4);
|
||||
dns_unreachcache_add(uc, &dst_addrv6, &src_addrv6);
|
||||
|
|
@ -110,7 +110,7 @@ ISC_LOOP_TEST_IMPL(expire) {
|
|||
isc_sockaddr_fromin(&src_addrv4, &localhost4, src_port);
|
||||
isc_sockaddr_fromin(&dst_addrv4, &localhost4, dst_port);
|
||||
|
||||
uc = dns_unreachcache_new(mctx, EXPIRE_MIN_S, EXPIRE_MAX_S,
|
||||
uc = dns_unreachcache_new(isc_g_mctx, EXPIRE_MIN_S, EXPIRE_MAX_S,
|
||||
BACKOFF_ELGIBLE_S);
|
||||
/* Two adds to "confirm" the addition. */
|
||||
dns_unreachcache_add(uc, &dst_addrv4, &src_addrv4);
|
||||
|
|
@ -161,7 +161,7 @@ ISC_LOOP_TEST_IMPL(flush) {
|
|||
isc_sockaddr_fromin(&src_addrv4, &localhost4, src_port);
|
||||
isc_sockaddr_fromin(&dst_addrv4, &localhost4, dst_port);
|
||||
|
||||
uc = dns_unreachcache_new(mctx, EXPIRE_MIN_S, EXPIRE_MAX_S,
|
||||
uc = dns_unreachcache_new(isc_g_mctx, EXPIRE_MIN_S, EXPIRE_MAX_S,
|
||||
BACKOFF_ELGIBLE_S);
|
||||
/* Two adds to "confirm" the addition. */
|
||||
dns_unreachcache_add(uc, &dst_addrv4, &src_addrv4);
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ ISC_LOOP_TEST_IMPL(zonemgr_create) {
|
|||
|
||||
UNUSED(arg);
|
||||
|
||||
dns_zonemgr_create(mctx, &myzonemgr);
|
||||
dns_zonemgr_create(isc_g_mctx, &myzonemgr);
|
||||
|
||||
dns_zonemgr_shutdown(myzonemgr);
|
||||
dns_zonemgr_detach(&myzonemgr);
|
||||
|
|
@ -74,7 +74,7 @@ ISC_LOOP_TEST_IMPL(zonemgr_managezone) {
|
|||
|
||||
UNUSED(arg);
|
||||
|
||||
dns_zonemgr_create(mctx, &myzonemgr);
|
||||
dns_zonemgr_create(isc_g_mctx, &myzonemgr);
|
||||
|
||||
result = dns_test_makezone("foo", &zone, NULL, false);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
|
@ -107,7 +107,7 @@ ISC_LOOP_TEST_IMPL(zonemgr_createzone) {
|
|||
|
||||
UNUSED(arg);
|
||||
|
||||
dns_zonemgr_create(mctx, &myzonemgr);
|
||||
dns_zonemgr_create(isc_g_mctx, &myzonemgr);
|
||||
|
||||
result = dns_zonemgr_createzone(myzonemgr, &zone);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@
|
|||
#include <isc/util.h>
|
||||
#include <isc/uv.h>
|
||||
|
||||
extern isc_mem_t *mctx;
|
||||
extern int ncpus;
|
||||
extern unsigned int workers;
|
||||
extern bool debug;
|
||||
|
|
@ -247,7 +246,7 @@ teardown_managers(void **state);
|
|||
r = cmocka_run_group_tests(tests, setup, teardown); \
|
||||
} \
|
||||
\
|
||||
isc_mem_detach(&mctx); \
|
||||
teardown_mctx(NULL); \
|
||||
\
|
||||
return (r); \
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ ISC_RUN_TEST_IMPL(isc_buffer_reserve) {
|
|||
UNUSED(state);
|
||||
|
||||
b = NULL;
|
||||
isc_buffer_allocate(mctx, &b, ISC_BUFFER_INCR);
|
||||
isc_buffer_allocate(isc_g_mctx, &b, ISC_BUFFER_INCR);
|
||||
assert_int_equal(b->length, ISC_BUFFER_INCR);
|
||||
|
||||
/*
|
||||
|
|
@ -105,7 +105,7 @@ ISC_RUN_TEST_IMPL(isc_buffer_dynamic) {
|
|||
UNUSED(state);
|
||||
|
||||
b = NULL;
|
||||
isc_buffer_allocate(mctx, &b, last_length);
|
||||
isc_buffer_allocate(isc_g_mctx, &b, last_length);
|
||||
assert_non_null(b);
|
||||
assert_int_equal(b->length, last_length);
|
||||
|
||||
|
|
@ -151,7 +151,7 @@ ISC_RUN_TEST_IMPL(isc_buffer_copyregion) {
|
|||
|
||||
UNUSED(state);
|
||||
|
||||
isc_buffer_allocate(mctx, &b, sizeof(data));
|
||||
isc_buffer_allocate(isc_g_mctx, &b, sizeof(data));
|
||||
|
||||
/*
|
||||
* Fill originally allocated buffer space.
|
||||
|
|
@ -182,7 +182,7 @@ ISC_RUN_TEST_IMPL(isc_buffer_printf) {
|
|||
* Prepare a buffer with auto-reallocation enabled.
|
||||
*/
|
||||
b = NULL;
|
||||
isc_buffer_allocate(mctx, &b, 0);
|
||||
isc_buffer_allocate(isc_g_mctx, &b, 0);
|
||||
|
||||
/*
|
||||
* Sanity check.
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ ISC_RUN_TEST_IMPL(isc_counter) {
|
|||
isc_result_t result;
|
||||
isc_counter_t *counter = NULL;
|
||||
|
||||
isc_counter_create(mctx, 0, &counter);
|
||||
isc_counter_create(isc_g_mctx, 0, &counter);
|
||||
|
||||
for (size_t i = 0; i < 10; i++) {
|
||||
result = isc_counter_increment(counter);
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@
|
|||
static int
|
||||
setup_test_dnsbuf(void **state) {
|
||||
isc_buffer_t **pdnsbuf = (isc_buffer_t **)state;
|
||||
isc_buffer_allocate(mctx, pdnsbuf, STATIC_BUFFER_SIZE);
|
||||
isc_buffer_allocate(isc_g_mctx, pdnsbuf, STATIC_BUFFER_SIZE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -68,7 +68,7 @@ static int
|
|||
setup_test_dnsasm(void **state) {
|
||||
isc_dnsstream_assembler_t **pdnsasm =
|
||||
(isc_dnsstream_assembler_t **)state;
|
||||
*pdnsasm = isc_dnsstream_assembler_new(mctx, dnsasm_dummy, NULL);
|
||||
*pdnsasm = isc_dnsstream_assembler_new(isc_g_mctx, dnsasm_dummy, NULL);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -382,7 +382,7 @@ ISC_RUN_TEST_IMPL(dnsasm_multiple_messages_test) {
|
|||
size_t verified = 0;
|
||||
|
||||
isc_buffer_init(&dnsbuf, NULL, 0);
|
||||
isc_buffer_setmctx(&dnsbuf, mctx);
|
||||
isc_buffer_setmctx(&dnsbuf, isc_g_mctx);
|
||||
isc_buffer_putmem(&dnsbuf, (void *)request, sizeof(request));
|
||||
isc_buffer_putmem(&dnsbuf, (void *)response, sizeof(response));
|
||||
isc_buffer_putmem(&dnsbuf, (void *)request_large,
|
||||
|
|
@ -464,7 +464,7 @@ ISC_RUN_TEST_IMPL(dnsasm_error_data_test) {
|
|||
uint16_t bad_data = 0;
|
||||
|
||||
isc_buffer_init(&dnsbuf, NULL, 0);
|
||||
isc_buffer_setmctx(&dnsbuf, mctx);
|
||||
isc_buffer_setmctx(&dnsbuf, isc_g_mctx);
|
||||
|
||||
isc_buffer_putmem(&dnsbuf, (void *)request, sizeof(request));
|
||||
isc_buffer_putmem(&dnsbuf, (void *)&bad_data, sizeof(bad_data));
|
||||
|
|
@ -518,7 +518,7 @@ ISC_RUN_TEST_IMPL(dnsasm_torn_randomly_test) {
|
|||
const size_t npackets = sizeof(packets) / sizeof(packets[0]);
|
||||
|
||||
isc_buffer_init(&dnsbuf, NULL, 0);
|
||||
isc_buffer_setmctx(&dnsbuf, mctx);
|
||||
isc_buffer_setmctx(&dnsbuf, isc_g_mctx);
|
||||
|
||||
for (size_t i = 0; i < npackets; i++) {
|
||||
isc_buffer_putmem(&dnsbuf, packets[i].base, packets[i].length);
|
||||
|
|
@ -600,7 +600,7 @@ ISC_RUN_TEST_IMPL(dnsasm_clear_buffer_within_cb_test) {
|
|||
isc_buffer_t dnsbuf;
|
||||
|
||||
isc_buffer_init(&dnsbuf, NULL, 0);
|
||||
isc_buffer_setmctx(&dnsbuf, mctx);
|
||||
isc_buffer_setmctx(&dnsbuf, isc_g_mctx);
|
||||
|
||||
isc_buffer_putmem(&dnsbuf, (void *)request, sizeof(request));
|
||||
isc_buffer_putmem(&dnsbuf, (void *)&response, sizeof(response));
|
||||
|
|
|
|||
|
|
@ -158,7 +158,6 @@ proxy_verify_unspec_endpoint(isc_nmhandle_t *handle) {
|
|||
}
|
||||
|
||||
typedef struct csdata {
|
||||
isc_mem_t *mctx;
|
||||
isc_nm_recv_cb_t reply_cb;
|
||||
void *cb_arg;
|
||||
isc_region_t region;
|
||||
|
|
@ -170,7 +169,7 @@ connect_send_cb(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
|
|||
|
||||
(void)atomic_fetch_sub(&active_cconnects, 1);
|
||||
memmove(&data, arg, sizeof(data));
|
||||
isc_mem_put(data.mctx, arg, sizeof(data));
|
||||
isc_mem_put(isc_g_mctx, arg, sizeof(data));
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto error;
|
||||
}
|
||||
|
|
@ -183,11 +182,11 @@ connect_send_cb(isc_nmhandle_t *handle, isc_result_t result, void *arg) {
|
|||
goto error;
|
||||
}
|
||||
|
||||
isc_mem_putanddetach(&data.mctx, data.region.base, data.region.length);
|
||||
isc_mem_put(isc_g_mctx, data.region.base, data.region.length);
|
||||
return;
|
||||
error:
|
||||
data.reply_cb(handle, result, NULL, data.cb_arg);
|
||||
isc_mem_putanddetach(&data.mctx, data.region.base, data.region.length);
|
||||
isc_mem_put(isc_g_mctx, data.region.base, data.region.length);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -198,12 +197,11 @@ connect_send_request(const char *uri, bool post, isc_region_t *region,
|
|||
csdata_t *data = NULL;
|
||||
isc_tlsctx_t *ctx = NULL;
|
||||
|
||||
copy = (isc_region_t){ .base = isc_mem_get(mctx, region->length),
|
||||
copy = (isc_region_t){ .base = isc_mem_get(isc_g_mctx, region->length),
|
||||
.length = region->length };
|
||||
memmove(copy.base, region->base, region->length);
|
||||
data = isc_mem_get(mctx, sizeof(*data));
|
||||
data = isc_mem_get(isc_g_mctx, sizeof(*data));
|
||||
*data = (csdata_t){ .reply_cb = cb, .cb_arg = cbarg, .region = copy };
|
||||
isc_mem_attach(mctx, &data->mctx);
|
||||
if (tls) {
|
||||
ctx = client_tlsctx;
|
||||
}
|
||||
|
|
@ -350,7 +348,7 @@ setup_test(void **state) {
|
|||
isc_tlsctx_createclient(&client_tlsctx);
|
||||
isc_tlsctx_enable_http2client_alpn(client_tlsctx);
|
||||
isc_tlsctx_client_session_cache_create(
|
||||
mctx, client_tlsctx,
|
||||
isc_g_mctx, client_tlsctx,
|
||||
ISC_TLSCTX_CLIENT_SESSION_CACHE_DEFAULT_SIZE,
|
||||
&client_sess_cache);
|
||||
|
||||
|
|
@ -358,7 +356,7 @@ setup_test(void **state) {
|
|||
atomic_store(&check_listener_quota, false);
|
||||
|
||||
INSIST(endpoints == NULL);
|
||||
endpoints = isc_nm_http_endpoints_new(mctx);
|
||||
endpoints = isc_nm_http_endpoints_new(isc_g_mctx);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1358,90 +1356,91 @@ ISC_RUN_TEST_IMPL(doh_base64url_to_base64) {
|
|||
char test[] = "YW55IGNhcm5hbCBwbGVhc3VyZS4";
|
||||
char res_test[] = "YW55IGNhcm5hbCBwbGVhc3VyZS4=";
|
||||
|
||||
res = isc__nm_base64url_to_base64(mctx, test, strlen(test),
|
||||
&res_len);
|
||||
res = isc__nm_base64url_to_base64(isc_g_mctx, test,
|
||||
strlen(test), &res_len);
|
||||
assert_non_null(res);
|
||||
assert_true(res_len == strlen(res_test));
|
||||
assert_true(strcmp(res, res_test) == 0);
|
||||
isc_mem_free(mctx, res);
|
||||
isc_mem_free(isc_g_mctx, res);
|
||||
}
|
||||
/* valid */
|
||||
{
|
||||
char test[] = "YW55IGNhcm5hbCBwbGVhcw";
|
||||
char res_test[] = "YW55IGNhcm5hbCBwbGVhcw==";
|
||||
|
||||
res = isc__nm_base64url_to_base64(mctx, test, strlen(test),
|
||||
&res_len);
|
||||
res = isc__nm_base64url_to_base64(isc_g_mctx, test,
|
||||
strlen(test), &res_len);
|
||||
assert_non_null(res);
|
||||
assert_true(res_len == strlen(res_test));
|
||||
assert_true(strcmp(res, res_test) == 0);
|
||||
isc_mem_free(mctx, res);
|
||||
isc_mem_free(isc_g_mctx, res);
|
||||
}
|
||||
/* valid */
|
||||
{
|
||||
char test[] = "YW55IGNhcm5hbCBwbGVhc3Vy";
|
||||
char res_test[] = "YW55IGNhcm5hbCBwbGVhc3Vy";
|
||||
|
||||
res = isc__nm_base64url_to_base64(mctx, test, strlen(test),
|
||||
&res_len);
|
||||
res = isc__nm_base64url_to_base64(isc_g_mctx, test,
|
||||
strlen(test), &res_len);
|
||||
assert_non_null(res);
|
||||
assert_true(res_len == strlen(res_test));
|
||||
assert_true(strcmp(res, res_test) == 0);
|
||||
isc_mem_free(mctx, res);
|
||||
isc_mem_free(isc_g_mctx, res);
|
||||
}
|
||||
/* valid */
|
||||
{
|
||||
char test[] = "YW55IGNhcm5hbCBwbGVhc3U";
|
||||
char res_test[] = "YW55IGNhcm5hbCBwbGVhc3U=";
|
||||
|
||||
res = isc__nm_base64url_to_base64(mctx, test, strlen(test),
|
||||
&res_len);
|
||||
res = isc__nm_base64url_to_base64(isc_g_mctx, test,
|
||||
strlen(test), &res_len);
|
||||
assert_non_null(res);
|
||||
assert_true(res_len == strlen(res_test));
|
||||
assert_true(strcmp(res, res_test) == 0);
|
||||
isc_mem_free(mctx, res);
|
||||
isc_mem_free(isc_g_mctx, res);
|
||||
}
|
||||
/* valid */
|
||||
{
|
||||
char test[] = "YW55IGNhcm5hbCBwbGVhcw";
|
||||
char res_test[] = "YW55IGNhcm5hbCBwbGVhcw==";
|
||||
|
||||
res = isc__nm_base64url_to_base64(mctx, test, strlen(test),
|
||||
&res_len);
|
||||
res = isc__nm_base64url_to_base64(isc_g_mctx, test,
|
||||
strlen(test), &res_len);
|
||||
assert_non_null(res);
|
||||
assert_true(res_len == strlen(res_test));
|
||||
assert_true(strcmp(res, res_test) == 0);
|
||||
isc_mem_free(mctx, res);
|
||||
isc_mem_free(isc_g_mctx, res);
|
||||
}
|
||||
/* valid */
|
||||
{
|
||||
char test[] = "PDw_Pz8-Pg";
|
||||
char res_test[] = "PDw/Pz8+Pg==";
|
||||
|
||||
res = isc__nm_base64url_to_base64(mctx, test, strlen(test),
|
||||
&res_len);
|
||||
res = isc__nm_base64url_to_base64(isc_g_mctx, test,
|
||||
strlen(test), &res_len);
|
||||
assert_non_null(res);
|
||||
assert_true(res_len == strlen(res_test));
|
||||
assert_true(strcmp(res, res_test) == 0);
|
||||
isc_mem_free(mctx, res);
|
||||
isc_mem_free(isc_g_mctx, res);
|
||||
}
|
||||
/* valid */
|
||||
{
|
||||
char test[] = "PDw_Pz8-Pg";
|
||||
char res_test[] = "PDw/Pz8+Pg==";
|
||||
|
||||
res = isc__nm_base64url_to_base64(mctx, test, strlen(test),
|
||||
NULL);
|
||||
res = isc__nm_base64url_to_base64(isc_g_mctx, test,
|
||||
strlen(test), NULL);
|
||||
assert_non_null(res);
|
||||
assert_true(strcmp(res, res_test) == 0);
|
||||
isc_mem_free(mctx, res);
|
||||
isc_mem_free(isc_g_mctx, res);
|
||||
}
|
||||
/* invalid */
|
||||
{
|
||||
char test[] = "YW55IGNhcm5hbCBwbGVhcw";
|
||||
res_len = 0;
|
||||
|
||||
res = isc__nm_base64url_to_base64(mctx, test, 0, &res_len);
|
||||
res = isc__nm_base64url_to_base64(isc_g_mctx, test, 0,
|
||||
&res_len);
|
||||
assert_null(res);
|
||||
assert_true(res_len == 0);
|
||||
}
|
||||
|
|
@ -1450,8 +1449,8 @@ ISC_RUN_TEST_IMPL(doh_base64url_to_base64) {
|
|||
char test[] = "";
|
||||
res_len = 0;
|
||||
|
||||
res = isc__nm_base64url_to_base64(mctx, test, strlen(test),
|
||||
&res_len);
|
||||
res = isc__nm_base64url_to_base64(isc_g_mctx, test,
|
||||
strlen(test), &res_len);
|
||||
assert_null(res);
|
||||
assert_true(res_len == 0);
|
||||
}
|
||||
|
|
@ -1460,8 +1459,8 @@ ISC_RUN_TEST_IMPL(doh_base64url_to_base64) {
|
|||
char test[] = "PDw_Pz8-Pg==";
|
||||
res_len = 0;
|
||||
|
||||
res = isc__nm_base64url_to_base64(mctx, test, strlen(test),
|
||||
&res_len);
|
||||
res = isc__nm_base64url_to_base64(isc_g_mctx, test,
|
||||
strlen(test), &res_len);
|
||||
assert_null(res);
|
||||
assert_true(res_len == 0);
|
||||
}
|
||||
|
|
@ -1471,8 +1470,8 @@ ISC_RUN_TEST_IMPL(doh_base64url_to_base64) {
|
|||
end */
|
||||
res_len = 0;
|
||||
|
||||
res = isc__nm_base64url_to_base64(mctx, test, strlen(test),
|
||||
&res_len);
|
||||
res = isc__nm_base64url_to_base64(isc_g_mctx, test,
|
||||
strlen(test), &res_len);
|
||||
assert_null(res);
|
||||
assert_true(res_len == 0);
|
||||
}
|
||||
|
|
@ -1480,7 +1479,8 @@ ISC_RUN_TEST_IMPL(doh_base64url_to_base64) {
|
|||
{
|
||||
res_len = 0;
|
||||
|
||||
res = isc__nm_base64url_to_base64(mctx, NULL, 31231, &res_len);
|
||||
res = isc__nm_base64url_to_base64(isc_g_mctx, NULL, 31231,
|
||||
&res_len);
|
||||
assert_null(res);
|
||||
assert_true(res_len == 0);
|
||||
}
|
||||
|
|
@ -1494,90 +1494,91 @@ ISC_RUN_TEST_IMPL(doh_base64_to_base64url) {
|
|||
char res_test[] = "YW55IGNhcm5hbCBwbGVhc3VyZS4";
|
||||
char test[] = "YW55IGNhcm5hbCBwbGVhc3VyZS4=";
|
||||
|
||||
res = isc__nm_base64_to_base64url(mctx, test, strlen(test),
|
||||
&res_len);
|
||||
res = isc__nm_base64_to_base64url(isc_g_mctx, test,
|
||||
strlen(test), &res_len);
|
||||
assert_non_null(res);
|
||||
assert_true(res_len == strlen(res_test));
|
||||
assert_true(strcmp(res, res_test) == 0);
|
||||
isc_mem_free(mctx, res);
|
||||
isc_mem_free(isc_g_mctx, res);
|
||||
}
|
||||
/* valid */
|
||||
{
|
||||
char res_test[] = "YW55IGNhcm5hbCBwbGVhcw";
|
||||
char test[] = "YW55IGNhcm5hbCBwbGVhcw==";
|
||||
|
||||
res = isc__nm_base64_to_base64url(mctx, test, strlen(test),
|
||||
&res_len);
|
||||
res = isc__nm_base64_to_base64url(isc_g_mctx, test,
|
||||
strlen(test), &res_len);
|
||||
assert_non_null(res);
|
||||
assert_true(res_len == strlen(res_test));
|
||||
assert_true(strcmp(res, res_test) == 0);
|
||||
isc_mem_free(mctx, res);
|
||||
isc_mem_free(isc_g_mctx, res);
|
||||
}
|
||||
/* valid */
|
||||
{
|
||||
char res_test[] = "YW55IGNhcm5hbCBwbGVhc3Vy";
|
||||
char test[] = "YW55IGNhcm5hbCBwbGVhc3Vy";
|
||||
|
||||
res = isc__nm_base64_to_base64url(mctx, test, strlen(test),
|
||||
&res_len);
|
||||
res = isc__nm_base64_to_base64url(isc_g_mctx, test,
|
||||
strlen(test), &res_len);
|
||||
assert_non_null(res);
|
||||
assert_true(res_len == strlen(res_test));
|
||||
assert_true(strcmp(res, res_test) == 0);
|
||||
isc_mem_free(mctx, res);
|
||||
isc_mem_free(isc_g_mctx, res);
|
||||
}
|
||||
/* valid */
|
||||
{
|
||||
char res_test[] = "YW55IGNhcm5hbCBwbGVhc3U";
|
||||
char test[] = "YW55IGNhcm5hbCBwbGVhc3U=";
|
||||
|
||||
res = isc__nm_base64_to_base64url(mctx, test, strlen(test),
|
||||
&res_len);
|
||||
res = isc__nm_base64_to_base64url(isc_g_mctx, test,
|
||||
strlen(test), &res_len);
|
||||
assert_non_null(res);
|
||||
assert_true(res_len == strlen(res_test));
|
||||
assert_true(strcmp(res, res_test) == 0);
|
||||
isc_mem_free(mctx, res);
|
||||
isc_mem_free(isc_g_mctx, res);
|
||||
}
|
||||
/* valid */
|
||||
{
|
||||
char res_test[] = "YW55IGNhcm5hbCBwbGVhcw";
|
||||
char test[] = "YW55IGNhcm5hbCBwbGVhcw==";
|
||||
|
||||
res = isc__nm_base64_to_base64url(mctx, test, strlen(test),
|
||||
&res_len);
|
||||
res = isc__nm_base64_to_base64url(isc_g_mctx, test,
|
||||
strlen(test), &res_len);
|
||||
assert_non_null(res);
|
||||
assert_true(res_len == strlen(res_test));
|
||||
assert_true(strcmp(res, res_test) == 0);
|
||||
isc_mem_free(mctx, res);
|
||||
isc_mem_free(isc_g_mctx, res);
|
||||
}
|
||||
/* valid */
|
||||
{
|
||||
char res_test[] = "PDw_Pz8-Pg";
|
||||
char test[] = "PDw/Pz8+Pg==";
|
||||
|
||||
res = isc__nm_base64_to_base64url(mctx, test, strlen(test),
|
||||
&res_len);
|
||||
res = isc__nm_base64_to_base64url(isc_g_mctx, test,
|
||||
strlen(test), &res_len);
|
||||
assert_non_null(res);
|
||||
assert_true(res_len == strlen(res_test));
|
||||
assert_true(strcmp(res, res_test) == 0);
|
||||
isc_mem_free(mctx, res);
|
||||
isc_mem_free(isc_g_mctx, res);
|
||||
}
|
||||
/* valid */
|
||||
{
|
||||
char res_test[] = "PDw_Pz8-Pg";
|
||||
char test[] = "PDw/Pz8+Pg==";
|
||||
|
||||
res = isc__nm_base64_to_base64url(mctx, test, strlen(test),
|
||||
NULL);
|
||||
res = isc__nm_base64_to_base64url(isc_g_mctx, test,
|
||||
strlen(test), NULL);
|
||||
assert_non_null(res);
|
||||
assert_true(strcmp(res, res_test) == 0);
|
||||
isc_mem_free(mctx, res);
|
||||
isc_mem_free(isc_g_mctx, res);
|
||||
}
|
||||
/* invalid */
|
||||
{
|
||||
char test[] = "YW55IGNhcm5hbCBwbGVhcw";
|
||||
res_len = 0;
|
||||
|
||||
res = isc__nm_base64_to_base64url(mctx, test, 0, &res_len);
|
||||
res = isc__nm_base64_to_base64url(isc_g_mctx, test, 0,
|
||||
&res_len);
|
||||
assert_null(res);
|
||||
assert_true(res_len == 0);
|
||||
}
|
||||
|
|
@ -1586,8 +1587,8 @@ ISC_RUN_TEST_IMPL(doh_base64_to_base64url) {
|
|||
char test[] = "";
|
||||
res_len = 0;
|
||||
|
||||
res = isc__nm_base64_to_base64url(mctx, test, strlen(test),
|
||||
&res_len);
|
||||
res = isc__nm_base64_to_base64url(isc_g_mctx, test,
|
||||
strlen(test), &res_len);
|
||||
assert_null(res);
|
||||
assert_true(res_len == 0);
|
||||
}
|
||||
|
|
@ -1596,8 +1597,8 @@ ISC_RUN_TEST_IMPL(doh_base64_to_base64url) {
|
|||
char test[] = "PDw_Pz8-Pg==";
|
||||
res_len = 0;
|
||||
|
||||
res = isc__nm_base64_to_base64url(mctx, test, strlen(test),
|
||||
&res_len);
|
||||
res = isc__nm_base64_to_base64url(isc_g_mctx, test,
|
||||
strlen(test), &res_len);
|
||||
assert_null(res);
|
||||
assert_true(res_len == 0);
|
||||
}
|
||||
|
|
@ -1607,8 +1608,8 @@ ISC_RUN_TEST_IMPL(doh_base64_to_base64url) {
|
|||
end */
|
||||
res_len = 0;
|
||||
|
||||
res = isc__nm_base64_to_base64url(mctx, test, strlen(test),
|
||||
&res_len);
|
||||
res = isc__nm_base64_to_base64url(isc_g_mctx, test,
|
||||
strlen(test), &res_len);
|
||||
assert_null(res);
|
||||
assert_true(res_len == 0);
|
||||
}
|
||||
|
|
@ -1616,7 +1617,8 @@ ISC_RUN_TEST_IMPL(doh_base64_to_base64url) {
|
|||
{
|
||||
res_len = 0;
|
||||
|
||||
res = isc__nm_base64_to_base64url(mctx, NULL, 31231, &res_len);
|
||||
res = isc__nm_base64_to_base64url(isc_g_mctx, NULL, 31231,
|
||||
&res_len);
|
||||
assert_null(res);
|
||||
assert_true(res_len == 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,9 +34,7 @@
|
|||
|
||||
/* INCLUDE LAST */
|
||||
|
||||
#define mctx __mctx
|
||||
#include "hashmap.c"
|
||||
#undef mctx
|
||||
|
||||
typedef struct test_node {
|
||||
uint32_t hashval;
|
||||
|
|
@ -71,11 +69,11 @@ test_hashmap_full(uint8_t init_bits, uintptr_t count) {
|
|||
isc_result_t result;
|
||||
test_node_t *nodes, *long_nodes, *upper_nodes;
|
||||
|
||||
nodes = isc_mem_cget(mctx, count, sizeof(nodes[0]));
|
||||
long_nodes = isc_mem_cget(mctx, count, sizeof(nodes[0]));
|
||||
upper_nodes = isc_mem_cget(mctx, count, sizeof(nodes[0]));
|
||||
nodes = isc_mem_cget(isc_g_mctx, count, sizeof(nodes[0]));
|
||||
long_nodes = isc_mem_cget(isc_g_mctx, count, sizeof(nodes[0]));
|
||||
upper_nodes = isc_mem_cget(isc_g_mctx, count, sizeof(nodes[0]));
|
||||
|
||||
isc_hashmap_create(mctx, init_bits, &hashmap);
|
||||
isc_hashmap_create(isc_g_mctx, init_bits, &hashmap);
|
||||
assert_non_null(hashmap);
|
||||
|
||||
/*
|
||||
|
|
@ -212,9 +210,9 @@ test_hashmap_full(uint8_t init_bits, uintptr_t count) {
|
|||
isc_hashmap_destroy(&hashmap);
|
||||
assert_null(hashmap);
|
||||
|
||||
isc_mem_cput(mctx, nodes, count, sizeof(nodes[0]));
|
||||
isc_mem_cput(mctx, long_nodes, count, sizeof(nodes[0]));
|
||||
isc_mem_cput(mctx, upper_nodes, count, sizeof(nodes[0]));
|
||||
isc_mem_cput(isc_g_mctx, nodes, count, sizeof(nodes[0]));
|
||||
isc_mem_cput(isc_g_mctx, long_nodes, count, sizeof(nodes[0]));
|
||||
isc_mem_cput(isc_g_mctx, upper_nodes, count, sizeof(nodes[0]));
|
||||
}
|
||||
|
||||
#include "hashmap_nodes.h"
|
||||
|
|
@ -228,10 +226,10 @@ test_hashmap_iterator(bool random_data) {
|
|||
test_node_t *nodes;
|
||||
bool *seen;
|
||||
|
||||
nodes = isc_mem_cget(mctx, count, sizeof(nodes[0]));
|
||||
seen = isc_mem_cget(mctx, count, sizeof(seen[0]));
|
||||
nodes = isc_mem_cget(isc_g_mctx, count, sizeof(nodes[0]));
|
||||
seen = isc_mem_cget(isc_g_mctx, count, sizeof(seen[0]));
|
||||
|
||||
isc_hashmap_create(mctx, HASHMAP_MIN_BITS, &hashmap);
|
||||
isc_hashmap_create(isc_g_mctx, HASHMAP_MIN_BITS, &hashmap);
|
||||
assert_non_null(hashmap);
|
||||
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
|
|
@ -357,8 +355,8 @@ test_hashmap_iterator(bool random_data) {
|
|||
isc_hashmap_destroy(&hashmap);
|
||||
assert_null(hashmap);
|
||||
|
||||
isc_mem_cput(mctx, seen, count, sizeof(seen[0]));
|
||||
isc_mem_cput(mctx, nodes, count, sizeof(nodes[0]));
|
||||
isc_mem_cput(isc_g_mctx, seen, count, sizeof(seen[0]));
|
||||
isc_mem_cput(isc_g_mctx, nodes, count, sizeof(nodes[0]));
|
||||
}
|
||||
|
||||
/* 1 bit, 120 elements test, full rehashing */
|
||||
|
|
@ -409,7 +407,7 @@ ISC_RUN_TEST_IMPL(isc_hashmap_hash_zero_length) {
|
|||
bool again = false;
|
||||
|
||||
again:
|
||||
isc_hashmap_create(mctx, 1, &hashmap);
|
||||
isc_hashmap_create(isc_g_mctx, 1, &hashmap);
|
||||
|
||||
hashval = isc_hash32("", 0, true);
|
||||
|
||||
|
|
@ -452,7 +450,7 @@ ISC_RUN_TEST_IMPL(isc_hashmap_case) {
|
|||
test_node_t mixed = { .key = "IsC_hAsHmAp_CaSe" };
|
||||
void *f = NULL;
|
||||
|
||||
isc_hashmap_create(mctx, 1, &hashmap);
|
||||
isc_hashmap_create(isc_g_mctx, 1, &hashmap);
|
||||
|
||||
result = isc_hashmap_add(hashmap,
|
||||
isc_hash32(lower.key, strlen(lower.key), true),
|
||||
|
|
@ -477,7 +475,7 @@ ISC_RUN_TEST_IMPL(isc_hashmap_case) {
|
|||
|
||||
isc_hashmap_destroy(&hashmap);
|
||||
|
||||
isc_hashmap_create(mctx, 1, &hashmap);
|
||||
isc_hashmap_create(isc_g_mctx, 1, &hashmap);
|
||||
|
||||
result = isc_hashmap_add(
|
||||
hashmap, isc_hash32(lower.key, strlen(lower.key), false),
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ ISC_RUN_TEST_IMPL(isc_heap_delete) {
|
|||
|
||||
UNUSED(state);
|
||||
|
||||
isc_heap_create(mctx, compare, idx, 0, &heap);
|
||||
isc_heap_create(isc_g_mctx, compare, idx, 0, &heap);
|
||||
assert_non_null(heap);
|
||||
|
||||
isc_heap_insert(heap, &e1);
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ ISC_RUN_TEST_IMPL(basics) {
|
|||
isc_nanosecs_t start = isc_time_monotonic();
|
||||
|
||||
isc_histo_t *hg = NULL;
|
||||
isc_histo_create(mctx, bits, &hg);
|
||||
isc_histo_create(isc_g_mctx, bits, &hg);
|
||||
|
||||
isc_histo_inc(hg, 0);
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ ISC_RUN_TEST_IMPL(quantiles) {
|
|||
isc_nanosecs_t start = isc_time_monotonic();
|
||||
|
||||
isc_histo_t *hg = NULL;
|
||||
isc_histo_create(mctx, bits, &hg);
|
||||
isc_histo_create(isc_g_mctx, bits, &hg);
|
||||
|
||||
/* ensure empty histogram does not divide by zero */
|
||||
isc_histo_moments(hg, &pop, &mean, &sd);
|
||||
|
|
@ -248,7 +248,7 @@ ISC_RUN_TEST_IMPL(sigfigs) {
|
|||
|
||||
for (uint bits = ISC_HISTO_MINBITS; bits <= ISC_HISTO_MAXBITS; bits++) {
|
||||
isc_histo_t *hg = NULL;
|
||||
isc_histo_create(mctx, bits, &hg);
|
||||
isc_histo_create(isc_g_mctx, bits, &hg);
|
||||
|
||||
uint digits = isc_histo_bits_to_digits(bits);
|
||||
assert_true(bits >= isc_histo_digits_to_bits(digits));
|
||||
|
|
@ -289,7 +289,7 @@ ISC_RUN_TEST_IMPL(subrange) {
|
|||
isc_nanosecs_t start = isc_time_monotonic();
|
||||
|
||||
isc_histo_t *hg = NULL;
|
||||
isc_histo_create(mctx, bits, &hg);
|
||||
isc_histo_create(isc_g_mctx, bits, &hg);
|
||||
|
||||
uint64_t value[SUBRANGE + 1];
|
||||
double frac[SUBRANGE + 1];
|
||||
|
|
@ -334,7 +334,7 @@ ISC_RUN_TEST_IMPL(subrange) {
|
|||
assert_int_equal(value[0], max);
|
||||
|
||||
isc_histo_destroy(&hg);
|
||||
isc_histo_create(mctx, bits, &hg);
|
||||
isc_histo_create(isc_g_mctx, bits, &hg);
|
||||
|
||||
/* these tests can be slow */
|
||||
if (isc_time_monotonic() > start + TIME_LIMIT) {
|
||||
|
|
|
|||
|
|
@ -34,9 +34,7 @@
|
|||
|
||||
/* INCLUDE LAST */
|
||||
|
||||
#define mctx __mctx
|
||||
#include "ht.c"
|
||||
#undef mctx
|
||||
|
||||
static void
|
||||
test_ht_full(uint8_t init_bits, uintptr_t count) {
|
||||
|
|
@ -44,7 +42,7 @@ test_ht_full(uint8_t init_bits, uintptr_t count) {
|
|||
isc_result_t result;
|
||||
uintptr_t i;
|
||||
|
||||
isc_ht_init(&ht, mctx, init_bits, ISC_HT_CASE_SENSITIVE);
|
||||
isc_ht_init(&ht, isc_g_mctx, init_bits, ISC_HT_CASE_SENSITIVE);
|
||||
assert_non_null(ht);
|
||||
|
||||
for (i = 1; i < count; i++) {
|
||||
|
|
@ -189,7 +187,7 @@ test_ht_iterator(void) {
|
|||
unsigned char key[16];
|
||||
size_t tksize;
|
||||
|
||||
isc_ht_init(&ht, mctx, HT_MIN_BITS, ISC_HT_CASE_SENSITIVE);
|
||||
isc_ht_init(&ht, isc_g_mctx, HT_MIN_BITS, ISC_HT_CASE_SENSITIVE);
|
||||
assert_non_null(ht);
|
||||
for (i = 1; i <= count; i++) {
|
||||
/*
|
||||
|
|
@ -341,7 +339,7 @@ ISC_RUN_TEST_IMPL(isc_ht_case) {
|
|||
unsigned char upper[16] = { "TEST CASE" };
|
||||
unsigned char mixed[16] = { "tEsT CaSe" };
|
||||
|
||||
isc_ht_init(&ht, mctx, 8, ISC_HT_CASE_SENSITIVE);
|
||||
isc_ht_init(&ht, isc_g_mctx, 8, ISC_HT_CASE_SENSITIVE);
|
||||
assert_non_null(ht);
|
||||
|
||||
result = isc_ht_add(ht, lower, 16, (void *)lower);
|
||||
|
|
@ -360,7 +358,7 @@ ISC_RUN_TEST_IMPL(isc_ht_case) {
|
|||
isc_ht_destroy(&ht);
|
||||
assert_null(ht);
|
||||
|
||||
isc_ht_init(&ht, mctx, 8, ISC_HT_CASE_INSENSITIVE);
|
||||
isc_ht_init(&ht, isc_g_mctx, 8, ISC_HT_CASE_INSENSITIVE);
|
||||
assert_non_null(ht);
|
||||
|
||||
result = isc_ht_add(ht, lower, 16, (void *)lower);
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ static void
|
|||
shutdown_cb(void *arg) {
|
||||
struct test_arg *ta = arg;
|
||||
|
||||
isc_mem_put(mctx, ta, sizeof(*ta));
|
||||
isc_mem_put(isc_g_mctx, ta, sizeof(*ta));
|
||||
|
||||
isc_loopmgr_shutdown();
|
||||
}
|
||||
|
|
@ -75,7 +75,7 @@ job_run_cb(void *arg) {
|
|||
atomic_fetch_add(&scheduled, 1);
|
||||
|
||||
if (arg == NULL) {
|
||||
ta = isc_mem_get(mctx, sizeof(*ta));
|
||||
ta = isc_mem_get(isc_g_mctx, sizeof(*ta));
|
||||
*ta = (struct test_arg){ .job = ISC_JOB_INITIALIZER };
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ ISC_RUN_TEST_IMPL(lex_0xff) {
|
|||
|
||||
UNUSED(state);
|
||||
|
||||
isc_lex_create(mctx, 1024, &lex);
|
||||
isc_lex_create(isc_g_mctx, 1024, &lex);
|
||||
|
||||
isc_buffer_init(&death_buf, &death[0], sizeof(death));
|
||||
isc_buffer_add(&death_buf, sizeof(death));
|
||||
|
|
@ -70,7 +70,7 @@ ISC_RUN_TEST_IMPL(lex_setline) {
|
|||
|
||||
UNUSED(state);
|
||||
|
||||
isc_lex_create(mctx, 1024, &lex);
|
||||
isc_lex_create(isc_g_mctx, 1024, &lex);
|
||||
|
||||
isc_buffer_init(&buf, &text[0], sizeof(text));
|
||||
isc_buffer_add(&buf, sizeof(text));
|
||||
|
|
@ -192,7 +192,7 @@ ISC_RUN_TEST_IMPL(lex_string) {
|
|||
UNUSED(state);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(parse_tests); i++) {
|
||||
isc_lex_create(mctx, 1024, &lex);
|
||||
isc_lex_create(isc_g_mctx, 1024, &lex);
|
||||
|
||||
isc_buffer_constinit(&buf, parse_tests[i].text,
|
||||
strlen(parse_tests[i].text));
|
||||
|
|
@ -245,7 +245,7 @@ ISC_RUN_TEST_IMPL(lex_qstring) {
|
|||
UNUSED(state);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(parse_tests); i++) {
|
||||
isc_lex_create(mctx, 1024, &lex);
|
||||
isc_lex_create(isc_g_mctx, 1024, &lex);
|
||||
|
||||
isc_buffer_constinit(&buf, parse_tests[i].text,
|
||||
strlen(parse_tests[i].text));
|
||||
|
|
@ -299,7 +299,7 @@ ISC_RUN_TEST_IMPL(lex_keypair) {
|
|||
UNUSED(state);
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(parse_tests); i++) {
|
||||
isc_lex_create(mctx, 1024, &lex);
|
||||
isc_lex_create(isc_g_mctx, 1024, &lex);
|
||||
|
||||
isc_buffer_constinit(&buf, parse_tests[i].text,
|
||||
strlen(parse_tests[i].text));
|
||||
|
|
|
|||
|
|
@ -56,8 +56,8 @@ ISC_RUN_TEST_IMPL(isc_mem_get) {
|
|||
unsigned int i, j;
|
||||
int rval;
|
||||
|
||||
isc_mempool_create(mctx, 24, "mp1", &mp1);
|
||||
isc_mempool_create(mctx, 31, "mp2", &mp2);
|
||||
isc_mempool_create(isc_g_mctx, 24, "mp1", &mp1);
|
||||
isc_mempool_create(isc_g_mctx, 31, "mp2", &mp2);
|
||||
|
||||
isc_mempool_setfreemax(mp1, MP1_FREEMAX);
|
||||
isc_mempool_setfillcount(mp1, MP1_FILLCNT);
|
||||
|
|
@ -114,7 +114,7 @@ ISC_RUN_TEST_IMPL(isc_mem_get) {
|
|||
isc_mempool_destroy(&mp1);
|
||||
isc_mempool_destroy(&mp2);
|
||||
|
||||
isc_mempool_create(mctx, 2, "mp1", &mp1);
|
||||
isc_mempool_create(isc_g_mctx, 2, "mp1", &mp1);
|
||||
|
||||
tmp = isc_mempool_get(mp1);
|
||||
assert_non_null(tmp);
|
||||
|
|
@ -132,22 +132,22 @@ ISC_RUN_TEST_IMPL(isc_mem_cget_zero) {
|
|||
|
||||
/* Skip the test if the memory is zeroed even in normal case */
|
||||
zeroed = true;
|
||||
ptr = isc_mem_get(mctx, sizeof(expected));
|
||||
ptr = isc_mem_get(isc_g_mctx, sizeof(expected));
|
||||
for (size_t i = 0; i < sizeof(expected); i++) {
|
||||
if (ptr[i] != expected[i]) {
|
||||
zeroed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
isc_mem_put(mctx, ptr, sizeof(expected));
|
||||
isc_mem_put(isc_g_mctx, ptr, sizeof(expected));
|
||||
if (zeroed) {
|
||||
skip();
|
||||
return;
|
||||
}
|
||||
|
||||
ptr = isc_mem_cget(mctx, 1, sizeof(expected));
|
||||
ptr = isc_mem_cget(isc_g_mctx, 1, sizeof(expected));
|
||||
assert_memory_equal(ptr, expected, sizeof(expected));
|
||||
isc_mem_put(mctx, ptr, sizeof(expected));
|
||||
isc_mem_put(isc_g_mctx, ptr, sizeof(expected));
|
||||
}
|
||||
|
||||
ISC_RUN_TEST_IMPL(isc_mem_callocate_zero) {
|
||||
|
|
@ -157,52 +157,51 @@ ISC_RUN_TEST_IMPL(isc_mem_callocate_zero) {
|
|||
|
||||
/* Skip the test if the memory is zeroed even in normal case */
|
||||
zeroed = true;
|
||||
ptr = isc_mem_get(mctx, sizeof(expected));
|
||||
ptr = isc_mem_get(isc_g_mctx, sizeof(expected));
|
||||
for (size_t i = 0; i < sizeof(expected); i++) {
|
||||
if (ptr[i] != expected[i]) {
|
||||
zeroed = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
isc_mem_put(mctx, ptr, sizeof(expected));
|
||||
isc_mem_put(isc_g_mctx, ptr, sizeof(expected));
|
||||
if (zeroed) {
|
||||
skip();
|
||||
return;
|
||||
}
|
||||
|
||||
ptr = isc_mem_callocate(mctx, 1, sizeof(expected));
|
||||
ptr = isc_mem_callocate(isc_g_mctx, 1, sizeof(expected));
|
||||
assert_memory_equal(ptr, expected, sizeof(expected));
|
||||
isc_mem_free(mctx, ptr);
|
||||
isc_mem_free(isc_g_mctx, ptr);
|
||||
}
|
||||
|
||||
/* test InUse calculation */
|
||||
ISC_RUN_TEST_IMPL(isc_mem_inuse) {
|
||||
isc_mem_t *mctx2 = NULL;
|
||||
isc_mem_t *mctx = NULL;
|
||||
size_t before, after;
|
||||
ssize_t diff;
|
||||
void *ptr;
|
||||
|
||||
mctx2 = NULL;
|
||||
isc_mem_create("test", &mctx2);
|
||||
isc_mem_create("test", &mctx);
|
||||
|
||||
before = isc_mem_inuse(mctx2);
|
||||
ptr = isc_mem_allocate(mctx2, 1024000);
|
||||
isc_mem_free(mctx2, ptr);
|
||||
after = isc_mem_inuse(mctx2);
|
||||
before = isc_mem_inuse(mctx);
|
||||
ptr = isc_mem_allocate(mctx, 1024000);
|
||||
isc_mem_free(mctx, ptr);
|
||||
after = isc_mem_inuse(mctx);
|
||||
|
||||
diff = after - before;
|
||||
|
||||
assert_int_equal(diff, 0);
|
||||
|
||||
isc_mem_detach(&mctx2);
|
||||
isc_mem_detach(&mctx);
|
||||
}
|
||||
|
||||
ISC_RUN_TEST_IMPL(isc_mem_zeroget) {
|
||||
uint8_t *data = NULL;
|
||||
|
||||
data = isc_mem_get(mctx, 0);
|
||||
data = isc_mem_get(isc_g_mctx, 0);
|
||||
assert_non_null(data);
|
||||
isc_mem_put(mctx, data, 0);
|
||||
isc_mem_put(isc_g_mctx, data, 0);
|
||||
}
|
||||
|
||||
#define REGET_INIT_SIZE 1024
|
||||
|
|
@ -213,22 +212,23 @@ ISC_RUN_TEST_IMPL(isc_mem_reget) {
|
|||
uint8_t *data = NULL;
|
||||
|
||||
/* test that we can reget NULL */
|
||||
data = isc_mem_reget(mctx, NULL, 0, REGET_INIT_SIZE);
|
||||
data = isc_mem_reget(isc_g_mctx, NULL, 0, REGET_INIT_SIZE);
|
||||
assert_non_null(data);
|
||||
isc_mem_put(mctx, data, REGET_INIT_SIZE);
|
||||
isc_mem_put(isc_g_mctx, data, REGET_INIT_SIZE);
|
||||
|
||||
/* test that we can re-get a zero-length allocation */
|
||||
data = isc_mem_get(mctx, 0);
|
||||
data = isc_mem_get(isc_g_mctx, 0);
|
||||
assert_non_null(data);
|
||||
|
||||
data = isc_mem_reget(mctx, data, 0, REGET_INIT_SIZE);
|
||||
data = isc_mem_reget(isc_g_mctx, data, 0, REGET_INIT_SIZE);
|
||||
assert_non_null(data);
|
||||
|
||||
for (size_t i = 0; i < REGET_INIT_SIZE; i++) {
|
||||
data[i] = i % UINT8_MAX;
|
||||
}
|
||||
|
||||
data = isc_mem_reget(mctx, data, REGET_INIT_SIZE, REGET_GROW_SIZE);
|
||||
data = isc_mem_reget(isc_g_mctx, data, REGET_INIT_SIZE,
|
||||
REGET_GROW_SIZE);
|
||||
assert_non_null(data);
|
||||
|
||||
for (size_t i = 0; i < REGET_INIT_SIZE; i++) {
|
||||
|
|
@ -239,36 +239,37 @@ ISC_RUN_TEST_IMPL(isc_mem_reget) {
|
|||
data[i - 1] = i % UINT8_MAX;
|
||||
}
|
||||
|
||||
data = isc_mem_reget(mctx, data, REGET_GROW_SIZE, REGET_SHRINK_SIZE);
|
||||
data = isc_mem_reget(isc_g_mctx, data, REGET_GROW_SIZE,
|
||||
REGET_SHRINK_SIZE);
|
||||
assert_non_null(data);
|
||||
|
||||
for (size_t i = REGET_SHRINK_SIZE; i > 0; i--) {
|
||||
assert_int_equal(data[i - 1], i % UINT8_MAX);
|
||||
}
|
||||
|
||||
isc_mem_put(mctx, data, REGET_SHRINK_SIZE);
|
||||
isc_mem_put(isc_g_mctx, data, REGET_SHRINK_SIZE);
|
||||
}
|
||||
|
||||
ISC_RUN_TEST_IMPL(isc_mem_reallocate) {
|
||||
uint8_t *data = NULL;
|
||||
|
||||
/* test that we can reallocate NULL */
|
||||
data = isc_mem_reallocate(mctx, NULL, REGET_INIT_SIZE);
|
||||
data = isc_mem_reallocate(isc_g_mctx, NULL, REGET_INIT_SIZE);
|
||||
assert_non_null(data);
|
||||
isc_mem_free(mctx, data);
|
||||
isc_mem_free(isc_g_mctx, data);
|
||||
|
||||
/* test that we can re-get a zero-length allocation */
|
||||
data = isc_mem_allocate(mctx, 0);
|
||||
data = isc_mem_allocate(isc_g_mctx, 0);
|
||||
assert_non_null(data);
|
||||
|
||||
data = isc_mem_reallocate(mctx, data, REGET_INIT_SIZE);
|
||||
data = isc_mem_reallocate(isc_g_mctx, data, REGET_INIT_SIZE);
|
||||
assert_non_null(data);
|
||||
|
||||
for (size_t i = 0; i < REGET_INIT_SIZE; i++) {
|
||||
data[i] = i % UINT8_MAX;
|
||||
}
|
||||
|
||||
data = isc_mem_reallocate(mctx, data, REGET_GROW_SIZE);
|
||||
data = isc_mem_reallocate(isc_g_mctx, data, REGET_GROW_SIZE);
|
||||
assert_non_null(data);
|
||||
|
||||
for (size_t i = 0; i < REGET_INIT_SIZE; i++) {
|
||||
|
|
@ -279,48 +280,48 @@ ISC_RUN_TEST_IMPL(isc_mem_reallocate) {
|
|||
data[i - 1] = i % UINT8_MAX;
|
||||
}
|
||||
|
||||
data = isc_mem_reallocate(mctx, data, REGET_SHRINK_SIZE);
|
||||
data = isc_mem_reallocate(isc_g_mctx, data, REGET_SHRINK_SIZE);
|
||||
assert_non_null(data);
|
||||
|
||||
for (size_t i = REGET_SHRINK_SIZE; i > 0; i--) {
|
||||
assert_int_equal(data[i - 1], i % UINT8_MAX);
|
||||
}
|
||||
|
||||
isc_mem_free(mctx, data);
|
||||
isc_mem_free(isc_g_mctx, data);
|
||||
}
|
||||
|
||||
ISC_RUN_TEST_IMPL(isc_mem_overmem) {
|
||||
isc_mem_t *omctx = NULL;
|
||||
isc_mem_create("test", &omctx);
|
||||
assert_non_null(omctx);
|
||||
isc_mem_t *mctx = NULL;
|
||||
isc_mem_create("test", &mctx);
|
||||
assert_non_null(mctx);
|
||||
|
||||
isc_mem_setwater(omctx, 1024, 512);
|
||||
isc_mem_setwater(mctx, 1024, 512);
|
||||
|
||||
/* inuse < lo_water */
|
||||
void *data1 = isc_mem_allocate(omctx, 256);
|
||||
assert_false(isc_mem_isovermem(omctx));
|
||||
void *data1 = isc_mem_allocate(mctx, 256);
|
||||
assert_false(isc_mem_isovermem(mctx));
|
||||
|
||||
/* lo_water < inuse < hi_water */
|
||||
void *data2 = isc_mem_allocate(omctx, 512);
|
||||
assert_false(isc_mem_isovermem(omctx));
|
||||
void *data2 = isc_mem_allocate(mctx, 512);
|
||||
assert_false(isc_mem_isovermem(mctx));
|
||||
|
||||
/* hi_water < inuse */
|
||||
void *data3 = isc_mem_allocate(omctx, 512);
|
||||
assert_true(isc_mem_isovermem(omctx));
|
||||
void *data3 = isc_mem_allocate(mctx, 512);
|
||||
assert_true(isc_mem_isovermem(mctx));
|
||||
|
||||
/* lo_water < inuse < hi_water */
|
||||
isc_mem_free(omctx, data2);
|
||||
assert_true(isc_mem_isovermem(omctx));
|
||||
isc_mem_free(mctx, data2);
|
||||
assert_true(isc_mem_isovermem(mctx));
|
||||
|
||||
/* inuse < lo_water */
|
||||
isc_mem_free(omctx, data3);
|
||||
assert_false(isc_mem_isovermem(omctx));
|
||||
isc_mem_free(mctx, data3);
|
||||
assert_false(isc_mem_isovermem(mctx));
|
||||
|
||||
/* inuse == 0 */
|
||||
isc_mem_free(omctx, data1);
|
||||
assert_false(isc_mem_isovermem(omctx));
|
||||
isc_mem_free(mctx, data1);
|
||||
assert_false(isc_mem_isovermem(mctx));
|
||||
|
||||
isc_mem_detach(&omctx);
|
||||
isc_mem_detach(&mctx);
|
||||
}
|
||||
|
||||
#if ISC_MEM_TRACKLINES
|
||||
|
|
@ -328,22 +329,23 @@ ISC_RUN_TEST_IMPL(isc_mem_overmem) {
|
|||
/* test mem with no flags */
|
||||
ISC_RUN_TEST_IMPL(isc_mem_noflags) {
|
||||
isc_result_t result;
|
||||
isc_mem_t *mctx2 = NULL;
|
||||
isc_mem_t *mctx = NULL;
|
||||
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;
|
||||
isc_mem_create("test", &mctx2);
|
||||
ptr = isc_mem_get(mctx2, 2048);
|
||||
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(mctx2, f);
|
||||
isc_mem_put(mctx2, ptr, 2048);
|
||||
isc_mem_detach(&mctx2);
|
||||
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
||||
isc__mem_printactive(mctx, f);
|
||||
isc_mem_put(mctx, ptr, 2048);
|
||||
isc_mem_detach(&mctx);
|
||||
isc_mem_debugon(debugging);
|
||||
isc_stdio_close(f);
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
|
@ -352,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;
|
||||
|
||||
|
|
@ -363,7 +365,7 @@ ISC_RUN_TEST_IMPL(isc_mem_noflags) {
|
|||
/* test mem with record flag */
|
||||
ISC_RUN_TEST_IMPL(isc_mem_recordflag) {
|
||||
isc_result_t result;
|
||||
isc_mem_t *mctx2 = NULL;
|
||||
isc_mem_t *mctx = NULL;
|
||||
char buf[4096], *p;
|
||||
FILE *f;
|
||||
void *ptr;
|
||||
|
|
@ -373,9 +375,9 @@ ISC_RUN_TEST_IMPL(isc_mem_recordflag) {
|
|||
result = isc_stdio_open("mem.output", "w", &f);
|
||||
assert_int_equal(result, ISC_R_SUCCESS);
|
||||
|
||||
isc_mem_create("test", &mctx2);
|
||||
isc_mem_create("test", &mctx);
|
||||
|
||||
ptr = isc_mem_get(mctx2, 2048);
|
||||
ptr = isc_mem_get(mctx, 2048);
|
||||
assert_non_null(ptr);
|
||||
|
||||
/*
|
||||
|
|
@ -385,14 +387,14 @@ ISC_RUN_TEST_IMPL(isc_mem_recordflag) {
|
|||
* shutdown if a plugin leaked memory, because the plugin would be
|
||||
* unloaded, and __FILE__ pointer passed at this time would be dangling.
|
||||
*/
|
||||
ptr2 = isc__mem_get(mctx2, 1024, 0, __func__, dummyfilename, __LINE__);
|
||||
ptr2 = isc__mem_get(mctx, 1024, 0, __func__, dummyfilename, __LINE__);
|
||||
assert_non_null(ptr2);
|
||||
dummyfilename[0] = 'b';
|
||||
|
||||
isc__mem_printactive(mctx2, f);
|
||||
isc_mem_put(mctx2, ptr2, 1024);
|
||||
isc_mem_put(mctx2, ptr, 2048);
|
||||
isc_mem_detach(&mctx2);
|
||||
isc__mem_printactive(mctx, f);
|
||||
isc_mem_put(mctx, ptr2, 1024);
|
||||
isc_mem_put(mctx, ptr, 2048);
|
||||
isc_mem_detach(&mctx);
|
||||
isc_stdio_close(f);
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
|
@ -427,23 +429,26 @@ ISC_RUN_TEST_IMPL(isc_mem_recordflag) {
|
|||
/* test mem with trace flag */
|
||||
ISC_RUN_TEST_IMPL(isc_mem_traceflag) {
|
||||
isc_result_t result;
|
||||
isc_mem_t *mctx2 = NULL;
|
||||
isc_mem_t *mctx = NULL;
|
||||
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;
|
||||
isc_mem_create("test", &mctx2);
|
||||
ptr = isc_mem_get(mctx2, 2048);
|
||||
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(mctx2, f);
|
||||
isc_mem_put(mctx2, ptr, 2048);
|
||||
isc_mem_detach(&mctx2);
|
||||
isc_mem_debugging = ISC_MEM_DEBUGRECORD;
|
||||
isc__mem_printactive(mctx, f);
|
||||
isc_mem_put(mctx, ptr, 2048);
|
||||
isc_mem_detach(&mctx);
|
||||
isc_mem_debugoff(ISC_MEM_DEBUGALL);
|
||||
isc_mem_debugon(debugging);
|
||||
isc_stdio_close(f);
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
|
@ -486,7 +491,7 @@ static atomic_size_t mem_size;
|
|||
|
||||
static void *
|
||||
mem_thread(void *arg) {
|
||||
isc_mem_t *mctx2 = (isc_mem_t *)arg;
|
||||
isc_mem_t *mctx = (isc_mem_t *)arg;
|
||||
void *items[NUM_ITEMS];
|
||||
size_t size = atomic_load(&mem_size);
|
||||
while (!atomic_compare_exchange_weak(&mem_size, &size, size / 2)) {
|
||||
|
|
@ -495,10 +500,10 @@ mem_thread(void *arg) {
|
|||
|
||||
for (int i = 0; i < ITERS; i++) {
|
||||
for (int j = 0; j < NUM_ITEMS; j++) {
|
||||
items[j] = isc_mem_get(mctx2, size);
|
||||
items[j] = isc_mem_get(mctx, size);
|
||||
}
|
||||
for (int j = 0; j < NUM_ITEMS; j++) {
|
||||
isc_mem_put(mctx2, items[j], size);
|
||||
isc_mem_put(mctx, items[j], size);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -516,7 +521,7 @@ ISC_RUN_TEST_IMPL(isc_mem_benchmark) {
|
|||
ts1 = isc_time_now();
|
||||
|
||||
for (int i = 0; i < nthreads; i++) {
|
||||
isc_thread_create(mem_thread, mctx, &threads[i]);
|
||||
isc_thread_create(mem_thread, isc_g_mctx, &threads[i]);
|
||||
}
|
||||
for (int i = 0; i < nthreads; i++) {
|
||||
isc_thread_join(threads[i], NULL);
|
||||
|
|
|
|||
|
|
@ -116,7 +116,8 @@ isc_mutex_thread(void *arg) {
|
|||
}
|
||||
|
||||
ISC_RUN_TEST_IMPL(isc_mutex_benchmark) {
|
||||
isc_thread_t *threads = isc_mem_cget(mctx, workers, sizeof(*threads));
|
||||
isc_thread_t *threads = isc_mem_cget(isc_g_mctx, workers,
|
||||
sizeof(*threads));
|
||||
isc_time_t ts1, ts2;
|
||||
double t;
|
||||
int dc;
|
||||
|
|
@ -202,7 +203,7 @@ ISC_RUN_TEST_IMPL(isc_mutex_benchmark) {
|
|||
|
||||
isc_mutex_destroy(&lock);
|
||||
|
||||
isc_mem_cput(mctx, threads, workers, sizeof(*threads));
|
||||
isc_mem_cput(isc_g_mctx, threads, workers, sizeof(*threads));
|
||||
}
|
||||
|
||||
ISC_TEST_LIST_START
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ setup_netmgr_test(void **state) {
|
|||
isc_nonce_buf(&send_magic, sizeof(send_magic));
|
||||
|
||||
setup_loopmgr(state);
|
||||
isc_netmgr_create(mctx);
|
||||
isc_netmgr_create(isc_g_mctx);
|
||||
isc_nm_setinitialtimeout(T_INIT);
|
||||
isc_nm_setprimariestimeout(T_PRIMARIES);
|
||||
isc_nm_setidletimeout(T_IDLE);
|
||||
|
|
@ -200,7 +200,7 @@ setup_netmgr_test(void **state) {
|
|||
isc_tlsctx_enable_dot_client_alpn(tcp_connect_tlsctx);
|
||||
|
||||
isc_tlsctx_client_session_cache_create(
|
||||
mctx, tcp_connect_tlsctx,
|
||||
isc_g_mctx, tcp_connect_tlsctx,
|
||||
ISC_TLSCTX_CLIENT_SESSION_CACHE_DEFAULT_SIZE,
|
||||
&tcp_tlsctx_client_sess_cache);
|
||||
|
||||
|
|
|
|||
|
|
@ -146,7 +146,8 @@ proxy2_handler_dummy(const isc_result_t result, const isc_proxy2_command_t cmd,
|
|||
static int
|
||||
setup_test_proxy(void **state) {
|
||||
isc_proxy2_handler_t **handler = (isc_proxy2_handler_t **)state;
|
||||
*handler = isc_proxy2_handler_new(mctx, 0, proxy2_handler_dummy, NULL);
|
||||
*handler = isc_proxy2_handler_new(isc_g_mctx, 0, proxy2_handler_dummy,
|
||||
NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -531,7 +532,7 @@ ISC_RUN_TEST_IMPL(proxyheader_max_size_test) {
|
|||
|
||||
UNUSED(state);
|
||||
|
||||
isc_proxy2_handler_init(&handler, mctx, sizeof(proxy_v2_header),
|
||||
isc_proxy2_handler_init(&handler, isc_g_mctx, sizeof(proxy_v2_header),
|
||||
proxy2_handler_dummy, NULL);
|
||||
|
||||
result = isc_proxy2_handler_push_data(&handler, proxy_v2_header,
|
||||
|
|
@ -541,7 +542,8 @@ ISC_RUN_TEST_IMPL(proxyheader_max_size_test) {
|
|||
|
||||
isc_proxy2_handler_uninit(&handler);
|
||||
|
||||
isc_proxy2_handler_init(&handler, mctx, sizeof(proxy_v2_header) - 1,
|
||||
isc_proxy2_handler_init(&handler, isc_g_mctx,
|
||||
sizeof(proxy_v2_header) - 1,
|
||||
proxy2_handler_dummy, NULL);
|
||||
|
||||
result = isc_proxy2_handler_push_data(&handler, proxy_v2_header,
|
||||
|
|
@ -794,8 +796,8 @@ proxy2_handler_rebuild(isc_buffer_t *restrict outbuf, const void *data,
|
|||
const size_t size) {
|
||||
isc_proxy2_handler_t handler = { 0 };
|
||||
|
||||
isc_proxy2_handler_init(&handler, mctx, 0, proxy2_handler_rebuild_cb,
|
||||
outbuf);
|
||||
isc_proxy2_handler_init(&handler, isc_g_mctx, 0,
|
||||
proxy2_handler_rebuild_cb, outbuf);
|
||||
|
||||
isc_proxy2_handler_push_data(&handler, data, size);
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ ISC_RUN_TEST_IMPL(isc_radix_remove) {
|
|||
|
||||
UNUSED(state);
|
||||
|
||||
isc_radix_create(mctx, &radix, 32);
|
||||
isc_radix_create(isc_g_mctx, &radix, 32);
|
||||
|
||||
in_addr.s_addr = inet_addr("1.1.1.1");
|
||||
isc_netaddr_fromin(&netaddr, &in_addr);
|
||||
|
|
@ -90,7 +90,7 @@ ISC_RUN_TEST_IMPL(isc_radix_search) {
|
|||
|
||||
UNUSED(state);
|
||||
|
||||
isc_radix_create(mctx, &radix, 32);
|
||||
isc_radix_create(isc_g_mctx, &radix, 32);
|
||||
|
||||
in_addr.s_addr = inet_addr("3.3.3.0");
|
||||
isc_netaddr_fromin(&netaddr, &in_addr);
|
||||
|
|
|
|||
|
|
@ -403,7 +403,7 @@ monobit(uint16_t *values, size_t length) {
|
|||
double s_obs;
|
||||
double p_value;
|
||||
|
||||
UNUSED(mctx);
|
||||
UNUSED(isc_g_mctx);
|
||||
|
||||
numbits = length * sizeof(*values) * 8;
|
||||
scount = 0;
|
||||
|
|
@ -439,7 +439,7 @@ runs(uint16_t *values, size_t length) {
|
|||
double denom;
|
||||
double p_value;
|
||||
|
||||
UNUSED(mctx);
|
||||
UNUSED(isc_g_mctx);
|
||||
|
||||
numbits = length * sizeof(*values) * 8;
|
||||
bcount = 0;
|
||||
|
|
@ -521,7 +521,7 @@ blockfrequency(uint16_t *values, size_t length) {
|
|||
assert_true(numblocks < 100);
|
||||
assert_true(numbits >= (mbits * numblocks));
|
||||
|
||||
pi = isc_mem_cget(mctx, numblocks, sizeof(double));
|
||||
pi = isc_mem_cget(isc_g_mctx, numblocks, sizeof(double));
|
||||
assert_non_null(pi);
|
||||
|
||||
for (i = 0; i < numblocks; i++) {
|
||||
|
|
@ -544,7 +544,7 @@ blockfrequency(uint16_t *values, size_t length) {
|
|||
|
||||
chi_square *= 4 * mbits;
|
||||
|
||||
isc_mem_cput(mctx, pi, numblocks, sizeof(double));
|
||||
isc_mem_cput(isc_g_mctx, pi, numblocks, sizeof(double));
|
||||
|
||||
p_value = igamc(numblocks * 0.5, chi_square * 0.5);
|
||||
|
||||
|
|
@ -571,7 +571,7 @@ binarymatrixrank(uint16_t *values, size_t length) {
|
|||
double chi_square;
|
||||
double p_value;
|
||||
|
||||
UNUSED(mctx);
|
||||
UNUSED(isc_g_mctx);
|
||||
|
||||
matrix_m = 32;
|
||||
matrix_q = 32;
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue