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

    r8296 r8424  
    11# include "pcontrol.h"
    22
    3 int KillJob (Job *job) {
     3int KillJob (Job *job, Host *host) {
    44 
    5   Host *host;
    65  IOBuffer buffer;
    76  int status;
    87  char *p;
    98
    10   /** must have a valid host : if not? **/
    11   host = (Host *) job[0].host;
     9  ASSERT (host == (Host *) job[0].host, "invalid host");
     10  ASSERT (job  == (Job *) host[0].job, "invalid job");
    1211
    1312  InitIOBuffer (&buffer, 0x100);
     
    1918    case PCLIENT_DOWN:
    2019      HarvestHost (host[0].pid);
    21       UnlinkJobAndHost (job);
    22       PutJob (job, PCONTROL_JOB_PENDING, STACK_BOTTOM);
     20      // unlink host & job
     21      job[0].host = NULL;
     22      host[0].job = NULL;
    2323      PutHost (host, PCONTROL_HOST_DOWN, STACK_BOTTOM);
     24      PutJob (job, PCONTROL_JOB_CRASH, STACK_BOTTOM);
    2425      FreeIOBuffer (&buffer);
    2526      return (FALSE);
    2627
    2728    case PCLIENT_HUNG:
     29      HarvestHost (host[0].pid);
     30      // unlink host & job
     31      job[0].host = NULL;
     32      host[0].job = NULL;
     33      PutHost (host, PCONTROL_HOST_DOWN, STACK_BOTTOM);
    2834      PutJobSetState (job, PCONTROL_JOB_BUSY, STACK_BOTTOM, PCONTROL_JOB_HUNG);
    2935      FreeIOBuffer (&buffer);
     
    3137
    3238    case PCLIENT_GOOD:
    33       gprint (GP_ERR, "message received (KillJob)\n"); 
     39      if (VerboseMode()) gprint (GP_ERR, "message received (KillJob)\n"); 
    3440      break;
    3541
    3642    default:
    37       gprint (GP_ERR, "unknown status for pclient command: programming error\n"); 
    38       exit (1);
     43      ABORT ("unknown status for pclient command"); 
    3944  }
    4045
    4146  /** host is up, need to parse message **/
    4247  p = memstr (buffer.buffer, "STATUS", buffer.Nbuffer);
    43   if (p == NULL) {
    44     gprint (GP_ERR, "missing STATUS in pclient message : programming error\n");
    45     exit (1);
    46   }
    47   gprint (GP_ERR, "client message: %s\n", buffer.buffer);
     48  ASSERT (p != NULL, "missing STATUS in pclient message");
     49  if (VerboseMode()) gprint (GP_ERR, "client message: %s\n", buffer.buffer);
     50
    4851  sscanf (p, "%*s %d", &status);
    4952  FreeIOBuffer (&buffer);
     
    5255  switch (status) {
    5356    case -1:
    54       gprint (GP_ERR, "programming error (syntax error to pclient)\n");
    55       return (FALSE);
    56       break;
     57      ABORT ("syntax error to pclient");
    5758    case 0:
    5859      gprint (GP_ERR, "failure to kill child process\n");
    59       PutJob (job, PCONTROL_JOB_BUSY, STACK_BOTTOM);
     60      PutHost (host, PCONTROL_HOST_BUSY, STACK_BOTTOM);
     61      PutJob (job, PCONTROL_JOB_KILL, STACK_BOTTOM);
    6062      return (FALSE);
    6163    case 1:
    62       PutJobSetState (job, PCONTROL_JOB_DONE, STACK_BOTTOM, PCONTROL_JOB_CRASH);
     64      gprint (GP_ERR, "killing job %s on %s\n", job[0].argv[0], host[0].hostname);
     65      // unlink host & job
     66      job[0].host = NULL;
     67      host[0].job = NULL;
     68      PutHost (host, PCONTROL_HOST_IDLE, STACK_BOTTOM);
     69      PutJob (job, PCONTROL_JOB_CRASH, STACK_BOTTOM);
    6370      return (TRUE);
    6471    case 2:
    65       gprint (GP_ERR, "programming error (client has no job)\n");
    66       return (FALSE);
     72      ABORT ("client has no job");
    6773  }
    68 
    69   gprint (GP_ERR, "programming error : should not reach here (CheckJob)\n");
    70   exit (1);
     74  ABORT ("should not reach here (KillJob)");
    7175}
    72 
    73 /** XXX need to do something appropriate with host? ***/
Note: See TracChangeset for help on using the changeset viewer.