Changeset 8424 for trunk/Ohana/src/opihi/pcontrol/CheckBusyJob.c
- Timestamp:
- Aug 18, 2006, 1:44:51 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/pcontrol/CheckBusyJob.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/pcontrol/CheckBusyJob.c
r8296 r8424 1 1 # include "pcontrol.h" 2 2 3 int CheckBusyJob (Job *job ) {3 int CheckBusyJob (Job *job, Host *host) { 4 4 5 5 int status; … … 8 8 char string[64]; 9 9 IOBuffer buffer; 10 Host *host;11 10 12 11 /* we are checking a job which is currently busy. it has been pulled from the … … 14 13 XXX need to check on state of HOST on return */ 15 14 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"); 18 17 19 18 InitIOBuffer (&buffer, 0x100); … … 25 24 case PCLIENT_DOWN: 26 25 HarvestHost (host[0].pid); 27 UnlinkJobAndHost (job); 26 // unlink host & job 27 job[0].host = NULL; 28 host[0].job = NULL; 28 29 PutHost (host, PCONTROL_HOST_DOWN, STACK_BOTTOM); 29 30 PutJob (job, PCONTROL_JOB_PENDING, STACK_BOTTOM); … … 32 33 33 34 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); 34 40 PutJobSetState (job, PCONTROL_JOB_BUSY, STACK_BOTTOM, PCONTROL_JOB_HUNG); 35 41 FreeIOBuffer (&buffer); … … 37 43 38 44 case PCLIENT_GOOD: 39 if (VerboseMode()) gprint (GP_ERR, "message received (CheckBusyJob) \n");45 if (VerboseMode()) gprint (GP_ERR, "message received (CheckBusyJob)"); 40 46 break; 41 47 42 48 default: 43 gprint (GP_ERR, "programming error: unknown status for pclient command\n"); 44 exit (1); 49 ABORT ("unknown status for pclient command"); 45 50 } 46 51 47 52 /** host is up, need to parse message **/ 48 53 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 53 56 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 58 59 /** no status change, return to BUSY stack **/ 59 60 if (!strcmp(string, "BUSY")) { 61 PutHost (host, PCONTROL_HOST_BUSY, STACK_BOTTOM); 60 62 PutJob (job, PCONTROL_JOB_BUSY, STACK_BOTTOM); 61 63 FreeIOBuffer (&buffer); … … 67 69 if (!strcmp(string, "EXIT")) outstate = PCONTROL_JOB_EXIT; 68 70 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)"); 73 72 74 73 /* parse the exit status and sizes of output buffers */ … … 80 79 sscanf (p, "%*s %d", &job[0].stderr_size); 81 80 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); 83 85 PutJobSetState (job, PCONTROL_JOB_DONE, STACK_BOTTOM, outstate); 84 86 FreeIOBuffer (&buffer); 85 87 return (TRUE); 86 88 } 87 88 /** need to add timeout check here **/
Note:
See TracChangeset
for help on using the changeset viewer.
