Changeset 3203 for trunk/Ohana/src/opihi/pcontrol/StartJob.c
- Timestamp:
- Feb 12, 2005, 9:34:34 AM (21 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/pcontrol/StartJob.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/pcontrol/StartJob.c
r3187 r3203 3 3 int StartJob (Job *job) { 4 4 5 int Nline; 6 char *line; 5 int i, Nline, status; 6 char *line, *p; 7 Host *host; 7 8 IOBuffer buffer; 8 9 9 InitIOBuffer (&buffer );10 InitIOBuffer (&buffer, 0x100); 10 11 11 12 /* job must have assigned host */ … … 17 18 18 19 /* construct command line : job arg0 arg1 ... argN\n */ 19 Nline = 10 + argc;20 for (i = 0; i < argc; i++) {20 Nline = 10 + job[0].argc; 21 for (i = 0; i < job[0].argc; i++) { 21 22 Nline += strlen (job[0].argv[i]); 22 23 } … … 24 25 bzero (line, Nline); 25 26 strcpy (line, "job"); 26 for (i = 0; i < argc; i++) {27 for (i = 0; i < job[0].argc; i++) { 27 28 strcat (line, " "); 28 29 strcat (line, job[0].argv[i]); 29 30 } 30 strcat (line, "\n");31 31 32 32 status = PclientCommand (host, line, &buffer); … … 35 35 /* check on success of pclient command */ 36 36 switch (status) { 37 case DOWN:37 case PCLIENT_DOWN: 38 38 fprintf (stderr, "host %s is down\n", host[0].hostname); 39 goto escape; 40 /*** different behavior for ANYHOST, WANTHOST, NEEDHOST ***/ 39 goto failure; 41 40 42 case HUNG:41 case PCLIENT_HUNG: 43 42 fprintf (stderr, "host %s is not responding\n", host[0].hostname); 44 goto escape; 45 /*** should we consider a HUNG host DOWN? ***/ 43 goto failure; 46 44 47 case TRUE:45 case PCLIENT_GOOD: 48 46 fprintf (stderr, "message received\n"); 49 47 break; … … 60 58 exit (1); 61 59 } 62 fscan(p, "%*s %d", &status);60 sscanf (p, "%*s %d", &status); 63 61 switch (status) { 64 62 case -1: 65 63 fprintf (stderr, "error in pclient child\n"); 66 goto escape; 67 /*** should we consider this host DOWN? ***/ 64 goto failure; 68 65 69 66 case -2: … … 77 74 default: 78 75 job[0].pid = status; 79 PutHost (host, PCONTROL_HOST_BUSY, QUEUE_BOTTOM); 80 PutJob (job, PCONTROL_JOB_BUSY, QUEUE_BOTTOM); 76 PutHost (host, PCONTROL_HOST_BUSY, STACK_BOTTOM); 77 PutJob (job, PCONTROL_JOB_BUSY, STACK_BOTTOM); 78 FreeIOBuffer (&buffer); 79 /** need to start timers here **/ 81 80 return (TRUE); 82 81 } … … 85 84 exit (1); 86 85 87 escape: 88 job[0].host = NULL; /* unlink host & job */ 86 failure: 87 /* unlink host & job */ 88 job[0].host = NULL; 89 89 host[0].job = NULL; 90 /*** need to pop host from corresponding queue (BUSY) ***/ 91 PutHost (host, PCONTROL_HOST_DOWN, QUEUE_BOTTOM); 92 PutJob (job, PCONTROL_JOB_PENDING, QUEUE_BOTTOM); 93 FreeBuffer (&buffer); 90 PutHost (host, PCONTROL_HOST_DOWN, STACK_BOTTOM); 91 PutJob (job, PCONTROL_JOB_PENDING, STACK_BOTTOM); 92 FreeIOBuffer (&buffer); 94 93 return (FALSE); 95 94 } 96 95 97 /* 98 this function sends a new command to the pclient. 99 before calling this function: 100 - grab the job from its queue (remove it from that queue with GetQueue) 101 - identify the target host (MUST already be IDLE) 102 - grab the host from its queue (remove it from that queue with GetQueue) 103 - link job and host (job[0].host = host, host[0].job = job) 104 - job must also have a valid command (argc, argv) 105 */ 96 /** note : host and job popped off stacks : can't use UnlinkJobAndHost **/
Note:
See TracChangeset
for help on using the changeset viewer.
