Change dns_message_create() function to accept memory pools

Instead of creating new memory pools for each new dns_message, change
dns_message_create() method to optionally accept externally created
dns_fixedname_t and dns_rdataset_t memory pools.  This allows us to
preallocate the memory pools in ns_client and dns_resolver units for the
lifetime of dns_resolver_t and ns_clientmgr_t.
This commit is contained in:
Ondřej Surý
2023-09-22 15:00:40 +02:00
parent 759a977a67
commit f5af981831
21 changed files with 194 additions and 168 deletions

View File

@@ -207,7 +207,7 @@ render(isc_buffer_t *buf, unsigned int flags, dns_tsigkey_t *key,
dns_compress_t cctx;
isc_result_t result;
dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &msg);
dns_message_create(mctx, NULL, NULL, DNS_MESSAGE_INTENTRENDER, &msg);
assert_non_null(msg);
msg->id = 50;
@@ -317,7 +317,7 @@ ISC_RUN_TEST_IMPL(tsig_tcp) {
/*
* Process response message 1.
*/
dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &msg);
dns_message_create(mctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE, &msg);
assert_non_null(msg);
result = dns_message_settsigkey(msg, key);
@@ -370,7 +370,7 @@ ISC_RUN_TEST_IMPL(tsig_tcp) {
/*
* Process response message 2.
*/
dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &msg);
dns_message_create(mctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE, &msg);
assert_non_null(msg);
msg->tcp_continuation = 1;
@@ -415,7 +415,7 @@ ISC_RUN_TEST_IMPL(tsig_tcp) {
/*
* Process response message 3.
*/
dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &msg);
dns_message_create(mctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE, &msg);
assert_non_null(msg);
msg->tcp_continuation = 1;

View File

@@ -262,7 +262,8 @@ attach_query_msg_to_client(ns_client_t *client, const char *qnamestr,
/*
* Create a new DNS message holding a query.
*/
dns_message_create(mctx, DNS_MESSAGE_INTENTRENDER, &message);
dns_message_create(mctx, NULL, NULL, DNS_MESSAGE_INTENTRENDER,
&message);
/*
* Set query ID to a random value.

View File

@@ -43,7 +43,7 @@ check_response(isc_buffer_t *buf) {
char rcodebuf[20];
isc_buffer_t b;
dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &message);
dns_message_create(mctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE, &message);
result = dns_message_parse(message, buf, 0);
assert_int_equal(result, ISC_R_SUCCESS);
@@ -89,7 +89,7 @@ ISC_LOOP_TEST_IMPL(notify_start) {
isc_buffer_init(&nbuf, ndata, nsize);
isc_buffer_add(&nbuf, nsize);
dns_message_create(mctx, DNS_MESSAGE_INTENTPARSE, &nmsg);
dns_message_create(mctx, NULL, NULL, DNS_MESSAGE_INTENTPARSE, &nmsg);
result = dns_message_parse(nmsg, &nbuf, 0);
assert_int_equal(result, ISC_R_SUCCESS);