Changeset 8296 for trunk/Ohana/src/opihi/pcontrol/CheckIdleHost.c
- Timestamp:
- Aug 11, 2006, 4:51:50 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/pcontrol/CheckIdleHost.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/pcontrol/CheckIdleHost.c
r7917 r8296 1 1 # include "pcontrol.h" 2 2 3 /* the supplied host is not on a stack: it cannot be taken by the other thread */ 3 4 int CheckIdleHost (Host *host) { 4 5 … … 7 8 Job *job; 8 9 10 /* search the JOB_PENDING stack for an appropriate job */ 9 11 stack = GetJobStack (PCONTROL_JOB_PENDING); 12 LockStack (stack); 10 13 11 14 /* look for first NEEDHOST matching this host */ … … 18 21 } 19 22 if (strcasecmp (job[0].hostname, host[0].hostname)) continue; 20 LinkJobAndHost (job, host); 23 24 /* we have found an appropriate job; link it to the host and send to StartJob */ 25 job[0].host = (struct Host *) host; 26 host[0].job = (struct Job *) job; 27 28 /* take the job off the stack and unlock the stack */ 29 RemoveStackEntry (stack, i); 30 UnlockStack (stack); 21 31 StartJob (job); 22 32 return (TRUE); … … 26 36 for (i = 0; i < stack[0].Nobject; i++) { 27 37 job = (Job *) stack[0].object[i]; 28 /*** this currently never runs WANTHOST jobs on any other machines ***/29 38 if (job[0].mode != PCONTROL_JOB_WANTHOST) continue; 30 39 if (job[0].hostname == NULL) { … … 33 42 } 34 43 if (strcasecmp (job[0].hostname, host[0].hostname)) continue; 35 LinkJobAndHost (job, host); 44 45 /* we have found an appropriate job; link it to the host and send to StartJob */ 46 job[0].host = (struct Host *) host; 47 host[0].job = (struct Job *) job; 48 49 /* take the job off the stack and unlock the stack */ 50 RemoveStackEntry (stack, i); 51 UnlockStack (stack); 36 52 StartJob (job); 37 53 return (TRUE); … … 42 58 job = (Job *) stack[0].object[i]; 43 59 if (job[0].mode != PCONTROL_JOB_ANYHOST) continue; 44 LinkJobAndHost (job, host); 60 61 /* we have found an appropriate job; link it to the host and send to StartJob */ 62 job[0].host = (struct Host *) host; 63 host[0].job = (struct Job *) job; 64 65 /* take the job off the stack and unlock the stack */ 66 RemoveStackEntry (stack, i); 67 UnlockStack (stack); 45 68 StartJob (job); 46 return (TRUE);69 return (TRUE); 47 70 } 48 /* no jobs for host, but back on IDLE stack */ 71 72 /* no ANYHOST entry, look for first WANTHOST with old time */ 73 /* XXX perhaps I should add this to the conditions for ANYHOST instead of 74 running a separate loop? ie, WANTHOST && time > X == ANYHOST */ 75 for (i = 0; i < stack[0].Nobject; i++) { 76 job = (Job *) stack[0].object[i]; 77 if (job[0].mode != PCONTROL_JOB_WANTHOST) continue; 78 // test the job age and skip if too young 79 80 /* we have found an appropriate job; link it to the host and send to StartJob */ 81 job[0].host = (struct Host *) host; 82 host[0].job = (struct Job *) job; 83 84 /* take the job off the stack and unlock the stack */ 85 RemoveStackEntry (stack, i); 86 UnlockStack (stack); 87 StartJob (job); 88 return (TRUE); 89 } 90 UnlockStack (stack); 91 92 /* no jobs for host, put it back on IDLE stack */ 49 93 PutHost (host, PCONTROL_HOST_IDLE, STACK_BOTTOM); 50 94 return (TRUE);
Note:
See TracChangeset
for help on using the changeset viewer.
