Index: /trunk/Ohana/src/opihi/pcontrol/CheckBusyJob.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/CheckBusyJob.c	(revision 10651)
+++ /trunk/Ohana/src/opihi/pcontrol/CheckBusyJob.c	(revision 10652)
@@ -12,4 +12,7 @@
      JOB_BUSY stack, and is linked to a host in the HOST_BUSY stack.  
      XXX need to check on state of HOST on return */
+
+  ASSERT (job, "job not set");
+  ASSERT (host, "host not set");
 
   ASSERT (host == (Host *) job[0].host, "invalid host");
Index: /trunk/Ohana/src/opihi/pcontrol/CheckDoneHost.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/CheckDoneHost.c	(revision 10651)
+++ /trunk/Ohana/src/opihi/pcontrol/CheckDoneHost.c	(revision 10652)
@@ -6,4 +6,6 @@
   char     *p;
   IOBuffer  buffer;
+
+  ASSERT (host, "host not set");
 
   InitIOBuffer (&buffer, 0x100);
Index: /trunk/Ohana/src/opihi/pcontrol/CheckDoneJob.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/CheckDoneJob.c	(revision 10651)
+++ /trunk/Ohana/src/opihi/pcontrol/CheckDoneJob.c	(revision 10652)
@@ -4,4 +4,7 @@
   
   int success;
+
+  ASSERT (job, "job not set");
+  ASSERT (host, "host not set");
 
   ASSERT (host == (Host *) job[0].host, "invalid host");
Index: /trunk/Ohana/src/opihi/pcontrol/CheckHost.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/CheckHost.c	(revision 10651)
+++ /trunk/Ohana/src/opihi/pcontrol/CheckHost.c	(revision 10652)
@@ -5,4 +5,6 @@
   int status;
   IOBuffer buffer;
+
+  ASSERT (host, "host not set");
 
   if (host[0].job != NULL) return (TRUE);
Index: /trunk/Ohana/src/opihi/pcontrol/CheckIdleHost.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/CheckIdleHost.c	(revision 10651)
+++ /trunk/Ohana/src/opihi/pcontrol/CheckIdleHost.c	(revision 10652)
@@ -7,4 +7,6 @@
   Stack *stack;
   Job *job;
+
+  ASSERT (host, "host not set");
 
   /* if this host has been marked to be turned off, do that and return */
Index: /trunk/Ohana/src/opihi/pcontrol/CheckPoint.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/CheckPoint.c	(revision 10651)
+++ /trunk/Ohana/src/opihi/pcontrol/CheckPoint.c	(revision 10652)
@@ -18,4 +18,5 @@
 # ifdef THREADED
   int status;
+  int Nwait;
 
   // set my lock
@@ -23,4 +24,5 @@
 
   // wait until client thread sets its lock
+  Nwait = 0;
   while (1) {
     status = pthread_mutex_trylock (&client);
@@ -31,4 +33,8 @@
     pthread_mutex_unlock (&client);
     usleep (10000); // wait for client thread to set lock
+    Nwait ++;
+    if (Nwait > 100) {
+      fprintf (stderr, "deadlock?\n");
+    }
   }
   // put in a timeout?  (client thread not spinning...)
Index: /trunk/Ohana/src/opihi/pcontrol/CheckSystem.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/CheckSystem.c	(revision 10651)
+++ /trunk/Ohana/src/opihi/pcontrol/CheckSystem.c	(revision 10652)
@@ -178,4 +178,6 @@
     }
     host = (Host *) job[0].host;
+    ASSERT (host, "host is NULL");
+
     RemoveStackByID (hoststack, host[0].HostID);
     UnlockStack (hoststack);
@@ -215,4 +217,6 @@
     }
     host = (Host *) job[0].host;
+    ASSERT (host, "host is NULL");
+
     RemoveStackByID (hoststack, host[0].HostID);
     UnlockStack (hoststack);
Index: /trunk/Ohana/src/opihi/pcontrol/GetJobOutput.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/GetJobOutput.c	(revision 10651)
+++ /trunk/Ohana/src/opihi/pcontrol/GetJobOutput.c	(revision 10652)
@@ -8,4 +8,8 @@
   char *line;
   struct timespec request, remain;
+
+  ASSERT (cmd, "cmd missing");
+  ASSERT (host, "host missing");
+  ASSERT (buffer, "buffer missing");
 
   /* flush any earlier messages */
Index: /trunk/Ohana/src/opihi/pcontrol/HostOps.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/HostOps.c	(revision 10651)
+++ /trunk/Ohana/src/opihi/pcontrol/HostOps.c	(revision 10652)
@@ -145,89 +145,4 @@
 }
 
