IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 17476


Ignore:
Timestamp:
Apr 23, 2008, 1:17:40 PM (18 years ago)
Author:
eugene
Message:

fixed up the pcontrol / pclient interactions

Location:
trunk/Ohana/src/opihi
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/include/pcontrol.h

    r17475 r17476  
    1010  PCONTROL_JOB_PENDING,
    1111  PCONTROL_JOB_BUSY, 
     12  PCONTROL_JOB_RESP, 
    1213  PCONTROL_JOB_HUNG, 
    1314  PCONTROL_JOB_DONE, 
  • trunk/Ohana/src/opihi/pcontrol/CheckBusyJob.c

    r17475 r17476  
    3636      if (DEBUG || VerboseMode()) gprint (GP_ERR, "message received (CheckBusyJob)");
    3737      PutHost (host, PCONTROL_HOST_RESP, STACK_BOTTOM);
    38       PutJob (job, PCONTROL_JOB_BUSY, STACK_BOTTOM);
     38      PutJob (job, PCONTROL_JOB_RESP, STACK_BOTTOM);
    3939      return (TRUE);
    4040
  • trunk/Ohana/src/opihi/pcontrol/CheckDoneHost.c

    r17475 r17476  
    3939  /* job must have assigned host */
    4040  ASSERT (host, "missing host");
    41   ASSERT (host[0].job, "missing job");
    4241  buffer = &host[0].comms_buffer;
    4342
  • trunk/Ohana/src/opihi/pcontrol/CheckRespHost.c

    r17475 r17476  
    2828      }
    2929
     30      // clear the response data
     31      host[0].response_state = PCONTROL_RESP_NONE;
     32      host[0].response = NULL;
     33
    3034      // host has shutdown; harvest the defunct process
    3135      HarvestHost (host[0].pid);
     
    3741      PutHost (host, PCONTROL_HOST_RESP, STACK_BOTTOM);
    3842      if (job) {
    39         PutJob (job, PCONTROL_JOB_BUSY, STACK_BOTTOM);
     43        PutJob (job, PCONTROL_JOB_RESP, STACK_BOTTOM);
    4044      }
    4145      if (DEBUG || VerboseMode()) gprint (GP_ERR, "host %s is not responding\n", host[0].hostname);
     
    5256  switch (host[0].response_state) {
    5357    case PCONTROL_RESP_START_JOB:
     58      if (DEBUG) fprintf (stderr, "PCONTROL_RESP_START_JOB\n");
    5459      status = StartJobResponse (host);
    55       return (status);
     60      break;
    5661
    5762    case PCONTROL_RESP_CHECK_HOST:
     63      if (DEBUG) fprintf (stderr, "PCONTROL_RESP_CHECK_HOST\n");
    5864      status = CheckHostResponse (host);
    59       return (status);
     65      break;
    6066
    6167    case PCONTROL_RESP_CHECK_DONE_HOST:
     68      if (DEBUG) fprintf (stderr, "PCONTROL_RESP_CHECK_DONE_HOST\n");
    6269      status = CheckDoneHostResponse (host);
    63       return (status);
     70      break;
    6471
    6572    case PCONTROL_RESP_CHECK_BUSY_JOB:
     73      if (DEBUG) fprintf (stderr, "PCONTROL_RESP_BUSY_JOB\n");
    6674      status = CheckBusyJobResponse (host);
    67       return (status);
     75      break;
    6876
    6977    case PCONTROL_RESP_KILL_JOB:
     78      if (DEBUG) fprintf (stderr, "PCONTROL_RESP_KILL_JOB\n");
    7079      status = KillJobResponse (host);
    71       return (status);
     80      break;
    7281
    7382    case PCONTROL_RESP_STOP_HOST:
     83      if (DEBUG) fprintf (stderr, "PCONTROL_RESP_STOP_HOST\n");
    7484      status = StopHostResponse (host);
    75       return (status);
     85      break;
    7686
    7787    default:
     
    7989  }
    8090
    81   ABORT ("should not be able to get here");
     91  // we have detected a valid response, clear the response data
     92  host[0].response_state = PCONTROL_RESP_NONE;
     93  host[0].response = NULL;
     94  return (status);
    8295}     
    8396
  • trunk/Ohana/src/opihi/pcontrol/CheckSystem.c

    r17475 r17476  
    264264  struct timeval start, stop;
    265265  int i, Nobject;
    266   Stack *stack;
    267   Host  *host;
    268   float dtime;
    269 
    270   /* Loop through objects on the stack, no more than once. see note above */
    271   stack = GetHostStack (PCONTROL_HOST_RESP);
    272   Nobject = stack[0].Nobject;
    273 
    274   /* always allow at least one test */
    275   gettimeofday (&start, (void *) NULL);
    276   dtime = 0.0;
    277   for (i = 0; (i < Nobject) && (dtime < MaxDelay); i++) {
    278     host = PullStackByLocation (stack, STACK_TOP);
    279     if (host == NULL) break;
     266  Stack *hoststack;
     267  Stack *jobstack;
     268  Host *host;
     269  Job *job;
     270  float dtime;
     271
     272  /* Loop through objects on the stack, no more than once. see note above */
     273  hoststack = GetHostStack (PCONTROL_HOST_RESP);
     274  jobstack = GetJobStack (PCONTROL_JOB_RESP);
     275  Nobject = hoststack[0].Nobject;
     276
     277  /* always allow at least one test */
     278  gettimeofday (&start, (void *) NULL);
     279  dtime = 0.0;
     280  for (i = 0; (i < Nobject) && (dtime < MaxDelay); i++) {
     281    LockStack (jobstack);
     282    host = PullStackByLocation (hoststack, STACK_TOP);
     283    if (host == NULL) {
     284        UnlockStack (jobstack);
     285        break;
     286    }
     287
     288    // if the host has a job, we need to pull the job from its stack
     289    job = (Job *) host[0].job;
     290    if (job != NULL) {
     291        RemoveStackByID (jobstack, job[0].JobID);
     292    }
     293    UnlockStack (jobstack);
     294
    280295    CheckRespHost (host);
    281296    gettimeofday (&stop, (void *) NULL);
  • trunk/Ohana/src/opihi/pcontrol/HostOps.c

    r17475 r17476  
    7878  Stack *stack;
    7979
     80  // fprintf (stderr, "move host %s to %s\n", host[0].hostname, GetHostStackName(StackID));
     81
    8082  stack = GetHostStack (StackID);
    8183  if (stack == NULL) return (FALSE);
  • trunk/Ohana/src/opihi/pcontrol/JobOps.c

    r16472 r17476  
    33Stack *JobPool_Pending;
    44Stack *JobPool_Busy;
     5Stack *JobPool_Resp;
    56Stack *JobPool_Done;
    67Stack *JobPool_Kill;
     
    1112  JobPool_Pending = InitStack ();
    1213  JobPool_Busy    = InitStack ();
     14  JobPool_Resp    = InitStack ();
    1315  JobPool_Done    = InitStack ();
    1416  JobPool_Kill    = InitStack ();
     
    2830  FreeJobStack (JobPool_Pending);
    2931  FreeJobStack (JobPool_Busy   );
     32  FreeJobStack (JobPool_Resp   );
    3033  FreeJobStack (JobPool_Done   );
    3134  FreeJobStack (JobPool_Kill   );
     
    3841    case PCONTROL_JOB_PENDING: return ("PENDING");
    3942    case PCONTROL_JOB_BUSY:    return ("BUSY");
     43    case PCONTROL_JOB_RESP:    return ("RESP");
    4044    case PCONTROL_JOB_DONE:    return ("DONE");
    4145    case PCONTROL_JOB_KILL:    return ("KILL");
     
    5256    case PCONTROL_JOB_PENDING: return (JobPool_Pending);
    5357    case PCONTROL_JOB_BUSY:    return (JobPool_Busy);
     58    case PCONTROL_JOB_RESP:    return (JobPool_Resp);
    5459    case PCONTROL_JOB_DONE:    return (JobPool_Done);
    5560    case PCONTROL_JOB_KILL:    return (JobPool_Kill);
     
    6671  if (!strcasecmp (name, "pending")) return (JobPool_Pending);
    6772  if (!strcasecmp (name, "busy"))    return (JobPool_Busy);
     73  if (!strcasecmp (name, "resp"))    return (JobPool_Resp);
    6874  if (!strcasecmp (name, "done"))    return (JobPool_Done);
    6975  if (!strcasecmp (name, "exit"))    return (JobPool_Exit);
     
    7783  int stat;
    7884  Stack *stack;
     85
     86  // fprintf (stderr, "move job %s to %s\n", job[0].argv[0], GetJobStackName(StackID));
    7987
    8088  stack = GetJobStack (StackID);
     
    115123
    116124  *StackID = PCONTROL_JOB_BUSY;
     125  job = PullJobFromStackByID (*StackID, JobID);
     126  if (job != NULL) return (job);
     127
     128  *StackID = PCONTROL_JOB_RESP;
    117129  job = PullJobFromStackByID (*StackID, JobID);
    118130  if (job != NULL) return (job);
  • trunk/Ohana/src/opihi/pcontrol/KillJob.c

    r17475 r17476  
    2828      FlushIOBuffer (&host[0].comms_buffer);
    2929      PutHost (host, PCONTROL_HOST_RESP, STACK_BOTTOM);
    30       PutJob (job, PCONTROL_JOB_BUSY, STACK_BOTTOM);
     30      PutJob (job, PCONTROL_JOB_RESP, STACK_BOTTOM);
    3131      return (TRUE);
    3232
  • trunk/Ohana/src/opihi/pcontrol/PclientCommand.c

    r17475 r17476  
    66
    77  int status;
    8   IOBuffer buffer;
    98
    109  ASSERT (host != NULL, "host missing");
     
    1211
    1312  // flush the stdout and stderr buffers here
    14   ReadtoIOBuffer (&buffer, host[0].stdout_fd);
    15   FlushIOBuffer (&buffer);
    16   ReadtoIOBuffer (&buffer, host[0].stderr_fd);
    17   FlushIOBuffer (&buffer);
     13  // recycle comms_buffer to minimize page thrashing
     14  ReadtoIOBuffer (&host[0].comms_buffer, host[0].stdout_fd);
     15  FlushIOBuffer (&host[0].comms_buffer);
     16  ReadtoIOBuffer (&host[0].comms_buffer, host[0].stderr_fd);
     17  FlushIOBuffer (&host[0].comms_buffer);
    1818
    1919  /* send command to client (adding on \n) */
     
    3030  host[0].response = response;
    3131  FlushIOBuffer (&host[0].comms_buffer);
     32
     33  // fprintf (stderr, "command: %s\n", command);
    3234
    3335  return (PCLIENT_GOOD);
     
    6769  if (status == -1) return (PCLIENT_HUNG);
    6870
    69   // fprintf (stderr, "buffer.buffer: %s\n", buffer[0].buffer);
    70 
    71   // we have detected a valid response, clear the response data
    72   host[0].response_state = PCONTROL_RESP_NONE;
    73   host[0].response = NULL;
     71  // fprintf (stderr, "response: %s\n", buffer[0].buffer);
    7472
    7573  return (PCLIENT_GOOD);
  • trunk/Ohana/src/opihi/pcontrol/StartJob.c

    r17475 r17476  
    4848      if (VerboseMode()) gprint (GP_ERR, "started job on host %s\n", host[0].hostname); 
    4949      PutHost (host, PCONTROL_HOST_RESP, STACK_BOTTOM);
    50       PutJob (job, PCONTROL_JOB_BUSY, STACK_BOTTOM);
     50      PutJob (job, PCONTROL_JOB_RESP, STACK_BOTTOM);
    5151      return (TRUE);
    5252
Note: See TracChangeset for help on using the changeset viewer.