3e961a6
+  e - Added a new function DIS_tcp_close to the the code. This takes care of a problem
3e961a6
+      where TORQUE memory keeps growing because the read and write buffers associated
3e961a6
+      with each tcparray entry would grow to accommodate incoming and outgoing data
3e961a6
+      but would not shrink.
3e961a6
 
3e961a6
Index: src/include/dis.h
3e961a6
===================================================================
3e961a6
--- src/include/dis.h	(revision 5257)
3e961a6
+++ src/include/dis.h	(revision 5258)
3e961a6
@@ -238,13 +238,15 @@
3e961a6
 
3e961a6
 /* the following routines set/control DIS over tcp */
3e961a6
 
3e961a6
-extern void DIS_tcp_reset (int fd, int rw);
3e961a6
-extern void DIS_tcp_setup (int fd);
3e961a6
-extern int  DIS_tcp_wflush (int fd);
3e961a6
-extern void DIS_tcp_settimeout (long timeout);
3e961a6
-extern int  DIS_tcp_istimeout (int fd);
3e961a6
+void DIS_tcp_reset (int fd, int rw);
3e961a6
+void DIS_tcp_setup (int fd);
3e961a6
+int  DIS_tcp_wflush (int fd);
3e961a6
+void DIS_tcp_settimeout (long timeout);
3e961a6
+int  DIS_tcp_istimeout (int fd);
3e961a6
+void DIS_tcp_close (int fd);
3e961a6
 
3e961a6
 
3e961a6
+
3e961a6
 extern int  PConnTimeout(int);
3e961a6
 
3e961a6
 /* NOTE:  increase THE_BUF_SIZE to 131072 for systems > 5k nodes */
3e961a6
Index: src/lib/Libattr/attr_fn_arst.c
3e961a6
===================================================================
3e961a6
--- src/lib/Libattr/attr_fn_arst.c	(revision 5257)
3e961a6
+++ src/lib/Libattr/attr_fn_arst.c	(revision 5258)
3e961a6
@@ -186,13 +186,14 @@
3e961a6
 
3e961a6
   bksize = (ns - 1) * sizeof(char *) + sizeof(struct array_strings);
3e961a6
 
3e961a6
-  if ((stp = (struct array_strings *)malloc(bksize)) == NULL)
3e961a6
+  if (( patr->at_val.at_arst = (struct array_strings *)malloc(bksize)) == NULL)
3e961a6
     {
3e961a6
     /* FAILURE */
3e961a6
 
3e961a6
     return(PBSE_SYSTEM);
3e961a6
     }
3e961a6
 
3e961a6
+  stp = patr->at_val.at_arst;
3e961a6
   memset(stp, 0, bksize);
3e961a6
 
3e961a6
   stp->as_npointers = ns;
3e961a6
@@ -238,7 +239,7 @@
3e961a6
 
3e961a6
   patr->at_flags |= ATR_VFLAG_SET | ATR_VFLAG_MODIFY;
3e961a6
 
3e961a6
-  patr->at_val.at_arst = stp;
3e961a6
+/*  patr->at_val.at_arst = stp;*/
3e961a6
 
3e961a6
   free(tmpval);
3e961a6
  
3e961a6
Index: src/lib/Libifl/tcp_dis.c
3e961a6
===================================================================
3e961a6
--- src/lib/Libifl/tcp_dis.c	(revision 5257)
3e961a6
+++ src/lib/Libifl/tcp_dis.c	(revision 5258)
3e961a6
@@ -790,9 +790,30 @@
3e961a6
   return;
3e961a6
   }
3e961a6
 
3e961a6
+void DIS_tcp_close(
3e961a6
 
3e961a6
+  int fd)
3e961a6
 
3e961a6
+  {
3e961a6
+  struct tcp_chan *tcp;
3e961a6
 
3e961a6
+  tcp = tcparray[fd];
3e961a6
+  if(tcp != NULL)
3e961a6
+    {
3e961a6
+    if(tcp->readbuf.tdis_thebuf != NULL)
3e961a6
+      free(tcp->readbuf.tdis_thebuf);
3e961a6
+    if(tcp->writebuf.tdis_thebuf != NULL)
3e961a6
+      free(tcp->writebuf.tdis_thebuf);
3e961a6
+
3e961a6
+    free(tcp);
3e961a6
+    tcparray[fd] = NULL;
3e961a6
+    }
3e961a6
+
3e961a6
+  return;
3e961a6
+  }
3e961a6
+
3e961a6
+
3e961a6
+
3e961a6
 /*
3e961a6
  * DIS_tcp_setup - setup supports routines for dis, "data is strings", to
3e961a6
  * use tcp stream I/O.  Also initializes an array of pointers to
3e961a6
Index: src/lib/Libnet/net_server.c
3e961a6
===================================================================
3e961a6
--- src/lib/Libnet/net_server.c	(revision 5257)
3e961a6
+++ src/lib/Libnet/net_server.c	(revision 5258)
3e961a6
@@ -114,6 +114,7 @@
3e961a6
 #include "server_limits.h"
3e961a6
 #include "net_connect.h"
3e961a6
 #include "log.h"
3e961a6
+#include "dis.h" /* DIS_tcp_close */
3e961a6
 
3e961a6
 extern int LOGLEVEL;
3e961a6
 
3e961a6
@@ -718,6 +719,7 @@
3e961a6
   int sd) /* I */
3e961a6
 
3e961a6
   {
3e961a6
+
3e961a6
   if ((sd < 0) || (max_connection <= sd))
3e961a6
     {
3e961a6
     return;
3e961a6
@@ -757,6 +759,9 @@
3e961a6
 
3e961a6
   num_connections--;
3e961a6
 
3e961a6
+  DIS_tcp_close(sd);
3e961a6
+
3e961a6
+
3e961a6
   return;
3e961a6
   }  /* END close_conn() */
3e961a6