mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-03 16:15:27 +00:00
use a fixedname buffer in dns_message_gettempname()
dns_message_gettempname() now returns a pointer to an initialized name associated with a dns_fixedname_t object. it is no longer necessary to allocate a buffer for temporary names associated with the message object.
This commit is contained in:
@@ -2884,11 +2884,10 @@ ns_client_putrdataset(ns_client_t *client, dns_rdataset_t **rdatasetp) {
|
||||
|
||||
isc_result_t
|
||||
ns_client_newnamebuf(ns_client_t *client) {
|
||||
isc_buffer_t *dbuf;
|
||||
isc_buffer_t *dbuf = NULL;
|
||||
|
||||
CTRACE("ns_client_newnamebuf");
|
||||
|
||||
dbuf = NULL;
|
||||
isc_buffer_allocate(client->mctx, &dbuf, 1024);
|
||||
ISC_LIST_APPEND(client->query.namebufs, dbuf, link);
|
||||
|
||||
@@ -2898,7 +2897,7 @@ ns_client_newnamebuf(ns_client_t *client) {
|
||||
|
||||
dns_name_t *
|
||||
ns_client_newname(ns_client_t *client, isc_buffer_t *dbuf, isc_buffer_t *nbuf) {
|
||||
dns_name_t *name;
|
||||
dns_name_t *name = NULL;
|
||||
isc_region_t r;
|
||||
isc_result_t result;
|
||||
|
||||
@@ -2906,7 +2905,6 @@ ns_client_newname(ns_client_t *client, isc_buffer_t *dbuf, isc_buffer_t *nbuf) {
|
||||
|
||||
CTRACE("ns_client_newname");
|
||||
|
||||
name = NULL;
|
||||
result = dns_message_gettempname(client->message, &name);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
CTRACE("ns_client_newname: "
|
||||
@@ -2915,7 +2913,7 @@ ns_client_newname(ns_client_t *client, isc_buffer_t *dbuf, isc_buffer_t *nbuf) {
|
||||
}
|
||||
isc_buffer_availableregion(dbuf, &r);
|
||||
isc_buffer_init(nbuf, r.base, r.length);
|
||||
dns_name_init(name, NULL);
|
||||
dns_name_setbuffer(name, NULL);
|
||||
dns_name_setbuffer(name, nbuf);
|
||||
client->query.attributes |= NS_QUERYATTR_NAMEBUFUSED;
|
||||
|
||||
@@ -2926,7 +2924,6 @@ ns_client_newname(ns_client_t *client, isc_buffer_t *dbuf, isc_buffer_t *nbuf) {
|
||||
isc_buffer_t *
|
||||
ns_client_getnamebuf(ns_client_t *client) {
|
||||
isc_buffer_t *dbuf;
|
||||
isc_result_t result;
|
||||
isc_region_t r;
|
||||
|
||||
CTRACE("ns_client_getnamebuf");
|
||||
@@ -2936,24 +2933,14 @@ ns_client_getnamebuf(ns_client_t *client) {
|
||||
* a new one if necessary.
|
||||
*/
|
||||
if (ISC_LIST_EMPTY(client->query.namebufs)) {
|
||||
result = ns_client_newnamebuf(client);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
CTRACE("ns_client_getnamebuf: "
|
||||
"ns_client_newnamebuf failed: done");
|
||||
return (NULL);
|
||||
}
|
||||
ns_client_newnamebuf(client);
|
||||
}
|
||||
|
||||
dbuf = ISC_LIST_TAIL(client->query.namebufs);
|
||||
INSIST(dbuf != NULL);
|
||||
isc_buffer_availableregion(dbuf, &r);
|
||||
if (r.length < DNS_NAME_MAXWIRE) {
|
||||
result = ns_client_newnamebuf(client);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
CTRACE("ns_client_getnamebuf: "
|
||||
"ns_client_newnamebuf failed: done");
|
||||
return (NULL);
|
||||
}
|
||||
ns_client_newnamebuf(client);
|
||||
dbuf = ISC_LIST_TAIL(client->query.namebufs);
|
||||
isc_buffer_availableregion(dbuf, &r);
|
||||
INSIST(r.length >= 255);
|
||||
@@ -2982,8 +2969,6 @@ ns_client_keepname(ns_client_t *client, dns_name_t *name, isc_buffer_t *dbuf) {
|
||||
|
||||
void
|
||||
ns_client_releasename(ns_client_t *client, dns_name_t **namep) {
|
||||
dns_name_t *name = *namep;
|
||||
|
||||
/*%
|
||||
* 'name' is no longer needed. Return it to our pool of temporary
|
||||
* names. If it is using a name buffer, relinquish its exclusive
|
||||
@@ -2991,11 +2976,7 @@ ns_client_releasename(ns_client_t *client, dns_name_t **namep) {
|
||||
*/
|
||||
|
||||
CTRACE("ns_client_releasename");
|
||||
if (dns_name_hasbuffer(name)) {
|
||||
INSIST((client->query.attributes & NS_QUERYATTR_NAMEBUFUSED) !=
|
||||
0);
|
||||
client->query.attributes &= ~NS_QUERYATTR_NAMEBUFUSED;
|
||||
}
|
||||
client->query.attributes &= ~NS_QUERYATTR_NAMEBUFUSED;
|
||||
dns_message_puttempname(client->message, namep);
|
||||
CTRACE("ns_client_releasename: done");
|
||||
}
|
||||
@@ -3003,16 +2984,13 @@ ns_client_releasename(ns_client_t *client, dns_name_t **namep) {
|
||||
isc_result_t
|
||||
ns_client_newdbversion(ns_client_t *client, unsigned int n) {
|
||||
unsigned int i;
|
||||
ns_dbversion_t *dbversion;
|
||||
ns_dbversion_t *dbversion = NULL;
|
||||
|
||||
for (i = 0; i < n; i++) {
|
||||
dbversion = isc_mem_get(client->mctx, sizeof(*dbversion));
|
||||
{
|
||||
dbversion->db = NULL;
|
||||
dbversion->version = NULL;
|
||||
ISC_LIST_INITANDAPPEND(client->query.freeversions,
|
||||
dbversion, link);
|
||||
}
|
||||
*dbversion = (ns_dbversion_t){ 0 };
|
||||
ISC_LIST_INITANDAPPEND(client->query.freeversions, dbversion,
|
||||
link);
|
||||
}
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
@@ -3020,14 +2998,10 @@ ns_client_newdbversion(ns_client_t *client, unsigned int n) {
|
||||
|
||||
static inline ns_dbversion_t *
|
||||
client_getdbversion(ns_client_t *client) {
|
||||
isc_result_t result;
|
||||
ns_dbversion_t *dbversion;
|
||||
ns_dbversion_t *dbversion = NULL;
|
||||
|
||||
if (ISC_LIST_EMPTY(client->query.freeversions)) {
|
||||
result = ns_client_newdbversion(client, 1);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (NULL);
|
||||
}
|
||||
ns_client_newdbversion(client, 1);
|
||||
}
|
||||
dbversion = ISC_LIST_HEAD(client->query.freeversions);
|
||||
INSIST(dbversion != NULL);
|
||||
|
@@ -788,7 +788,7 @@ ns_query_free(ns_client_t *client) {
|
||||
|
||||
isc_result_t
|
||||
ns_query_init(ns_client_t *client) {
|
||||
isc_result_t result;
|
||||
isc_result_t result = ISC_R_SUCCESS;
|
||||
|
||||
REQUIRE(NS_CLIENT_VALID(client));
|
||||
|
||||
@@ -827,16 +827,8 @@ ns_query_init(ns_client_t *client) {
|
||||
client->query.redirect.fname =
|
||||
dns_fixedname_initname(&client->query.redirect.fixed);
|
||||
query_reset(client, false);
|
||||
result = ns_client_newdbversion(client, 3);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
isc_mutex_destroy(&client->query.fetchlock);
|
||||
return (result);
|
||||
}
|
||||
result = ns_client_newnamebuf(client);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
query_freefreeversions(client, true);
|
||||
isc_mutex_destroy(&client->query.fetchlock);
|
||||
}
|
||||
ns_client_newdbversion(client, 3);
|
||||
ns_client_newnamebuf(client);
|
||||
|
||||
return (result);
|
||||
}
|
||||
@@ -9812,8 +9804,7 @@ query_synthcnamewildcard(query_ctx_t *qctx, dns_rdataset_t *rdataset,
|
||||
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
||||
dns_rdata_reset(&rdata);
|
||||
|
||||
dns_name_init(tname, NULL);
|
||||
dns_name_dup(&cname.cname, qctx->client->mctx, tname);
|
||||
dns_name_clone(&cname.cname, tname);
|
||||
|
||||
dns_rdata_freestruct(&cname);
|
||||
ns_client_qnamereplace(qctx->client, tname);
|
||||
@@ -10346,8 +10337,8 @@ cleanup:
|
||||
static isc_result_t
|
||||
query_cname(query_ctx_t *qctx) {
|
||||
isc_result_t result = ISC_R_UNSET;
|
||||
dns_name_t *tname;
|
||||
dns_rdataset_t *trdataset;
|
||||
dns_name_t *tname = NULL;
|
||||
dns_rdataset_t *trdataset = NULL;
|
||||
dns_rdataset_t **sigrdatasetp = NULL;
|
||||
dns_rdata_t rdata = DNS_RDATA_INIT;
|
||||
dns_rdata_cname_t cname;
|
||||
@@ -10409,7 +10400,6 @@ query_cname(query_ctx_t *qctx) {
|
||||
* Reset qname to be the target name of the CNAME and restart
|
||||
* the query.
|
||||
*/
|
||||
tname = NULL;
|
||||
result = dns_message_gettempname(qctx->client->message, &tname);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (ns_query_done(qctx));
|
||||
@@ -10426,8 +10416,7 @@ query_cname(query_ctx_t *qctx) {
|
||||
RUNTIME_CHECK(result == ISC_R_SUCCESS);
|
||||
dns_rdata_reset(&rdata);
|
||||
|
||||
dns_name_init(tname, NULL);
|
||||
dns_name_dup(&cname.cname, qctx->client->mctx, tname);
|
||||
dns_name_clone(&cname.cname, tname);
|
||||
|
||||
dns_rdata_freestruct(&cname);
|
||||
ns_client_qnamereplace(qctx->client, tname);
|
||||
@@ -10627,7 +10616,7 @@ query_addcname(query_ctx_t *qctx, dns_trust_t trust, dns_ttl_t ttl) {
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (result);
|
||||
}
|
||||
dns_name_dup(client->query.qname, client->mctx, aname);
|
||||
dns_name_clone(client->query.qname, aname);
|
||||
|
||||
result = dns_message_gettemprdatalist(client->message, &rdatalist);
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
@@ -10762,7 +10751,6 @@ query_addsoa(query_ctx_t *qctx, unsigned int override_ttl,
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
return (result);
|
||||
}
|
||||
dns_name_init(name, NULL);
|
||||
dns_name_clone(dns_db_origin(qctx->db), name);
|
||||
rdataset = ns_client_newrdataset(client);
|
||||
if (rdataset == NULL) {
|
||||
@@ -10899,7 +10887,6 @@ query_addns(query_ctx_t *qctx) {
|
||||
"failed: done");
|
||||
return (result);
|
||||
}
|
||||
dns_name_init(name, NULL);
|
||||
dns_name_clone(dns_db_origin(qctx->db), name);
|
||||
rdataset = ns_client_newrdataset(client);
|
||||
if (rdataset == NULL) {
|
||||
|
@@ -1402,7 +1402,6 @@ sendstream(xfrout_ctx_t *xfr) {
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto failure;
|
||||
}
|
||||
dns_name_init(qname, NULL);
|
||||
isc_buffer_availableregion(&xfr->buf, &r);
|
||||
INSIST(r.length >= xfr->qname->length);
|
||||
r.length = xfr->qname->length;
|
||||
@@ -1476,7 +1475,6 @@ sendstream(xfrout_ctx_t *xfr) {
|
||||
if (result != ISC_R_SUCCESS) {
|
||||
goto failure;
|
||||
}
|
||||
dns_name_init(msgname, NULL);
|
||||
isc_buffer_availableregion(&xfr->buf, &r);
|
||||
INSIST(r.length >= name->length);
|
||||
r.length = name->length;
|
||||
|
Reference in New Issue
Block a user