Changeset 17475 for trunk/Ohana/src/opihi/pcontrol/KillJob.c
- Timestamp:
- Apr 23, 2008, 11:35:39 AM (18 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/pcontrol/KillJob.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/pcontrol/KillJob.c
r10661 r17475 3 3 int KillJob (Job *job, Host *host) { 4 4 5 IOBuffer buffer;6 5 int status; 7 char *p;8 6 9 7 ASSERT (host != NULL, "host missing"); 10 8 ASSERT (job != NULL, "job missing"); 11 12 9 ASSERT (host == (Host *) job[0].host, "invalid host"); 13 10 ASSERT (job == (Job *) host[0].job, "invalid job"); 14 11 15 InitIOBuffer (&buffer, 0x100); 16 17 status = PclientCommand (host, "reset", PCLIENT_PROMPT, &buffer); 12 status = PclientCommand (host, "reset", PCLIENT_PROMPT, PCONTROL_RESP_KILL_JOB); 18 13 19 14 /* check on success of pclient command */ 20 15 switch (status) { 21 16 case PCLIENT_DOWN: 22 HarvestHost (host[0].pid);23 17 // unlink host & job 18 if (VerboseMode()) gprint (GP_ERR, "host %s is down\n", host[0].hostname); 24 19 job[0].host = NULL; 25 20 host[0].job = NULL; 21 HarvestHost (host[0].pid); 26 22 PutHost (host, PCONTROL_HOST_DOWN, STACK_BOTTOM); 27 23 PutJob (job, PCONTROL_JOB_CRASH, STACK_BOTTOM); 28 FreeIOBuffer (&buffer);29 24 return (FALSE); 30 25 31 case PCLIENT_ HUNG:32 // don't do anything drastic, just keep trying33 // XXX move to which stack??34 gprint (GP_ERR, "client is busy, not responding (KillJob)");35 FreeIOBuffer (&buffer);26 case PCLIENT_GOOD: 27 if (VerboseMode()) gprint (GP_ERR, "kill job on host %s\n", host[0].hostname); 28 FlushIOBuffer (&host[0].comms_buffer); 29 PutHost (host, PCONTROL_HOST_RESP, STACK_BOTTOM); 30 PutJob (job, PCONTROL_JOB_BUSY, STACK_BOTTOM); 36 31 return (TRUE); 37 38 case PCLIENT_GOOD:39 if (VerboseMode()) gprint (GP_ERR, "message received (KillJob)\n");40 break;41 32 42 33 default: 43 34 ABORT ("unknown status for pclient command"); 44 35 } 36 } 45 37 46 /** host is up, need to parse message **/ 47 p = memstr (buffer.buffer, "STATUS", buffer.Nbuffer); 38 int KillJobResponse (Host *host) { 39 40 int status; 41 char *p; 42 IOBuffer *buffer; 43 Job *job; 44 45 ASSERT (host != NULL, "host missing"); 46 ASSERT (host[0].job, "missing job"); 47 buffer = &host[0].comms_buffer; 48 job = (Job *) host[0].job; 49 50 /** check on response to pclient command **/ 51 p = memstr (buffer[0].buffer, "STATUS", buffer[0].Nbuffer); 48 52 ASSERT (p != NULL, "missing STATUS in pclient message"); 49 if (VerboseMode()) gprint (GP_ERR, "client message: %s\n", buffer .buffer);53 if (VerboseMode()) gprint (GP_ERR, "client message: %s\n", buffer[0].buffer); 50 54 51 55 sscanf (p, "%*s %d", &status); 52 FreeIOBuffer (&buffer);53 56 gprint (GP_ERR, "client status: %d\n", status); 54 57 … … 62 65 return (FALSE); 63 66 case 1: 64 gprint (GP_ERR, "kill ingjob %s on %s\n", job[0].argv[0], host[0].hostname);67 gprint (GP_ERR, "killed job %s on %s\n", job[0].argv[0], host[0].hostname); 65 68 // unlink host & job 66 69 job[0].host = NULL;
Note:
See TracChangeset
for help on using the changeset viewer.
