Changeset 29540 for trunk/Ohana/src/opihi/pcontrol/MachineOps.c
- Timestamp:
- Oct 25, 2010, 12:50:29 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/Ohana/src/opihi/pcontrol/MachineOps.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/opihi/pcontrol/MachineOps.c
r26521 r29540 1 1 # include "pcontrol.h" 2 # define DEBUG 0 2 3 3 4 static int MAX_UNWANTED_HOST_JOBS = 5; … … 107 108 int AddMachineJob (Host *host, Job *job) { 108 109 110 int i; 109 111 Machine *machine; 110 112 … … 114 116 machine[0].NjobsRealhost ++; 115 117 116 // skip jobs that do not have a targeted host 117 if (job[0].hostname == NULL) { 118 return (TRUE); 118 // skip jobs that do not have a targeted host or any xhosts 119 if (!job[0].hostname && !job[0].Nxhosts) { 120 return (TRUE); 121 } 122 123 for (i = 0; i < job[0].Nxhosts; i++) { 124 // find machine matching the xhost name (these count against the unwanted host total) 125 machine = FindMachineByName (job[0].xhosts[i]); // Can this fail? 126 if (!machine) continue; 127 machine[0].NjobsWanthost ++; 119 128 } 120 129 … … 134 143 int DelMachineJob (Host *host, Job *job) { 135 144 145 int i; 136 146 Machine *machine; 137 147 … … 141 151 machine[0].NjobsRealhost --; 142 152 143 // skip jobs that do not have a targeted host 144 if (job[0].hostname == NULL) { 145 return (TRUE); 153 // skip jobs that do not have a targeted host or any xhosts 154 if (!job[0].hostname && !job[0].Nxhosts) { 155 return (TRUE); 156 } 157 158 for (i = 0; i < job[0].Nxhosts; i++) { 159 // find machine matching the xhost name (these count against the unwanted host total) 160 machine = FindMachineByName (job[0].xhosts[i]); // Can this fail? 161 if (!machine) continue; 162 machine[0].NjobsWanthost --; 146 163 } 147 164 … … 175 192 int CheckMachineJobs (Host *host, Job *job) { 176 193 194 int i; 177 195 Machine *machine; 178 196 179 197 machine = FindMachineByName (job[0].hostname); 180 if (machine == NULL) return (TRUE); 181 // fprintf (stderr, "wanthost: %s, Ntotal: %d, Nmax: %d\n", job[0].hostname, machine[0].NjobsWanthost + machine[0].NjobsRealhost, machine[0].Nhosts + MAX_UNWANTED_HOST_JOBS); 182 // if (machine[0].NjobsWanthost + machine[0].NjobsRealhost >= machine[0].Nhosts + MAX_UNWANTED_HOST_JOBS) { 183 if (machine[0].NjobsWanthost >= MAX_UNWANTED_HOST_JOBS) { 184 // fprintf (stderr, "too many outstanding jobs wanting host %s, delay job %s for now\n", job[0].hostname, job[0].argv[0]); 185 return (FALSE); 186 } 198 if (machine) { 199 if (DEBUG) fprintf (stderr, "wanthost: %s, Ntotal: %d, Nmax: %d\n", machine[0].name, machine[0].NjobsWanthost + machine[0].NjobsRealhost, machine[0].Nhosts + MAX_UNWANTED_HOST_JOBS); 200 if (machine[0].NjobsWanthost >= MAX_UNWANTED_HOST_JOBS) { 201 if (DEBUG) fprintf (stderr, "too many outstanding jobs wanting host %s, delay job %s for now\n", machine[0].name, job[0].argv[0]); 202 return (FALSE); 203 } 204 } 205 206 for (i = 0; i < job[0].Nxhosts; i++) { 207 machine = FindMachineByName (job[0].xhosts[i]); 208 if (machine) { 209 if (DEBUG) fprintf (stderr, "xhost: %s, Ntotal: %d, Nmax: %d\n", machine[0].name, machine[0].NjobsWanthost + machine[0].NjobsRealhost, machine[0].Nhosts + MAX_UNWANTED_HOST_JOBS); 210 if (machine[0].NjobsWanthost >= MAX_UNWANTED_HOST_JOBS) { 211 if (DEBUG) fprintf (stderr, "too many outstanding jobs wanting host %s, delay job %s for now\n", machine[0].name, job[0].argv[0]); 212 return (FALSE); 213 } 214 } 215 } 187 216 188 217 machine = FindMachineByName (host[0].hostname); 189 // fprintf (stderr, "realhost: %s, Ntotal: %d, Nmax: %d\n", host[0].hostname, machine[0].NjobsWanthost + machine[0].NjobsRealhost, machine[0].Nhosts + MAX_UNWANTED_HOST_JOBS); 190 if (machine[0].NjobsWanthost >= MAX_UNWANTED_HOST_JOBS) { 191 // fprintf (stderr, "too many outstanding jobs wanting host %s, delay job %s for now\n", job[0].hostname, job[0].argv[0]); 192 return (FALSE); 193 } 218 if (machine) { 219 if (DEBUG) fprintf (stderr, "realhost: %s, Ntotal: %d, Nmax: %d\n", machine[0].name, machine[0].NjobsWanthost + machine[0].NjobsRealhost, machine[0].Nhosts + MAX_UNWANTED_HOST_JOBS); 220 if (machine[0].NjobsWanthost >= MAX_UNWANTED_HOST_JOBS) { 221 if (DEBUG) fprintf (stderr, "too many outstanding jobs wanting host %s, delay job %s for now\n", machine[0].name, job[0].argv[0]); 222 return (FALSE); 223 } 224 } 225 194 226 return (TRUE); 195 227 }
Note:
See TracChangeset
for help on using the changeset viewer.
