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/KillJob.c

    r10661 r17475  
    33int KillJob (Job *job, Host *host) {
    44 
    5   IOBuffer buffer;
    65  int status;
    7   char *p;
    86
    97  ASSERT (host != NULL, "host missing");
    108  ASSERT (job != NULL, "job missing");
    11 
    129  ASSERT (host == (Host *) job[0].host, "invalid host");
    1310  ASSERT (job  == (Job *) host[0].job, "invalid job");
    1411
    15   InitIOBuffer (&buffer, 0x100);
    16 
    17   status = PclientCommand (host, "reset", PCLIENT_PROMPT, &buffer);
     12  status = PclientCommand (host, "reset", PCLIENT_PROMPT, PCONTROL_RESP_KILL_JOB);
    1813
    1914  /* check on success of pclient command */
    2015  switch (status) {
    2116    case PCLIENT_DOWN:
    22       HarvestHost (host[0].pid);
    2317      // unlink host & job
     18      if (VerboseMode()) gprint (GP_ERR, "host %s is down\n", host[0].hostname);
    2419      job[0].host = NULL;
    2520      host[0].job = NULL;
     21      HarvestHost (host[0].pid);
    2622      PutHost (host, PCONTROL_HOST_DOWN, STACK_BOTTOM);
    2723      PutJob (job, PCONTROL_JOB_CRASH, STACK_BOTTOM);
    28       FreeIOBuffer (&buffer);
    2924      return (FALSE);
    3025
    31     case PCLIENT_HUNG:
    32       // don't do anything drastic, just keep trying
    33       // XXX move to which stack??
    34       gprint (GP_ERR, "client is busy, not responding (KillJob)");
    35       FreeIOBuffer (&buffer);
     26    case PCLIENT_GOOD:
     27      if (VerboseMode()) gprint (GP_ERR, "kill job on host %s\n", host[0].hostname); 
     28      FlushIOBuffer (&host[0].comms_buffer);
     29      PutHost (host, PCONTROL_HOST_RESP, STACK_BOTTOM);
     30      PutJob (job, PCONTROL_JOB_BUSY, STACK_BOTTOM);
    3631      return (TRUE);
    37 
    38     case PCLIENT_GOOD:
    39       if (VerboseMode()) gprint (GP_ERR, "message received (KillJob)\n"); 
    40       break;
    4132
    4233    default:
    4334      ABORT ("unknown status for pclient command"); 
    4435  }
     36}
    4537
    46   /** host is up, need to parse message **/
    47   p = memstr (buffer.buffer, "STATUS", buffer.Nbuffer);
     38int KillJobResponse (Host *host) {
     39 
     40  int status;
     41  char *p;
     42  IOBuffer *buffer;
     43  Job *job;
     44
     45  ASSERT (host != NULL, "host missing");
     46  ASSERT (host[0].job, "missing job");
     47  buffer = &host[0].comms_buffer;
     48  job = (Job *) host[0].job;
     49
     50  /** check on response to pclient command **/
     51  p = memstr (buffer[0].buffer, "STATUS", buffer[0].Nbuffer);
    4852  ASSERT (p != NULL, "missing STATUS in pclient message");
    49   if (VerboseMode()) gprint (GP_ERR, "client message: %s\n", buffer.buffer);
     53  if (VerboseMode()) gprint (GP_ERR, "client message: %s\n", buffer[0].buffer);
    5054
    5155  sscanf (p, "%*s %d", &status);
    52   FreeIOBuffer (&buffer);
    5356  gprint (GP_ERR, "client status: %d\n", status);
    5457
     
    6265      return (FALSE);
    6366    case 1:
    64       gprint (GP_ERR, "killing job %s on %s\n", job[0].argv[0], host[0].hostname);
     67      gprint (GP_ERR, "killed job %s on %s\n", job[0].argv[0], host[0].hostname);
    6568      // unlink host & job
    6669      job[0].host = NULL;
Note: See TracChangeset for help on using the changeset viewer.