Index: trunk/Ohana/src/opihi/pcontrol/CheckIdleHost.c
===================================================================
--- trunk/Ohana/src/opihi/pcontrol/CheckIdleHost.c	(revision 23330)
+++ trunk/Ohana/src/opihi/pcontrol/CheckIdleHost.c	(revision 25872)
@@ -1,5 +1,29 @@
 # include "pcontrol.h"
 
+// The connection to the remote host is only allow to live for MAX_CONNECT_TIME seconds.  We
+// disconnect and reconnect if a remote host has been connected for too long.  This is a
+// (temporary?) work-around for the problem that the remote pclient job tends to grow too large
+// over time.
+
+# define MAX_CONNECT_TIME 36000.0
+
 static FILE *logfile = NULL;
+
+  /* if this host has been connected for too long, disconnect (will automatically reconnect) */
+int CheckResetHost (Host *host) {
+
+  struct timeval now;
+  float dtime;
+
+  /* if this host has been connected for too long, disconnect (will automatically reconnect) */
+  gettimeofday (&now, (void *) NULL);
+  dtime = DTIME (now, host[0].connect_time);
+  if (dtime > MAX_CONNECT_TIME) {
+      if (VerboseMode()) gprint (GP_ERR, "disconnect from %s\n", host[0].hostname);
+      StopHost (host, PCONTROL_HOST_DOWN);
+      return (TRUE);
+  }
+  return FALSE;
+}
 
 /* the supplied host is not on a stack: it cannot be taken by the other thread */
@@ -21,8 +45,13 @@
   if (host[0].markoff) {
     host[0].markoff = FALSE;
-    StopHost (host);
+    StopHost (host, PCONTROL_HOST_OFF);
     return (TRUE);
   }
     
+  /* check if host has been connected for too long */
+  if (CheckResetHost (host)) {
+    return (TRUE);
+  }
+
   /* search the JOB_PENDING stack for an appropriate job */
   stack = GetJobStack (PCONTROL_JOB_PENDING);
