Index: trunk/Ohana/src/opihi/pantasks/ControllerOps.c
===================================================================
--- trunk/Ohana/src/opihi/pantasks/ControllerOps.c	(revision 19939)
+++ trunk/Ohana/src/opihi/pantasks/ControllerOps.c	(revision 20032)
@@ -159,5 +159,5 @@
   return (TRUE);
 
-  escape:
+escape:
   gprint (GP_ERR, "garbage in pcontrol reponse\n");
   FreeIOBuffer (&buffer);
@@ -411,5 +411,5 @@
   if ((status == -1) && (errno == EPIPE)) {
     StopController ();
-    gprint (GP_ERR, "controller is down, restarting\n");
+    gprint (GP_ERR, "controller is down (pipe closed), restarting\n");
     if (!RestartController ()) {
       return (FALSE);
@@ -420,5 +420,5 @@
   /* for commands which don't return a prompt, don't look for one */
   if (response == NULL) {
-      return (TRUE);
+    return (TRUE);
   }
 
@@ -427,22 +427,25 @@
   status = -1;
   for (j = 0; (status == -1) && (j < 10); j++) {
-      for (i = 0; (i < CONTROLLER_TIMEOUT) && (status != 0) && (line == NULL); i++) {
-	  status = ReadtoIOBuffer (buffer, stdout_cntl);
-	  line = memstr (buffer[0].buffer, response, buffer[0].Nbuffer);
-	  if (status == -1) nanosleep (&request, &remain);
+    for (i = 0; (i < CONTROLLER_TIMEOUT) && (status != 0) && (line == NULL); i++) {
+      status = ReadtoIOBuffer (buffer, stdout_cntl);
+      line = memstr (buffer[0].buffer, response, buffer[0].Nbuffer);
+      if (status == -1) nanosleep (&request, &remain);
+    }
+    if (status ==  0) {
+      StopController ();
+      gprint (GP_ERR, "controller is down (EOF), restarting\n");
+      if (!RestartController ()) {
+	return (FALSE);
       }
-      if (status ==  0) {
-	  StopController ();
-	  gprint (GP_ERR, "controller is down\n");
-	  return (FALSE);
-      }
-      if (status == -1) {
-	  gprint (GP_ERR, "controller is not responding (%d tries)\n", j);
-	  gwrite (buffer[0].buffer, 1, buffer[0].Nbuffer, GP_ERR);
-      }
+      return (FALSE);
+    }
+    if (status == -1) {
+      gprint (GP_ERR, "controller is not responding (%d tries)\n", j);
+      gwrite (buffer[0].buffer, 1, buffer[0].Nbuffer, GP_ERR);
+    }
   }
   if (status == -1) {
-      gprint (GP_ERR, "controller still not responding, giving up\n");
-      return (FALSE);
+    gprint (GP_ERR, "controller still not responding, giving up\n");
+    return (FALSE);
   }
 
@@ -570,5 +573,5 @@
   IOBuffer buffer;
 
-  gprint (GP_ERR, "controller is down, restarting\n");
+  gprint (GP_ERR, "attempting to restart pcontrol\n");
   if (!StartController ()) {
     gprint (GP_ERR, "failure to re-start pcontrol\n");
@@ -579,8 +582,8 @@
 
   // XXX lock the host table? SerialThreadLock ();
-  fprintf (stderr, "controller is down, restarting\n");
+  gprint (GP_ERR, "pcontrol restarted, reloading hosts\n");
   for (i = 0; i < Nhosts; i++) {
-    fprintf (stderr, "controller host add %s -threads %d\n", hosts[i].hostname, hosts[i].max_threads);
     snprintf (command, 256, "host add %s -threads %d\n", hosts[i].hostname, hosts[i].max_threads);
+    gprint (GP_ERR, "sending: %s\n", command);
     status = ControllerCommand (command, CONTROLLER_PROMPT, &buffer);
   }