-/* find the host by ID in the defined host stacks (don't pull off stack) */
-/* the Find functions are not thread-safe: DROP */
-# if (0) 
-Host *FindHostByID (IDtype HostID, int *StackID) {
-
-  Host *host;
-
-  *StackID = PCONTROL_HOST_IDLE;
-  host = FindHostInStackByID (*StackID, HostID);
-  if (host != NULL) return (host);
-
-  *StackID = PCONTROL_HOST_DOWN;
-  host = FindHostInStackByID (*StackID, HostID);
-  if (host != NULL) return (host);
-
-  *StackID = PCONTROL_HOST_DONE;
-  host = FindHostInStackByID (*StackID, HostID);
-  if (host != NULL) return (host);
-
-  *StackID = PCONTROL_HOST_BUSY;
-  host = FindHostInStackByID (*StackID, HostID);
-  if (host != NULL) return (host);
-
-  *StackID = PCONTROL_HOST_OFF;
-  host = FindHostInStackByID (*StackID, HostID);
-  if (host != NULL) return (host);
-
-  *StackID = -1;
-  return (NULL);
-}
-
-/* find the host by Name in the defined host stacks (don't pull off stack) */
-Host *FindHostByName (char *name, int *StackID) {
-
-  Host *host;
-
-  *StackID = PCONTROL_HOST_IDLE;
-  host = FindHostInStackByName (*StackID, name);
-  if (host != NULL) return (host);
-
-  *StackID = PCONTROL_HOST_DOWN;
-  host = FindHostInStackByName (*StackID, name);
-  if (host != NULL) return (host);
-
-  *StackID = PCONTROL_HOST_DONE;
-  host = FindHostInStackByName (*StackID, name);
-  if (host != NULL) return (host);
-
-  *StackID = PCONTROL_HOST_BUSY;
-  host = FindHostInStackByName (*StackID, name);
-  if (host != NULL) return (host);
-
-  *StackID = PCONTROL_HOST_OFF;
-  host = FindHostInStackByName (*StackID, name);
-  if (host != NULL) return (host);
-
-  *StackID = -1;
-  return (NULL);
-}
-
-Host *FindHostInStackByID (int StackID, IDtype ID) {
-
-  Host *host;
-  Stack *stack;
-
-  stack = GetHostStack (StackID);
-  if (stack == NULL) return (NULL);
-
-  host = FindStackByID (stack, ID);
-  return (host);
-}
-
-Host *FindHostInStackByName (int StackID, char *name) {
-
-  Host *host;
-  Stack *stack;
-
-  stack = GetHostStack (StackID);
-  if (stack == NULL) return (NULL);
-
-  host = FindStackByName (stack, name);
-  return (host);
-}
-# endif
-
 IDtype AddHost (char *hostname) {
 
Index: /trunk/Ohana/src/opihi/pcontrol/JobOps.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/JobOps.c	(revision 10651)
+++ /trunk/Ohana/src/opihi/pcontrol/JobOps.c	(revision 10652)
@@ -130,47 +130,4 @@
   return (job);
 }
