mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-09-02 15:45:25 +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);
|
||||
|
Reference in New Issue
Block a user