]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Remove some stale fields from ns_client_t; make sendbuf allocated on heap
authorWitold Kręcicki <wpk@isc.org>
Fri, 31 Jan 2020 21:56:32 +0000 (22:56 +0100)
committerWitold Kręcicki <wpk@isc.org>
Fri, 28 Feb 2020 07:46:16 +0000 (08:46 +0100)
lib/ns/client.c
lib/ns/include/ns/client.h

index 3a0a9c69f7e5c5f93ea25eb096d3c0fa15b3af45..ba0639a83eb5ed70b61e183e323b68d89a751d96 100644 (file)
@@ -189,10 +189,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);
@@ -1622,7 +1618,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);
@@ -1712,7 +1708,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) {
@@ -2316,8 +2311,8 @@ ns__client_setup(ns_client_t *client, ns_clientmgr_t *mgr, bool new) {
                        goto cleanup;
                }
 
-               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.
@@ -2331,7 +2326,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;
@@ -2341,14 +2336,13 @@ 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 };
        }
 
        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);
@@ -2365,9 +2359,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) {
index 12f159b4fac9b5a724985bc7ab3bd82ffd39eae7..61612a32eacad24eb9212d55b2ea01e273ef88d3 100644 (file)
@@ -83,7 +83,6 @@
 
 #define NS_CLIENT_TCP_BUFFER_SIZE  (65535 + 2)
 #define NS_CLIENT_SEND_BUFFER_SIZE 4096
-#define NS_CLIENT_RECV_BUFFER_SIZE 4096
 
 /*!
  * Client object states.  Ordering is significant: higher-numbered
@@ -178,12 +177,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;
@@ -192,8 +186,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;