Changeset 8424 for trunk/Ohana/src/opihi/pcontrol/KillJob.c
- Timestamp:
- Aug 18, 2006, 1:44:51 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/pcontrol/KillJob.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/pcontrol/KillJob.c
r8296 r8424 1 1 # include "pcontrol.h" 2 2 3 int KillJob (Job *job ) {3 int KillJob (Job *job, Host *host) { 4 4 5 Host *host;6 5 IOBuffer buffer; 7 6 int status; 8 7 char *p; 9 8 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"); 12 11 13 12 InitIOBuffer (&buffer, 0x100); … … 19 18 case PCLIENT_DOWN: 20 19 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; 23 23 PutHost (host, PCONTROL_HOST_DOWN, STACK_BOTTOM); 24 PutJob (job, PCONTROL_JOB_CRASH, STACK_BOTTOM); 24 25 FreeIOBuffer (&buffer); 25 26 return (FALSE); 26 27 27 28 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); 28 34 PutJobSetState (job, PCONTROL_JOB_BUSY, STACK_BOTTOM, PCONTROL_JOB_HUNG); 29 35 FreeIOBuffer (&buffer); … … 31 37 32 38 case PCLIENT_GOOD: 33 gprint (GP_ERR, "message received (KillJob)\n");39 if (VerboseMode()) gprint (GP_ERR, "message received (KillJob)\n"); 34 40 break; 35 41 36 42 default: 37 gprint (GP_ERR, "unknown status for pclient command: programming error\n"); 38 exit (1); 43 ABORT ("unknown status for pclient command"); 39 44 } 40 45 41 46 /** host is up, need to parse message **/ 42 47 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 48 51 sscanf (p, "%*s %d", &status); 49 52 FreeIOBuffer (&buffer); … … 52 55 switch (status) { 53 56 case -1: 54 gprint (GP_ERR, "programming error (syntax error to pclient)\n"); 55 return (FALSE); 56 break; 57 ABORT ("syntax error to pclient"); 57 58 case 0: 58 59 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); 60 62 return (FALSE); 61 63 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); 63 70 return (TRUE); 64 71 case 2: 65 gprint (GP_ERR, "programming error (client has no job)\n"); 66 return (FALSE); 72 ABORT ("client has no job"); 67 73 } 68 69 gprint (GP_ERR, "programming error : should not reach here (CheckJob)\n"); 70 exit (1); 74 ABORT ("should not reach here (KillJob)"); 71 75 } 72 73 /** XXX need to do something appropriate with host? ***/
Note:
See TracChangeset
for help on using the changeset viewer.
