Remove some stale fields from ns_client_t; make sendbuf allocated on heap

This commit is contained in:
Witold Kręcicki
2020-02-07 08:40:25 +01:00
parent e80ac06ed4
commit 9fda4a4cbf
2 changed files with 9 additions and 24 deletions
+8 -14
View File
@@ -172,10 +172,6 @@ ns_client_settimeout(ns_client_t *client, unsigned int seconds) {
static void
ns_client_endrequest(ns_client_t *client) {
INSIST(client->naccepts == 0);
INSIST(client->nreads == 0);
INSIST(client->nsends == 0);
INSIST(client->nrecvs == 0);
INSIST(client->nupdates == 0);
INSIST(client->state == NS_CLIENTSTATE_WORKING ||
client->state == NS_CLIENTSTATE_RECURSING);
@@ -1574,7 +1570,7 @@ ns__client_put_cb(void *client0) {
clientmgr_detach(&client->manager);
}
isc_mem_put(client->mctx, client->recvbuf, NS_CLIENT_RECV_BUFFER_SIZE);
isc_mem_put(client->mctx, client->sendbuf, NS_CLIENT_SEND_BUFFER_SIZE);
if (client->opt != NULL) {
INSIST(dns_rdataset_isassociated(client->opt));
dns_rdataset_disassociate(client->opt);
@@ -1665,7 +1661,6 @@ ns__client_request(isc_nmhandle_t *handle, isc_region_t *region, void *arg) {
}
client->state = NS_CLIENTSTATE_READY;
client->dscp = ifp->dscp;
isc_task_pause(client->task);
if (client->handle == NULL) {
@@ -2275,8 +2270,8 @@ ns__client_setup(ns_client_t *client, ns_clientmgr_t *mgr, bool new) {
}
client->recvbuf = isc_mem_get(client->mctx,
NS_CLIENT_RECV_BUFFER_SIZE);
client->sendbuf = isc_mem_get(client->mctx,
NS_CLIENT_SEND_BUFFER_SIZE);
/*
* Set magic earlier than usual because ns_query_init()
* and the functions it calls will require it.
@@ -2290,7 +2285,7 @@ ns__client_setup(ns_client_t *client, ns_clientmgr_t *mgr, bool new) {
ns_clientmgr_t *oldmgr = client->manager;
ns_server_t *sctx = client->sctx;
isc_task_t *task = client->task;
unsigned char *recvbuf = client->recvbuf;
unsigned char *sendbuf = client->sendbuf;
dns_message_t *message = client->message;
isc_mem_t *oldmctx = client->mctx;
ns_query_t query = client->query;
@@ -2301,7 +2296,7 @@ ns__client_setup(ns_client_t *client, ns_clientmgr_t *mgr, bool new) {
.manager = oldmgr,
.sctx = sctx,
.task = task,
.recvbuf = recvbuf,
.sendbuf = sendbuf,
.message = message,
.query = query
};
@@ -2309,7 +2304,6 @@ ns__client_setup(ns_client_t *client, ns_clientmgr_t *mgr, bool new) {
client->state = NS_CLIENTSTATE_INACTIVE;
client->udpsize = 512;
client->dscp = -1;
client->ednsversion = -1;
dns_name_init(&client->signername, NULL);
dns_ecs_init(&client->ecs);
@@ -2326,9 +2320,9 @@ ns__client_setup(ns_client_t *client, ns_clientmgr_t *mgr, bool new) {
return (ISC_R_SUCCESS);
cleanup:
if (client->recvbuf != NULL) {
isc_mem_put(client->mctx, client->recvbuf,
NS_CLIENT_RECV_BUFFER_SIZE);
if (client->sendbuf != NULL) {
isc_mem_put(client->mctx, client->sendbuf,
NS_CLIENT_SEND_BUFFER_SIZE);
}
if (client->message != NULL) {
+1 -10
View File
@@ -193,12 +193,7 @@ struct ns_client {
ns_server_t *sctx;
ns_clientmgr_t *manager;
ns_clientstate_t state;
int naccepts;
int nreads;
int nsends;
int nrecvs;
int nupdates;
int nctls;
bool shuttingdown;
unsigned int attributes;
isc_task_t *task;
@@ -207,8 +202,7 @@ struct ns_client {
isc_nmhandle_t *handle;
unsigned char *tcpbuf;
dns_message_t *message;
unsigned char *recvbuf;
unsigned char sendbuf[NS_CLIENT_SEND_BUFFER_SIZE];
unsigned char *sendbuf;
dns_rdataset_t *opt;
uint16_t udpsize;
uint16_t extflags;
@@ -222,7 +216,6 @@ struct ns_client {
isc_time_t tnow;
dns_name_t signername; /*%< [T]SIG key name */
dns_name_t *signer; /*%< NULL if not valid sig */
bool mortal; /*%< Die after handling request */
isc_quota_t *recursionquota;
isc_sockaddr_t peeraddr;
@@ -232,8 +225,6 @@ struct ns_client {
dns_ecs_t ecs; /*%< EDNS client subnet sent by client */
struct in6_pktinfo pktinfo;
isc_dscp_t dscp;
/*%
* Information about recent FORMERR response(s), for
* FORMERR loop avoidance. This is separate for each