-  
-/* the Find functions are not thread-safe: DROP */
-# if (0)
-Job *FindJobByID (IDtype JobID, int *StackID) {
-
-  Job *job;
-
-  *StackID = PCONTROL_JOB_PENDING;
-  job = FindJobInStackByID (*StackID, JobID);
-  if (job != NULL) return (job);
-
-  *StackID = PCONTROL_JOB_BUSY;
-  job = FindJobInStackByID (*StackID, JobID);
-  if (job != NULL) return (job);
-
-  *StackID = PCONTROL_JOB_EXIT;
-  job = FindJobInStackByID (*StackID, JobID);
-  if (job != NULL) return (job);
-
-  *StackID = PCONTROL_JOB_CRASH;
-  job = FindJobInStackByID (*StackID, JobID);
-  if (job != NULL) return (job);
-
-  *StackID = PCONTROL_JOB_DONE;
-  job = FindJobInStackByID (*StackID, JobID);
-  if (job != NULL) return (job);
-
-  return (NULL);
-}
-
-/* remove job from position in stack */
-Job *FindJobInStackByID (int StackID, int ID) {
-
-  Job *job;
-  Stack *stack;
-
-  stack = GetJobStack (StackID);
-  if (stack == NULL) return (NULL);
-
-  job = FindStackByID (stack, ID);
-  return (job);
-}
-# endif
 
 IDtype AddJob (char *hostname, JobMode mode, int timeout, int argc, char **argv) {
Index: /trunk/Ohana/src/opihi/pcontrol/KillJob.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/KillJob.c	(revision 10651)
+++ /trunk/Ohana/src/opihi/pcontrol/KillJob.c	(revision 10652)
@@ -6,4 +6,7 @@
   int status;
   char *p;
+
+  ASSERT (host != NULL, "host missing");
+  ASSERT (job != NULL, "job missing");
 
   ASSERT (host == (Host *) job[0].host, "invalid host");
Index: /trunk/Ohana/src/opihi/pcontrol/PclientCommand.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/PclientCommand.c	(revision 10651)
+++ /trunk/Ohana/src/opihi/pcontrol/PclientCommand.c	(revision 10652)
@@ -8,4 +8,9 @@
   char *line;
   struct timespec request, remain;
+
+  ASSERT (host != NULL, "host missing");
+  ASSERT (buffer != NULL, "buffer missing");
+  ASSERT (command != NULL, "command missing");
+  ASSERT (response != NULL, "response missing");
 
   /* avoid blocking on read, test every 100 usec, up to 50 msec */
Index: /trunk/Ohana/src/opihi/pcontrol/QueueOps.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/QueueOps.c	(revision 10651)
+++ /trunk/Ohana/src/opihi/pcontrol/QueueOps.c	(revision 10652)
@@ -7,4 +7,6 @@
   void *object;
   
+  ASSERT (stack != NULL, "stack missing");
+
   /* STACK_TOP == 0, STACK_BOTTOM == -1 */
   /* this code correctly handles the negative 'where' and Nobject == 0 */
@@ -25,4 +27,6 @@
 
   int i;
+
+  ASSERT (stack != NULL, "stack missing");
 
   /* STACK_TOP == 0, STACK_BOTTOM == -1 */
Index: /trunk/Ohana/src/opihi/pcontrol/ResetJob.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/ResetJob.c	(revision 10651)
+++ /trunk/Ohana/src/opihi/pcontrol/ResetJob.c	(revision 10652)
@@ -8,5 +8,8 @@
 
   /** must have a valid host : if not, move to pending? **/
+  ASSERT (job != NULL, "job missing");
+
   host = (Host *) job[0].host;
+  ASSERT (job != NULL, "host missing");
 
   InitIOBuffer (&buffer, 0x100);
Index: /trunk/Ohana/src/opihi/pcontrol/StackOps.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/StackOps.c	(revision 10651)
+++ /trunk/Ohana/src/opihi/pcontrol/StackOps.c	(revision 10652)
@@ -39,4 +39,5 @@
   int i;
 
+  ASSERT (stack != NULL, "stack not set");
   LockStack (stack);
 
@@ -74,4 +75,5 @@
   void *object;
   
+  ASSERT (stack != NULL, "stack not set");
   LockStack (stack);
 
@@ -98,4 +100,5 @@
   void *object;
 
+  ASSERT (stack != NULL, "stack not set");
   LockStack (stack);
 
@@ -119,4 +122,5 @@
   void *object;
   
+  ASSERT (stack != NULL, "stack not set");
   LockStack (stack);
 
@@ -138,4 +142,6 @@
 
   int i;
+
+  ASSERT (stack != NULL, "stack not set");
 
   if (where < 0) abort();
@@ -159,4 +165,6 @@
   void *object;
   
+  ASSERT (stack != NULL, "stack not set");
+
   for (i = 0; i < stack[0].Nobject; i++) {
     if (stack[0].id[i] != id) continue;
@@ -170,41 +178,7 @@
 }
 
-/* the Find operations are not thread-safe */
-# if (0)
-/* get object from stack which matches name */
-void *FindStackByName (Stack *stack, char *name) {
-
-  int i, j;
-  void *object;
-
-  for (i = 0; i < stack[0].Nobject; i++) {
-    if (strcasecmp (stack[0].name[i], name)) continue;
-
-    /* here is the element of interest */
-    object = stack[0].object[i];
-    return (object);
-  }
-  return (NULL);
-}
-
-/* find object in stack, don't remove */
-void *FindStackByID (Stack *stack, int id) {
-
-  int i, j;
-  void *object;
-  
-  for (i = 0; i < stack[0].Nobject; i++) {
-    if (stack[0].id[i] != id) continue;
-
-    /* here is the element of interest */
-    object = stack[0].object[i];
-    return (object);
-  }
-  return (NULL);
-}
-# endif
-
 void LockStack (Stack *stack) {
 # ifdef THREADED
+  ASSERT (stack != NULL, "stack not set");
   pthread_mutex_lock (&stack[0].mutex);
 # endif
@@ -214,4 +188,5 @@
 void UnlockStack (Stack *stack) {
 # ifdef THREADED
+  ASSERT (stack != NULL, "stack not set");
   pthread_mutex_unlock (&stack[0].mutex);
 # endif
Index: /trunk/Ohana/src/opihi/pcontrol/StartJob.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/StartJob.c	(revision 10651)
+++ /trunk/Ohana/src/opihi/pcontrol/StartJob.c	(revision 10652)
@@ -10,4 +10,6 @@
 
   /* job must have assigned host */
+  ASSERT (job != NULL, "missing job");
+  ASSERT (host != NULL, "missing host");
   ASSERT (host == (Host *) job[0].host, "invalid host");
   ASSERT (job  == (Job *) host[0].job, "invalid job");
Index: /trunk/Ohana/src/opihi/pcontrol/StopHosts.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/StopHosts.c	(revision 10651)
+++ /trunk/Ohana/src/opihi/pcontrol/StopHosts.c	(revision 10652)
@@ -30,4 +30,5 @@
   SetCheckPoint (); // ensure we can find the specified host
   stack = GetHostStack (PCONTROL_HOST_IDLE);
+  ASSERT (stack != NULL, "stack missing");
   Nobject = stack[0].Nobject;
   for (i = 0; i < Nobject; i++) {
@@ -39,4 +40,5 @@
 
   stack = GetHostStack (PCONTROL_HOST_BUSY);
+  ASSERT (stack != NULL, "stack missing");
   Nobject = stack[0].Nobject;
   for (i = 0; i < Nobject; i++) {
@@ -50,4 +52,6 @@
   Nwait = 0;
   stack = GetHostStack (PCONTROL_HOST_IDLE);
+  ASSERT (stack != NULL, "stack missing");
+
   gprint (GP_ERR, "waiting for clients to exit");
   while ((Nwait < 15) && stack[0].Nobject) {
Index: /trunk/Ohana/src/opihi/pcontrol/host.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/host.c	(revision 10651)
+++ /trunk/Ohana/src/opihi/pcontrol/host.c	(revision 10652)
@@ -68,40 +68,4 @@
   }
 
-# if 0
-    host = PullHostFromStackByName (PCONTROL_HOST_IDLE, argv[2]);
-    if (host) {
-      StopHost (host);
-      OffHost (host);
-      ClearCheckPoint ();
-      return (TRUE);
-    }
-    host = PullHostFromStackByName (PCONTROL_HOST_DOWN, argv[2]);
-    if (host) {
-      OffHost (host);
-      ClearCheckPoint ();
-      return (TRUE);
-    }
-    /* XXX the 'markoff' flag is not being checked */
-    host = PullHostFromStackByName (PCONTROL_HOST_BUSY, argv[2]);
-    if (host) {
-      host[0].markoff  = TRUE;
-      PutHost (host, PCONTROL_HOST_BUSY, STACK_BOTTOM);
-      ClearCheckPoint ();
-      return (TRUE);
-    }
-    /* XXX the 'markoff' flag is not being checked */
-    host = PullHostFromStackByName (PCONTROL_HOST_DONE, argv[2]);
-    if (host) {
-      host[0].markoff  = TRUE;
-      PutHost (host, PCONTROL_HOST_DONE, STACK_BOTTOM);
-      ClearCheckPoint ();
-      return (TRUE);
-    }
-    gprint (GP_LOG, "host %s is not found (already off?)\n", argv[2]);
-    ClearCheckPoint ();
-    return (FALSE);
-  }
-# endif
-
   if (!strcasecmp (argv[1], "DELETE")) {
     // a check point is not required: no possible thief
Index: /trunk/Ohana/src/opihi/pcontrol/rconnect.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/rconnect.c	(revision 10651)
+++ /trunk/Ohana/src/opihi/pcontrol/rconnect.c	(revision 10652)
@@ -17,4 +17,9 @@
   IOBuffer buffer;
   struct timespec request, remain;
+
+  ASSERT (command != NULL, "command is NULL");
+  ASSERT (hostname != NULL, "hostname is NULL");
+  ASSERT (shell != NULL, "shell is NULL");
+  ASSERT (stdio != NULL, "stdio is NULL");
 
   bzero (stdin_fd,  2*sizeof(int));
Index: /trunk/Ohana/src/opihi/pcontrol/status.c
===================================================================
--- /trunk/Ohana/src/opihi/pcontrol/status.c	(revision 10651)
+++ /trunk/Ohana/src/opihi/pcontrol/status.c	(revision 10652)
@@ -28,4 +28,5 @@
 
   stack = GetJobStack (Nstack);
+  ASSERT (stack != NULL, "programming error");
 
   LockStack (stack);
@@ -35,4 +36,5 @@
   for (i = 0; i < Nobject; i++) {
     job = stack[0].object[i];
+    ASSERT (job != NULL, "programming error");
     gprint (GP_LOG, "%d  %s  %d  ", i, job[0].hostname, job[0].argc);
     for (j = 0; j < job[0].argc; j++) {
