IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 18, 2006, 1:44:51 PM (20 years ago)
Author:
eugene
Message:

successful implementation of the threaded version of pcontrol

File:
1 edited

Legend:

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

    r8296 r8424  
    11# include "pcontrol.h"
    22
    3 int CheckBusyJob (Job *job) {
     3int CheckBusyJob (Job *job, Host *host) {
    44
    55  int      status;
     
    88  char     string[64];
    99  IOBuffer buffer;
    10   Host    *host;
    1110
    1211  /* we are checking a job which is currently busy.  it has been pulled from the
     
    1413     XXX need to check on state of HOST on return */
    1514
    16   /** must have a valid host : if not? **/
    17   host = (Host *) job[0].host;
     15  ASSERT (host == (Host *) job[0].host, "invalid host");
     16  ASSERT (job  == (Job *) host[0].job, "invalid job");
    1817
    1918  InitIOBuffer (&buffer, 0x100);
     
    2524    case PCLIENT_DOWN:
    2625      HarvestHost (host[0].pid);
    27       UnlinkJobAndHost (job);
     26      // unlink host & job
     27      job[0].host = NULL;
     28      host[0].job = NULL;
    2829      PutHost (host, PCONTROL_HOST_DOWN, STACK_BOTTOM);
    2930      PutJob (job, PCONTROL_JOB_PENDING, STACK_BOTTOM);
     
    3233
    3334    case PCLIENT_HUNG:
     35      HarvestHost (host[0].pid);
     36      // unlink host & job
     37      job[0].host = NULL;
     38      host[0].job = NULL;
     39      PutHost (host, PCONTROL_HOST_DOWN, STACK_BOTTOM);
    3440      PutJobSetState (job, PCONTROL_JOB_BUSY, STACK_BOTTOM, PCONTROL_JOB_HUNG);
    3541      FreeIOBuffer (&buffer);
     
    3743
    3844    case PCLIENT_GOOD:
    39       if (VerboseMode()) gprint (GP_ERR, "message received (CheckBusyJob)\n");
     45      if (VerboseMode()) gprint (GP_ERR, "message received (CheckBusyJob)");
    4046      break;
    4147
    4248    default:
    43       gprint (GP_ERR, "programming error: unknown status for pclient command\n"); 
    44       exit (1);
     49      ABORT ("unknown status for pclient command"); 
    4550  }
    4651
    4752  /** host is up, need to parse message **/
    4853  p = memstr (buffer.buffer, "STATUS", buffer.Nbuffer);
    49   if (p == NULL) {
    50     gprint (GP_ERR, "programming error: missing STATUS in pclient message\n");
    51     exit (1);
    52   }
     54  ASSERT (p != NULL, "missing STATUS in pclient message");
     55
    5356  sscanf (p, "%*s %s", string);
    54   if (!strcmp(string, "NONE")) {
    55     gprint (GP_ERR, "programming error: no current job\n");
    56     exit (1);
    57   }
     57  ASSERT (strcmp(string, "NONE"), "no current job\n");
     58
    5859  /** no status change, return to BUSY stack **/
    5960  if (!strcmp(string, "BUSY")) {
     61    PutHost (host, PCONTROL_HOST_BUSY, STACK_BOTTOM);
    6062    PutJob (job, PCONTROL_JOB_BUSY, STACK_BOTTOM);
    6163    FreeIOBuffer (&buffer);
     
    6769  if (!strcmp(string, "EXIT")) outstate = PCONTROL_JOB_EXIT;
    6870  if (!strcmp(string, "CRASH")) outstate = PCONTROL_JOB_CRASH;
    69   if (outstate == PCONTROL_JOB_BUSY) {
    70     gprint (GP_ERR, "programming error : should not reach here (CheckJob)\n");
    71     exit (1);
    72   }
     71  ASSERT (outstate != PCONTROL_JOB_BUSY, "should not reach here (CheckJob)");
    7372
    7473  /* parse the exit status and sizes of output buffers */
     
    8079  sscanf (p, "%*s %d", &job[0].stderr_size);
    8180
    82   /** job has exited : move to DONE stack (host still BUSY) **/
     81  // job has exited : move to DONE stack
     82  // the host is still BUSY until job output is gathered (int CheckDoneJob)
     83  // don't unlink job and host yet
     84  PutHost (host, PCONTROL_HOST_BUSY, STACK_BOTTOM);
    8385  PutJobSetState (job, PCONTROL_JOB_DONE, STACK_BOTTOM, outstate);
    8486  FreeIOBuffer (&buffer);
    8587  return (TRUE);
    8688}
    87 
    88 /** need to add timeout check here **/
Note: See TracChangeset for help on using the changeset viewer.