Changeset 17476
- Timestamp:
- Apr 23, 2008, 1:17:40 PM (18 years ago)
- Location:
- trunk/Ohana/src/opihi
- Files:
-
- 10 edited
-
include/pcontrol.h (modified) (1 diff)
-
pcontrol/CheckBusyJob.c (modified) (1 diff)
-
pcontrol/CheckDoneHost.c (modified) (1 diff)
-
pcontrol/CheckRespHost.c (modified) (4 diffs)
-
pcontrol/CheckSystem.c (modified) (1 diff)
-
pcontrol/HostOps.c (modified) (1 diff)
-
pcontrol/JobOps.c (modified) (8 diffs)
-
pcontrol/KillJob.c (modified) (1 diff)
-
pcontrol/PclientCommand.c (modified) (4 diffs)
-
pcontrol/StartJob.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/include/pcontrol.h
r17475 r17476 10 10 PCONTROL_JOB_PENDING, 11 11 PCONTROL_JOB_BUSY, 12 PCONTROL_JOB_RESP, 12 13 PCONTROL_JOB_HUNG, 13 14 PCONTROL_JOB_DONE, -
trunk/Ohana/src/opihi/pcontrol/CheckBusyJob.c
r17475 r17476 36 36 if (DEBUG || VerboseMode()) gprint (GP_ERR, "message received (CheckBusyJob)"); 37 37 PutHost (host, PCONTROL_HOST_RESP, STACK_BOTTOM); 38 PutJob (job, PCONTROL_JOB_ BUSY, STACK_BOTTOM);38 PutJob (job, PCONTROL_JOB_RESP, STACK_BOTTOM); 39 39 return (TRUE); 40 40 -
trunk/Ohana/src/opihi/pcontrol/CheckDoneHost.c
r17475 r17476 39 39 /* job must have assigned host */ 40 40 ASSERT (host, "missing host"); 41 ASSERT (host[0].job, "missing job");42 41 buffer = &host[0].comms_buffer; 43 42 -
trunk/Ohana/src/opihi/pcontrol/CheckRespHost.c
r17475 r17476 28 28 } 29 29 30 // clear the response data 31 host[0].response_state = PCONTROL_RESP_NONE; 32 host[0].response = NULL; 33 30 34 // host has shutdown; harvest the defunct process 31 35 HarvestHost (host[0].pid); … … 37 41 PutHost (host, PCONTROL_HOST_RESP, STACK_BOTTOM); 38 42 if (job) { 39 PutJob (job, PCONTROL_JOB_ BUSY, STACK_BOTTOM);43 PutJob (job, PCONTROL_JOB_RESP, STACK_BOTTOM); 40 44 } 41 45 if (DEBUG || VerboseMode()) gprint (GP_ERR, "host %s is not responding\n", host[0].hostname); … … 52 56 switch (host[0].response_state) { 53 57 case PCONTROL_RESP_START_JOB: 58 if (DEBUG) fprintf (stderr, "PCONTROL_RESP_START_JOB\n"); 54 59 status = StartJobResponse (host); 55 return (status);60 break; 56 61 57 62 case PCONTROL_RESP_CHECK_HOST: 63 if (DEBUG) fprintf (stderr, "PCONTROL_RESP_CHECK_HOST\n"); 58 64 status = CheckHostResponse (host); 59 return (status);65 break; 60 66 61 67 case PCONTROL_RESP_CHECK_DONE_HOST: 68 if (DEBUG) fprintf (stderr, "PCONTROL_RESP_CHECK_DONE_HOST\n"); 62 69 status = CheckDoneHostResponse (host); 63 return (status);70 break; 64 71 65 72 case PCONTROL_RESP_CHECK_BUSY_JOB: 73 if (DEBUG) fprintf (stderr, "PCONTROL_RESP_BUSY_JOB\n"); 66 74 status = CheckBusyJobResponse (host); 67 return (status);75 break; 68 76 69 77 case PCONTROL_RESP_KILL_JOB: 78 if (DEBUG) fprintf (stderr, "PCONTROL_RESP_KILL_JOB\n"); 70 79 status = KillJobResponse (host); 71 return (status);80 break; 72 81 73 82 case PCONTROL_RESP_STOP_HOST: 83 if (DEBUG) fprintf (stderr, "PCONTROL_RESP_STOP_HOST\n"); 74 84 status = StopHostResponse (host); 75 return (status);85 break; 76 86 77 87 default: … … 79 89 } 80 90 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); 82 95 } 83 96 -
trunk/Ohana/src/opihi/pcontrol/CheckSystem.c
r17475 r17476 264 264 struct timeval start, stop; 265 265 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 280 295 CheckRespHost (host); 281 296 gettimeofday (&stop, (void *) NULL); -
trunk/Ohana/src/opihi/pcontrol/HostOps.c
r17475 r17476 78 78 Stack *stack; 79 79 80 // fprintf (stderr, "move host %s to %s\n", host[0].hostname, GetHostStackName(StackID)); 81 80 82 stack = GetHostStack (StackID); 81 83 if (stack == NULL) return (FALSE); -
trunk/Ohana/src/opihi/pcontrol/JobOps.c
r16472 r17476 3 3 Stack *JobPool_Pending; 4 4 Stack *JobPool_Busy; 5 Stack *JobPool_Resp; 5 6 Stack *JobPool_Done; 6 7 Stack *JobPool_Kill; … … 11 12 JobPool_Pending = InitStack (); 12 13 JobPool_Busy = InitStack (); 14 JobPool_Resp = InitStack (); 13 15 JobPool_Done = InitStack (); 14 16 JobPool_Kill = InitStack (); … … 28 30 FreeJobStack (JobPool_Pending); 29 31 FreeJobStack (JobPool_Busy ); 32 FreeJobStack (JobPool_Resp ); 30 33 FreeJobStack (JobPool_Done ); 31 34 FreeJobStack (JobPool_Kill ); … … 38 41 case PCONTROL_JOB_PENDING: return ("PENDING"); 39 42 case PCONTROL_JOB_BUSY: return ("BUSY"); 43 case PCONTROL_JOB_RESP: return ("RESP"); 40 44 case PCONTROL_JOB_DONE: return ("DONE"); 41 45 case PCONTROL_JOB_KILL: return ("KILL"); … … 52 56 case PCONTROL_JOB_PENDING: return (JobPool_Pending); 53 57 case PCONTROL_JOB_BUSY: return (JobPool_Busy); 58 case PCONTROL_JOB_RESP: return (JobPool_Resp); 54 59 case PCONTROL_JOB_DONE: return (JobPool_Done); 55 60 case PCONTROL_JOB_KILL: return (JobPool_Kill); … … 66 71 if (!strcasecmp (name, "pending")) return (JobPool_Pending); 67 72 if (!strcasecmp (name, "busy")) return (JobPool_Busy); 73 if (!strcasecmp (name, "resp")) return (JobPool_Resp); 68 74 if (!strcasecmp (name, "done")) return (JobPool_Done); 69 75 if (!strcasecmp (name, "exit")) return (JobPool_Exit); … … 77 83 int stat; 78 84 Stack *stack; 85 86 // fprintf (stderr, "move job %s to %s\n", job[0].argv[0], GetJobStackName(StackID)); 79 87 80 88 stack = GetJobStack (StackID); … … 115 123 116 124 *StackID = PCONTROL_JOB_BUSY; 125 job = PullJobFromStackByID (*StackID, JobID); 126 if (job != NULL) return (job); 127 128 *StackID = PCONTROL_JOB_RESP; 117 129 job = PullJobFromStackByID (*StackID, JobID); 118 130 if (job != NULL) return (job); -
trunk/Ohana/src/opihi/pcontrol/KillJob.c
r17475 r17476 28 28 FlushIOBuffer (&host[0].comms_buffer); 29 29 PutHost (host, PCONTROL_HOST_RESP, STACK_BOTTOM); 30 PutJob (job, PCONTROL_JOB_ BUSY, STACK_BOTTOM);30 PutJob (job, PCONTROL_JOB_RESP, STACK_BOTTOM); 31 31 return (TRUE); 32 32 -
trunk/Ohana/src/opihi/pcontrol/PclientCommand.c
r17475 r17476 6 6 7 7 int status; 8 IOBuffer buffer;9 8 10 9 ASSERT (host != NULL, "host missing"); … … 12 11 13 12 // 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); 18 18 19 19 /* send command to client (adding on \n) */ … … 30 30 host[0].response = response; 31 31 FlushIOBuffer (&host[0].comms_buffer); 32 33 // fprintf (stderr, "command: %s\n", command); 32 34 33 35 return (PCLIENT_GOOD); … … 67 69 if (status == -1) return (PCLIENT_HUNG); 68 70 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); 74 72 75 73 return (PCLIENT_GOOD); -
trunk/Ohana/src/opihi/pcontrol/StartJob.c
r17475 r17476 48 48 if (VerboseMode()) gprint (GP_ERR, "started job on host %s\n", host[0].hostname); 49 49 PutHost (host, PCONTROL_HOST_RESP, STACK_BOTTOM); 50 PutJob (job, PCONTROL_JOB_ BUSY, STACK_BOTTOM);50 PutJob (job, PCONTROL_JOB_RESP, STACK_BOTTOM); 51 51 return (TRUE); 52 52
Note:
See TracChangeset
for help on using the changeset viewer.
