IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Feb 12, 2005, 9:34:34 AM (21 years ago)
Author:
eugene
Message:

pcontrol dev

File:
1 edited

Legend:

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

    r3187 r3203  
    33int StartJob (Job *job) {
    44
    5   int  Nline;
    6   char *line;
     5  int  i, Nline, status;
     6  char *line, *p;
     7  Host *host;
    78  IOBuffer buffer;
    89
    9   InitIOBuffer (&buffer);
     10  InitIOBuffer (&buffer, 0x100);
    1011
    1112  /* job must have assigned host */
     
    1718
    1819  /* construct command line : job arg0 arg1 ... argN\n */
    19   Nline = 10 + argc;
    20   for (i = 0; i < argc; i++) {
     20  Nline = 10 + job[0].argc;
     21  for (i = 0; i < job[0].argc; i++) {
    2122    Nline += strlen (job[0].argv[i]);
    2223  }
     
    2425  bzero (line, Nline);
    2526  strcpy (line, "job");
    26   for (i = 0; i < argc; i++) {
     27  for (i = 0; i < job[0].argc; i++) {
    2728    strcat (line, " ");
    2829    strcat (line, job[0].argv[i]);
    2930  }
    30   strcat (line, "\n");
    3131
    3232  status = PclientCommand (host, line, &buffer);
     
    3535  /* check on success of pclient command */
    3636  switch (status) {
    37     case DOWN:
     37    case PCLIENT_DOWN:
    3838      fprintf (stderr, "host %s is down\n", host[0].hostname);
    39       goto escape;
    40       /*** different behavior for ANYHOST, WANTHOST, NEEDHOST ***/
     39      goto failure;
    4140
    42     case HUNG:
     41    case PCLIENT_HUNG:
    4342      fprintf (stderr, "host %s is not responding\n", host[0].hostname);
    44       goto escape;
    45       /*** should we consider a HUNG host DOWN? ***/
     43      goto failure;
    4644
    47     case TRUE:
     45    case PCLIENT_GOOD:
    4846      fprintf (stderr, "message received\n"); 
    4947      break;
     
    6058    exit (1);
    6159  }
    62   fscan (p, "%*s %d", &status);
     60  sscanf (p, "%*s %d", &status);
    6361  switch (status) {
    6462    case -1:
    6563      fprintf (stderr, "error in pclient child\n");
    66       goto escape;
    67       /*** should we consider this host DOWN? ***/
     64      goto failure;
    6865
    6966    case -2:
     
    7774    default:
    7875      job[0].pid = status;
    79       PutHost (host, PCONTROL_HOST_BUSY, QUEUE_BOTTOM);
    80       PutJob (job, PCONTROL_JOB_BUSY, QUEUE_BOTTOM);
     76      PutHost (host, PCONTROL_HOST_BUSY, STACK_BOTTOM);
     77      PutJob (job, PCONTROL_JOB_BUSY, STACK_BOTTOM);
     78      FreeIOBuffer (&buffer);
     79      /** need to start timers here **/
    8180      return (TRUE);
    8281  }
     
    8584  exit (1);
    8685
    87 escape:
    88   job[0].host = NULL; /* unlink host & job */
     86failure:
     87  /* unlink host & job */
     88  job[0].host = NULL;
    8989  host[0].job = NULL;
    90   /*** need to pop host from corresponding queue (BUSY) ***/
    91   PutHost (host, PCONTROL_HOST_DOWN, QUEUE_BOTTOM);
    92   PutJob (job, PCONTROL_JOB_PENDING, QUEUE_BOTTOM);
    93   FreeBuffer (&buffer);
     90  PutHost (host, PCONTROL_HOST_DOWN, STACK_BOTTOM);
     91  PutJob (job, PCONTROL_JOB_PENDING, STACK_BOTTOM);
     92  FreeIOBuffer (&buffer);
    9493  return (FALSE);
    9594}
    9695
    97 /*
    98    this function sends a new command to the pclient.
    99    before calling this function:
    100      - grab the job from its queue (remove it from that queue with GetQueue)
    101      - identify the target host (MUST already be IDLE)
    102      - grab the host from its queue (remove it from that queue with GetQueue)
    103      - link job and host (job[0].host = host, host[0].job = job)
    104      - job must also have a valid command (argc, argv)
    105 */
     96/** note : host and job popped off stacks : can't use UnlinkJobAndHost **/
Note: See TracChangeset for help on using the changeset viewer.