]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
pullup:
authorAndreas Gustafsson <source@isc.org>
Mon, 17 Jul 2000 19:40:55 +0000 (19:40 +0000)
committerAndreas Gustafsson <source@isc.org>
Mon, 17 Jul 2000 19:40:55 +0000 (19:40 +0000)
 336.   [bug]           "dig -f" used 64 k of memory for each line in
                        the file.  It now uses much less, though still
                        proportionally to the file size.

CHANGES
bin/dig/dig.c
bin/dig/dighost.c
bin/dig/host.c
bin/dig/include/dig/dig.h
bin/dig/nslookup.c

diff --git a/CHANGES b/CHANGES
index 45a2942054ad529405b0bf111e10d8dfa14a90d2..61fa87a6f2477b2c8d59dd1caf0073faa0f55131 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,8 @@
+
+ 336.  [bug]           "dig -f" used 64 k of memory for each line in
+                       the file.  It now uses much less, though still
+                       proportionally to the file size.
+
  335.  [bug]           named would occasionally attempt recursion when
                        it was disallowed or undesired.
 
index 19146b0e80ea64336ce72e98655d14ce91e585ec..f82193718be78d7c9e462e19ed1b74ea6b2acde7 100644 (file)
@@ -15,7 +15,7 @@
  * SOFTWARE.
  */
 
-/* $Id: dig.c,v 1.51.2.4 2000/07/12 17:56:23 gson Exp $ */
+/* $Id: dig.c,v 1.51.2.5 2000/07/17 19:40:50 gson Exp $ */
 
 #include <config.h>
 #include <stdlib.h>
@@ -1046,7 +1046,7 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
                        strcpy(lookup->rttext, "ptr");
                        strcpy(lookup->rctext, "in");
                        lookup->namespace[0] = 0;
-                       lookup->sendspace[0] = 0;
+                       lookup->sendspace = NULL;
                        lookup->sendmsg = NULL;
                        lookup->name = NULL;
                        lookup->oname = NULL;
@@ -1111,7 +1111,7 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
                        lookup->rttext[0] = 0;
                        lookup->rctext[0] = 0;
                        lookup->namespace[0] = 0;
-                       lookup->sendspace[0] = 0;
+                       lookup->sendspace = NULL;
                        lookup->sendmsg = NULL;
                        lookup->name = NULL;
                        lookup->oname = NULL;
@@ -1188,7 +1188,7 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
                lookup->pending = ISC_FALSE;
                lookup->rctext[0] = 0;
                lookup->namespace[0] = 0;
-               lookup->sendspace[0] = 0;
+               lookup->sendspace = NULL;
                lookup->sendmsg = NULL;
                lookup->name = NULL;
                lookup->oname = NULL;
index cfcc0fc143defa2bdf04f180154abdffb8e20a9d..b523997deb1c03382effac7639112691241c03c1 100644 (file)
@@ -15,7 +15,7 @@
  * SOFTWARE.
  */
 
-/* $Id: dighost.c,v 1.58.2.5 2000/07/12 00:52:57 gson Exp $ */
+/* $Id: dighost.c,v 1.58.2.6 2000/07/17 19:40:51 gson Exp $ */
 
 /*
  * Notice to programmers:  Do not use this code as an example of how to
@@ -102,7 +102,7 @@ isc_buffer_t *namebuf = NULL;
 dns_tsigkey_t *key = NULL;
 isc_boolean_t validated = ISC_TRUE;
 isc_entropy_t *entp = NULL;
-
+isc_mempool_t *commctx = NULL;
 extern isc_boolean_t isc_mem_debugging;
 isc_boolean_t debugging = ISC_FALSE;
 char *progname = NULL;
@@ -141,7 +141,6 @@ hex_dump(isc_buffer_t *b) {
                printf("\n");
 }
 
-
 void
 fatal(const char *format, ...) {
        va_list args;
@@ -252,7 +251,7 @@ requeue_lookup(dig_lookup_t *lookold, isc_boolean_t servers) {
        strncpy(looknew->rttext, lookold-> rttext, 32);
        strncpy(looknew->rctext, lookold-> rctext, 32);
        looknew->namespace[0] = 0;
-       looknew->sendspace[0] = 0;
+       looknew->sendspace = NULL;
        looknew->sendmsg = NULL;
        looknew->name = NULL;
        looknew->oname = NULL;
@@ -566,6 +565,16 @@ setup_libs(void) {
        result = dst_lib_init(mctx, entp, 0);
        check_result(result, "dst_lib_init");
        is_dst_up = ISC_TRUE;
+
+       result = isc_mempool_create(mctx, COMMSIZE, &commctx);
+       check_result(result, "isc_mempool_create");
+       isc_mempool_setname(commctx, "COMMPOOL");
+       /*
+        * 6 and 2 set as reasonable parameters for 3 or 4 nameserver
+        * systems.
+        */
+       isc_mempool_setfreemax(commctx, 6);
+       isc_mempool_setfillcount(commctx, 2);
 }
 
 static void
@@ -1079,6 +1088,10 @@ setup_lookup(dig_lookup_t *lookup) {
                lookup->querysig = NULL;
        }
 
