IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 23, 2008, 11:35:39 AM (18 years ago)
Author:
eugene
Message:

split out client command from client response; allow response to return slowly

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/pcontrol/CheckDoneHost.c

    r10668 r17475  
    55 
    66  int       status;
    7   char     *p;
    8   IOBuffer  buffer;
    97
    108  ASSERT (host, "host not set");
    119
    12   InitIOBuffer (&buffer, 0x100);
    13  
    14   status = PclientCommand (host, "reset", PCLIENT_PROMPT, &buffer);
     10  status = PclientCommand (host, "reset", PCLIENT_PROMPT, PCONTROL_RESP_CHECK_DONE_HOST);
    1511
    1612  /* check on success of pclient command */
     
    1814    case PCLIENT_DOWN:
    1915      if (DEBUG || VerboseMode()) gprint (GP_ERR, "host %s is down\n", host[0].hostname);
    20       /* DONE host does not have an incomplete job */
    2116      HarvestHost (host[0].pid);
    2217      PutHost (host, PCONTROL_HOST_DOWN, STACK_BOTTOM);
    23       FreeIOBuffer (&buffer);
    2418      return (FALSE);
     19      /* DONE host does not have an incomplete job */
    2520      // XXX do we need to close the connection?
    2621
    27     case PCLIENT_HUNG:
    28       // don't do anything drastic, just try again later
    29       PutHost (host, PCONTROL_HOST_DONE, STACK_BOTTOM);
    30       if (DEBUG || VerboseMode()) gprint (GP_ERR, "host %s is not responding\n", host[0].hostname);
    31       FreeIOBuffer (&buffer);
    32       return (FALSE);
    33 
    3422    case PCLIENT_GOOD:
    35       if (VerboseMode()) gprint (GP_ERR, "message received (CheckDoneHost)\n"); 
    36       break;
     23      if (VerboseMode()) gprint (GP_ERR, "checking done host %s\n", host[0].hostname); 
     24      PutHost (host, PCONTROL_HOST_RESP, STACK_BOTTOM);
     25      return (TRUE);
    3726
    3827    default:
    3928      ABORT ("unknown status for pclient command"); 
    4029  }
     30  ABORT ("should not reach here (CheckDoneHost)");
     31}
     32
     33int CheckDoneHostResponse (Host *host) {
     34
     35  int status;
     36  char *p;
     37  IOBuffer *buffer;
     38
     39  /* job must have assigned host */
     40  ASSERT (host, "missing host");
     41  ASSERT (host[0].job, "missing job");
     42  buffer = &host[0].comms_buffer;
    4143
    4244  /** successful command, examine result **/
    43   p = memstr (buffer.buffer, "STATUS", buffer.Nbuffer);
     45  p = memstr (buffer[0].buffer, "STATUS", buffer[0].Nbuffer);
    4446  ASSERT (p != NULL, "missing STATUS in pclient message (CheckDoneHost)");
    4547
     
    5254      if (DEBUG || VerboseMode()) gprint (GP_ERR, "reset failed\n");
    5355      PutHost (host, PCONTROL_HOST_DONE, STACK_BOTTOM);
    54       FreeIOBuffer (&buffer);
    5556      return (FALSE);
    5657     
     
    5960      if (DEBUG || VerboseMode()) gprint (GP_ERR, "successful reset\n");
    6061      PutHost (host, PCONTROL_HOST_IDLE, STACK_BOTTOM);
    61       FreeIOBuffer (&buffer);
    6262      return (FALSE);
    6363
     
    6767  ABORT ("should not reach here (CheckDoneHost)");
    6868}
    69 
    70 /** probably need to flush the buffer before the command **/
    71 /** need to add timeout check here **/
Note: See TracChangeset for help on using the changeset viewer.