+       lookup->sendspace = isc_mempool_get(commctx);
+       if (lookup->sendspace == NULL)
+               fatal("memory allocation failure");
+
        debug("starting to render the message");
        isc_buffer_init(&lookup->sendbuf, lookup->sendspace, COMMSIZE);
        result = dns_message_renderbegin(lookup->sendmsg, &lookup->sendbuf);
@@ -1122,6 +1135,9 @@ setup_lookup(dig_lookup_t *lookup) {
                ISC_LIST_INIT(query->recvlist);
                ISC_LIST_INIT(query->lengthlist);
                query->sock = NULL;
+               query->recvspace = isc_mempool_get(commctx);
+               if (query->recvspace == NULL)
+                       fatal("memory allocation failure");
 
                isc_buffer_init(&query->recvbuf, query->recvspace, COMMSIZE);
                isc_buffer_init(&query->lengthbuf, query->lengthspace, 2);
@@ -2148,6 +2164,8 @@ free_lists(void) {
                        if (ISC_LINK_LINKED(&q->lengthbuf, link))
                                ISC_LIST_DEQUEUE(q->lengthlist, &q->lengthbuf,
                                                 link);
+                       INSIST(q->recvspace != NULL);
+                       isc_mempool_put(commctx, q->recvspace);
                        isc_buffer_invalidate(&q->recvbuf);
                        isc_buffer_invalidate(&q->lengthbuf);
                        ptr = q;
@@ -2167,6 +2185,8 @@ free_lists(void) {
                }
                if (l->sendmsg != NULL)
                        dns_message_destroy(&l->sendmsg);
+               if (l->sendspace != NULL)
+                       isc_mempool_put(commctx, l->sendspace);
                if (l->querysig != NULL) {
                        debug("freeing buffer %p", l->querysig);
                        isc_buffer_free(&l->querysig);
@@ -2190,4 +2210,8 @@ free_lists(void) {
                debug("detach from entropy");
                isc_entropy_detach(&entp);
        }
+       if (commctx != NULL) {
+               debug("freeing commctx");
+               isc_mempool_destroy(&commctx);
+       }
 }
index e156880c676b3e127f2728d55e064791c29b57bb..8c2df26aae754b1ab3b870a2cf08cbeca30844d3 100644 (file)
@@ -15,7 +15,7 @@
  * SOFTWARE.
  */
 
-/* $Id: host.c,v 1.29.2.3 2000/07/10 19:11:37 bwelling Exp $ */
+/* $Id: host.c,v 1.29.2.4 2000/07/17 19:40:53 gson Exp $ */
 
 #include <config.h>
 #include <stdlib.h>
@@ -661,7 +661,7 @@ parse_args(isc_boolean_t is_batchfile, int argc, char **argv) {
        strncpy(lookup->rttext, querytype, 32);
        strncpy(lookup->rctext, queryclass, 32);
        lookup->namespace[0] = 0;
-       lookup->sendspace[0] = 0;
+       lookup->sendspace = NULL;
        lookup->sendmsg = NULL;
        lookup->name = NULL;
        lookup->oname = NULL;
index 959d30c88a274a0a8281137c8785c0d1e171b07e..270abba9b6ba3752d7241c85c8b79a3fd51ec169 100644 (file)
@@ -15,7 +15,7 @@
  * SOFTWARE.
  */
 
-/* $Id: dig.h,v 1.25.2.2 2000/07/10 19:11:40 bwelling Exp $ */
+/* $Id: dig.h,v 1.25.2.3 2000/07/17 19:40:55 gson Exp $ */
 
 #ifndef DIG_H
 #define DIG_H
@@ -99,7 +99,7 @@ struct dig_lookup {
        isc_buffer_t namebuf;
        isc_buffer_t onamebuf;
        isc_buffer_t sendbuf;
-       char sendspace[COMMSIZE];
+       char *sendspace;
        dns_name_t *name;
        isc_timer_t *timer;
        isc_interval_t interval;
@@ -139,7 +139,7 @@ struct dig_query {
        isc_buffer_t recvbuf,
                lengthbuf,
                slbuf;
-       char recvspace[COMMSIZE],
+       char *recvspace,
                lengthspace[4],
                slspace[4];
        isc_socket_t *sock;
index b4d95e2804cde4c3ff109f04969393a6d88f0b75..34f9517d3fd0c925b32d92148432a2bdd4b9125c 100644 (file)
@@ -15,7 +15,7 @@
  * SOFTWARE.
  */
 
-/* $Id: nslookup.c,v 1.20.2.1 2000/07/10 19:11:38 bwelling Exp $ */
+/* $Id: nslookup.c,v 1.20.2.2 2000/07/17 19:40:54 gson Exp $ */
 
 #include <config.h>
 
@@ -651,7 +651,7 @@ addlookup(char *opt) {
        strncpy (lookup->rttext, deftype, MXNAME);
        strncpy (lookup->rctext, defclass, MXNAME);
        lookup->namespace[0]=0;
-       lookup->sendspace[0]=0;
+       lookup->sendspace = NULL;
        lookup->sendmsg=NULL;
        lookup->name=NULL;
        lookup->oname=NULL;