author | viric@mandarina |
Fri, 02 Oct 2009 20:42:47 +0200 | |
changeset 280 | d207fb747144 |
parent 267 | 11631dd11ff8 |
child 287 | b3c38ff8f41a |
permissions | -rw-r--r-- |
49 | 1 |
/* |
2 |
Task Spooler - a task queue system for the unix user |
|
267 | 3 |
Copyright (C) 2007-2009 LluĂs Batlle i Rossell |
49 | 4 |
|
5 |
Please find the license in the provided COPYING file. |
|
6 |
*/ |
|
8 | 7 |
#include <stdlib.h> |
44 | 8 |
#include <unistd.h> |
8 | 9 |
#include <stdio.h> |
44 | 10 |
#include <string.h> |
146 | 11 |
#include <sys/time.h> |
12 |
#include <time.h> |
|
32 | 13 |
#include "main.h" |
3 | 14 |
|
219 | 15 |
/* The list will access them */ |
16 |
int busy_slots = 0; |
|
17 |
int max_slots = 1; |
|
8 | 18 |
|
42 | 19 |
struct Notify |
20 |
{ |
|
21 |
int socket; |
|
22 |
int jobid; |
|
23 |
struct Notify *next; |
|
24 |
}; |
|
25 |
||
3 | 26 |
/* Globals */ |
27 |
static struct Job *firstjob = 0; |
|
19
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
28 |
static struct Job *first_finished_job = 0; |
44 | 29 |
static int jobids = 0; |
221
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
30 |
/* This is used for dependencies from jobs |
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
31 |
* already out of the queue */ |
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
32 |
static int last_errorlevel = 0; /* Before the first job, let's consider |
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
33 |
a good previous result */ |
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
34 |
/* We need this to handle well "-d" after a "-nf" run */ |
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
35 |
static int last_finished_jobid; |
3 | 36 |
|
42 | 37 |
static struct Notify *first_notify = 0; |
38 |
||
218 | 39 |
static struct Job * get_job(int jobid); |
40 |
void notify_errorlevel(struct Job *p); |
|
41 |
||
5 | 42 |
static void send_list_line(int s, const char * str) |
43 |
{ |
|
44 |
struct msg m; |
|
45 |
||
21 | 46 |
/* Message */ |
5 | 47 |
m.type = LIST_LINE; |
146 | 48 |
m.u.size = strlen(str) + 1; |
5 | 49 |
|
21 | 50 |
send_msg(s, &m); |
51 |
||
52 |
/* Send the line */ |
|
146 | 53 |
send_bytes(s, str, m.u.size); |
5 | 54 |
} |
55 |
||
53 | 56 |
static void send_urgent_ok(int s) |
57 |
{ |
|
58 |
struct msg m; |
|
59 |
||
60 |
/* Message */ |
|
61 |
m.type = URGENT_OK; |
|
62 |
||
63 |
send_msg(s, &m); |
|
64 |
} |
|
65 |
||
66
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
66 |
static void send_swap_jobs_ok(int s) |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
67 |
{ |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
68 |
struct msg m; |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
69 |
|
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
70 |
/* Message */ |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
71 |
m.type = SWAP_JOBS_OK; |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
72 |
|
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
73 |
send_msg(s, &m); |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
74 |
} |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
75 |
|
120 | 76 |
static struct Job * find_previous_job(const struct Job *final) |
53 | 77 |
{ |
78 |
struct Job *p; |
|
79 |
||
80 |
/* Show Queued or Running jobs */ |
|
81 |
p = firstjob; |
|
82 |
while(p != 0) |
|
83 |
{ |
|
84 |
if (p->next == final) |
|
85 |
return p; |
|
86 |
p = p->next; |
|
87 |
} |
|
88 |
||
89 |
return 0; |
|
90 |
} |
|
91 |
||
22 | 92 |
static struct Job * findjob(int jobid) |
93 |
{ |
|
94 |
struct Job *p; |
|
95 |
||
96 |
/* Show Queued or Running jobs */ |
|
97 |
p = firstjob; |
|
98 |
while(p != 0) |
|
99 |
{ |
|
100 |
if (p->jobid == jobid) |
|
101 |
return p; |
|
102 |
p = p->next; |
|
103 |
} |
|
104 |
||
105 |
return 0; |
|
106 |
} |
|
107 |
||
32 | 108 |
static struct Job * find_finished_job(int jobid) |
109 |
{ |
|
110 |
struct Job *p; |
|
111 |
||
112 |
/* Show Queued or Running jobs */ |
|
113 |
p = first_finished_job; |
|
114 |
while(p != 0) |
|
115 |
{ |
|
116 |
if (p->jobid == jobid) |
|
117 |
return p; |
|
118 |
p = p->next; |
|
119 |
} |
|
120 |
||
121 |
return 0; |
|
122 |
} |
|
123 |
||
259 | 124 |
static void add_notify_errorlevel_to(struct Job *job, int jobid) |
125 |
{ |
|
126 |
int *p; |
|
127 |
int newsize = (job->notify_errorlevel_to_size + 1) |
|
128 |
* sizeof(int); |
|
129 |
p = (int *) realloc(job->notify_errorlevel_to, |
|
130 |
newsize); |
|
131 |
||
132 |
if (p == 0) |
|
133 |
error("Cannot allocate more memory for notify_errorlist_to for jobid %i," |
|
134 |
" having already %i elements", |
|
135 |
job->jobid, job->notify_errorlevel_to_size); |
|
136 |
||
137 |
job->notify_errorlevel_to = p; |
|
138 |
job->notify_errorlevel_to_size += 1; |
|
139 |
job->notify_errorlevel_to[job->notify_errorlevel_to_size - 1] = jobid; |
|
140 |
} |
|
141 |
||
218 | 142 |
void s_mark_job_running(int jobid) |
19
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
143 |
{ |
218 | 144 |
struct Job *p; |
145 |
p = findjob(jobid); |
|
146 |
if (!p) |
|
147 |
error("Cannot mark the jobid %i RUNNING.", jobid); |
|
148 |
p->state = RUNNING; |
|
19
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
149 |
} |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
150 |
|
63 | 151 |
const char * jstate2string(enum Jobstate s) |
19
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
152 |
{ |
120 | 153 |
const char * jobstate; |
19
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
154 |
switch(s) |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
155 |
{ |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
156 |
case QUEUED: |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
157 |
jobstate = "queued"; |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
158 |
break; |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
159 |
case RUNNING: |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
160 |
jobstate = "running"; |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
161 |
break; |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
162 |
case FINISHED: |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
163 |
jobstate = "finished"; |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
164 |
break; |
156 | 165 |
case SKIPPED: |
166 |
jobstate = "skipped"; |
|
167 |
break; |
|
19
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
168 |
} |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
169 |
return jobstate; |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
170 |
} |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
171 |
|
3 | 172 |
void s_list(int s) |
173 |
{ |
|
174 |
struct Job *p; |
|
117 | 175 |
char *buffer; |
3 | 176 |
|
114 | 177 |
/* Times: 0.00/0.00/0.00 - 4+4+4+2 = 14*/ |
117 | 178 |
buffer = joblist_headers(); |
5 | 179 |
send_list_line(s,buffer); |
117 | 180 |
free(buffer); |
3 | 181 |
|
19
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
182 |
/* Show Queued or Running jobs */ |
3 | 183 |
p = firstjob; |
184 |
while(p != 0) |
|
185 |
{ |
|
117 | 186 |
buffer = joblist_line(p); |
5 | 187 |
send_list_line(s,buffer); |
117 | 188 |
free(buffer); |
3 | 189 |
p = p->next; |
190 |
} |
|
19
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
191 |
|
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
192 |
p = first_finished_job; |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
193 |
|
120 | 194 |
/* Show Finished jobs */ |
195 |
while(p != 0) |
|
19
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
196 |
{ |
120 | 197 |
buffer = joblist_line(p); |
198 |
send_list_line(s,buffer); |
|
199 |
free(buffer); |
|
200 |
p = p->next; |
|
19
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
201 |
} |
3 | 202 |
} |
203 |
||
204 |
static struct Job * newjobptr() |
|
205 |
{ |
|
206 |
struct Job *p; |
|
207 |
||
208 |
if (firstjob == 0) |
|
209 |
{ |
|
210 |
firstjob = (struct Job *) malloc(sizeof(*firstjob)); |
|
211 |
firstjob->next = 0; |
|
64 | 212 |
firstjob->output_filename = 0; |
213 |
firstjob->command = 0; |
|
3 | 214 |
return firstjob; |
215 |
} |
|
216 |
||
217 |
p = firstjob; |
|
218 |
while(p->next != 0) |
|
219 |
p = p->next; |
|
220 |
||
221 |
p->next = (struct Job *) malloc(sizeof(*p)); |
|
222 |
p->next->next = 0; |
|
64 | 223 |
p->next->output_filename = 0; |
224 |
p->next->command = 0; |
|
3 | 225 |
|
226 |
return p->next; |
|
227 |
} |
|
228 |
||
218 | 229 |
/* Returns -1 if no last job id found */ |
221
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
230 |
static int find_last_jobid_in_queue(int neglect_jobid) |
218 | 231 |
{ |
232 |
struct Job *p; |
|
233 |
int last_jobid = -1; |
|
234 |
||
235 |
p = firstjob; |
|
236 |
while(p != 0) |
|
237 |
{ |
|
238 |
if (p->jobid != neglect_jobid && |
|
239 |
p->jobid > last_jobid) |
|
240 |
last_jobid = p->jobid; |
|
241 |
p = p->next; |
|
242 |
} |
|
243 |
||
221
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
244 |
return last_jobid; |
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
245 |
} |
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
246 |
|
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
247 |
/* Returns -1 if no last job id found */ |
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
248 |
static int find_last_stored_jobid_finished() |
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
249 |
{ |
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
250 |
struct Job *p; |
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
251 |
int last_jobid = -1; |
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
252 |
|
218 | 253 |
p = first_finished_job; |
254 |
while(p != 0) |
|
255 |
{ |
|
221
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
256 |
if (p->jobid > last_jobid) |
218 | 257 |
last_jobid = p->jobid; |
258 |
p = p->next; |
|
259 |
} |
|
260 |
||
261 |
return last_jobid; |
|
262 |
} |
|
263 |
||
259 | 264 |
/* Returns job id or -1 on error */ |
18 | 265 |
int s_newjob(int s, struct msg *m) |
3 | 266 |
{ |
267 |
struct Job *p; |
|
18 | 268 |
int res; |
3 | 269 |
|
270 |
p = newjobptr(); |
|
271 |
||
272 |
p->jobid = jobids++; |
|
273 |
p->state = QUEUED; |
|
27
886bdb2f4632
Fixed the Output File information in the list.
viric@llimona
parents:
26
diff
changeset
|
274 |
p->store_output = m->u.newjob.store_output; |
55
678ca291d545
Now the '-nf' doesn't leave a job in 'finished' state.
viric@llimona
parents:
54
diff
changeset
|
275 |
p->should_keep_finished = m->u.newjob.should_keep_finished; |
259 | 276 |
p->notify_errorlevel_to = 0; |
277 |
p->notify_errorlevel_to_size = 0; |
|
278 |
p->do_depend = m->u.newjob.do_depend; |
|
279 |
p->depend_on = -1; /* By default. May be overriden in the next conditions */ |
|
280 |
if (m->u.newjob.do_depend == 1) |
|
221
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
281 |
{ |
259 | 282 |
/* Depend on the last queued job. */ |
283 |
||
221
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
284 |
/* As we already have 'p' in the queue, |
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
285 |
* neglect it during the find_last_jobid_in_queue() */ |
259 | 286 |
if (m->u.newjob.depend_on == -1) |
287 |
{ |
|
288 |
p->depend_on = find_last_jobid_in_queue(p->jobid); |
|
289 |
||
290 |
/* We don't trust the last jobid in the queue (running or queued) |
|
291 |
* if it's not the last added job. In that case, let |
|
292 |
* the next control flow handle it as if it could not |
|
293 |
* do_depend on any still queued job. */ |
|
294 |
if (last_finished_jobid > p->depend_on) |
|
295 |
p->depend_on = -1; |
|
221
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
296 |
|
259 | 297 |
/* If it's queued still without result, let it know |
298 |
* its result to p when it finishes. */ |
|
299 |
if (p->depend_on != -1) |
|
300 |
{ |
|
301 |
struct Job *depended_job; |
|
302 |
depended_job = findjob(p->depend_on); |
|
303 |
if (depended_job != 0) |
|
304 |
add_notify_errorlevel_to(depended_job, p->jobid); |
|
305 |
else |
|
306 |
warning("The jobid %i is queued to do_depend on the jobid %i" |
|
307 |
" suddenly non existant in the queue", p->jobid, |
|
308 |
p->depend_on); |
|
309 |
} |
|
310 |
else /* Otherwise take the finished job, or the last_errorlevel */ |
|
311 |
{ |
|
312 |
if (m->u.newjob.depend_on == -1) |
|
313 |
{ |
|
314 |
int ljobid = find_last_stored_jobid_finished(); |
|
315 |
/* If we have a newer result stored, use it */ |
|
316 |
if (last_finished_jobid < ljobid) |
|
317 |
{ |
|
318 |
struct Job *parent; |
|
319 |
parent = find_finished_job(ljobid); |
|
320 |
if (!parent) |
|
321 |
error("jobid %i suddenly disappeared from the finished list", |
|
322 |
ljobid); |
|
323 |
p->dependency_errorlevel = parent->result.errorlevel; |
|
324 |
} |
|
325 |
else |
|
326 |
p->dependency_errorlevel = last_errorlevel; |
|
327 |
} |
|
328 |
} |
|
329 |
} |
|
330 |
else |
|
331 |
{ |
|
332 |
/* The user decided what's the job this new job depends on */ |
|
333 |
struct Job *depended_job; |
|
221
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
334 |
|
259 | 335 |
p->depend_on = m->u.newjob.depend_on; |
336 |
||
221
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
337 |
depended_job = findjob(p->depend_on); |
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
338 |
if (depended_job != 0) |
259 | 339 |
add_notify_errorlevel_to(depended_job, p->jobid); |
221
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
340 |
else |
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
341 |
{ |
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
342 |
struct Job *parent; |
259 | 343 |
parent = find_finished_job(p->depend_on); |
344 |
if (parent) |
|
345 |
{ |
|
346 |
p->dependency_errorlevel = parent->result.errorlevel; |
|
347 |
} |
|
348 |
else |
|
349 |
{ |
|
350 |
/* We consider as if the job not found |
|
351 |
didn't finish well */ |
|
352 |
p->dependency_errorlevel = -1; |
|
353 |
} |
|
221
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
354 |
} |
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
355 |
} |
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
356 |
} |
218 | 357 |
|
18 | 358 |
|
147 | 359 |
pinfo_init(&p->info); |
146 | 360 |
pinfo_set_enqueue_time(&p->info); |
361 |
||
18 | 362 |
/* load the command */ |
363 |
p->command = malloc(m->u.newjob.command_size); |
|
147 | 364 |
if (p->command == 0) |
365 |
error("Cannot allocate memory in s_newjob command_size (%i)", |
|
366 |
m->u.newjob.command_size); |
|
18 | 367 |
res = recv_bytes(s, p->command, m->u.newjob.command_size); |
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
368 |
if (res == -1) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
369 |
error("wrong bytes received"); |
3 | 370 |
|
150 | 371 |
/* load the label */ |
372 |
p->label = 0; |
|
373 |
if (m->u.newjob.label_size > 0) |
|
374 |
{ |
|
375 |
char *ptr; |
|
376 |
ptr = (char *) malloc(m->u.newjob.label_size); |
|
377 |
if (ptr == 0) |
|
378 |
error("Cannot allocate memory in s_newjob env_size(%i)", |
|
379 |
m->u.newjob.env_size); |
|
380 |
res = recv_bytes(s, ptr, m->u.newjob.label_size); |
|
381 |
if (res == -1) |
|
382 |
error("wrong bytes received"); |
|
383 |
p->label = ptr; |
|
384 |
} |
|
385 |
||
147 | 386 |
/* load the info */ |
387 |
if (m->u.newjob.env_size > 0) |
|
388 |
{ |
|
389 |
char *ptr; |
|
390 |
ptr = (char *) malloc(m->u.newjob.env_size); |
|
391 |
if (ptr == 0) |
|
392 |
error("Cannot allocate memory in s_newjob env_size(%i)", |
|
393 |
m->u.newjob.env_size); |
|
394 |
res = recv_bytes(s, ptr, m->u.newjob.env_size); |
|
395 |
if (res == -1) |
|
396 |
error("wrong bytes received"); |
|
397 |
pinfo_addinfo(&p->info, m->u.newjob.env_size+100, |
|
398 |
"Environment:\n%s", ptr); |
|
399 |
free(ptr); |
|
400 |
} |
|
401 |
||
3 | 402 |
return p->jobid; |
403 |
} |
|
404 |
||
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
405 |
/* This assumes the jobid exists */ |
3 | 406 |
void s_removejob(int jobid) |
407 |
{ |
|
408 |
struct Job *p; |
|
409 |
struct Job *newnext; |
|
410 |
||
411 |
if (firstjob->jobid == jobid) |
|
412 |
{ |
|
413 |
struct Job *newfirst; |
|
134
5a6b8bb1f7a8
Fixing two bugs noted in buglist.bug (ts clients not dying on removejob, queue
viric@llimona
parents:
120
diff
changeset
|
414 |
|
3 | 415 |
/* First job is to be removed */ |
416 |
newfirst = firstjob->next; |
|
18 | 417 |
free(firstjob->command); |
64 | 418 |
free(firstjob->output_filename); |
148 | 419 |
pinfo_free(&firstjob->info); |
150 | 420 |
free(firstjob->label); |
3 | 421 |
free(firstjob); |
422 |
firstjob = newfirst; |
|
423 |
return; |
|
424 |
} |
|
425 |
||
426 |
p = firstjob; |
|
427 |
/* Not first job */ |
|
428 |
while (p->next != 0) |
|
429 |
{ |
|
430 |
if (p->next->jobid == jobid) |
|
431 |
break; |
|
432 |
p = p->next; |
|
433 |
} |
|
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
434 |
if (p->next == 0) |
134
5a6b8bb1f7a8
Fixing two bugs noted in buglist.bug (ts clients not dying on removejob, queue
viric@llimona
parents:
120
diff
changeset
|
435 |
error("Job to be removed not found. jobid=%i", jobid); |
3 | 436 |
|
437 |
newnext = p->next->next; |
|
438 |
||
18 | 439 |
free(p->next->command); |
3 | 440 |
free(p->next); |
441 |
p->next = newnext; |
|
442 |
} |
|
8 | 443 |
|
444 |
/* -1 if no one should be run. */ |
|
445 |
int next_run_job() |
|
446 |
{ |
|
218 | 447 |
struct Job *p; |
448 |
||
219 | 449 |
/* busy_slots may be bigger than the maximum slots, |
450 |
* if the user was running many jobs, and suddenly |
|
451 |
* trimmed the maximum slots down. */ |
|
452 |
if (busy_slots >= max_slots) |
|
218 | 453 |
return -1; |
454 |
||
455 |
/* If there are no jobs to run... */ |
|
456 |
if (firstjob == 0) |
|
8 | 457 |
return -1; |
458 |
||
218 | 459 |
/* Look for a runnable task */ |
460 |
p = firstjob; |
|
461 |
while(p != 0) |
|
9 | 462 |
{ |
218 | 463 |
if (p->state == QUEUED) |
464 |
{ |
|
465 |
if (p->depend_on >= 0) |
|
466 |
{ |
|
259 | 467 |
struct Job *do_depend_job = get_job(p->depend_on); |
468 |
/* We won't try to run any job do_depending on an unfinished |
|
218 | 469 |
* job */ |
259 | 470 |
if (do_depend_job != NULL && |
471 |
(do_depend_job->state == QUEUED || do_depend_job->state == RUNNING)) |
|
218 | 472 |
{ |
473 |
/* Next try */ |
|
474 |
p = p->next; |
|
475 |
continue; |
|
476 |
} |
|
477 |
} |
|
478 |
||
479 |
++busy_slots; |
|
480 |
return p->jobid; |
|
481 |
} |
|
482 |
p = p->next; |
|
9 | 483 |
} |
8 | 484 |
|
485 |
return -1; |
|
486 |
} |
|
487 |
||
64 | 488 |
/* Returns 1000 if no limit, The limit otherwise. */ |
489 |
static int get_max_finished_jobs() |
|
490 |
{ |
|
491 |
char *limit; |
|
492 |
||
493 |
limit = getenv("TS_MAXFINISHED"); |
|
494 |
if (limit == NULL) |
|
495 |
return 1000; |
|
496 |
return abs(atoi(limit)); |
|
497 |
} |
|
498 |
||
19
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
499 |
/* Add the job to the finished queue. */ |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
500 |
static void new_finished_job(struct Job *j) |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
501 |
{ |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
502 |
struct Job *p; |
64 | 503 |
int count, max; |
19
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
504 |
|
64 | 505 |
max = get_max_finished_jobs(); |
506 |
count = 0; |
|
507 |
||
508 |
if (first_finished_job == 0 && count < max) |
|
19
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
509 |
{ |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
510 |
first_finished_job = j; |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
511 |
first_finished_job->next = 0; |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
512 |
return; |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
513 |
} |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
514 |
|
64 | 515 |
++count; |
516 |
||
19
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
517 |
p = first_finished_job; |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
518 |
while(p->next != 0) |
64 | 519 |
{ |
19
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
520 |
p = p->next; |
64 | 521 |
++count; |
522 |
} |
|
19
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
523 |
|
64 | 524 |
/* If too many jobs, wipe out the first */ |
525 |
if (count >= max) |
|
526 |
{ |
|
527 |
struct Job *tmp; |
|
528 |
tmp = first_finished_job; |
|
529 |
first_finished_job = first_finished_job->next; |
|
530 |
free(tmp->command); |
|
531 |
free(tmp->output_filename); |
|
148 | 532 |
pinfo_free(&tmp->info); |
150 | 533 |
free(tmp->label); |
64 | 534 |
free(tmp); |
535 |
} |
|
19
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
536 |
p->next = j; |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
537 |
p->next->next = 0; |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
538 |
|
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
539 |
return; |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
540 |
} |
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
541 |
|
252
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
246
diff
changeset
|
542 |
int job_is_running(int jobid) |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
246
diff
changeset
|
543 |
{ |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
246
diff
changeset
|
544 |
struct Job *p; |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
246
diff
changeset
|
545 |
|
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
246
diff
changeset
|
546 |
p = findjob(jobid); |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
246
diff
changeset
|
547 |
if (p == 0) |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
246
diff
changeset
|
548 |
return 0; |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
246
diff
changeset
|
549 |
if (p->state == RUNNING) |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
246
diff
changeset
|
550 |
return 1; |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
246
diff
changeset
|
551 |
return 0; |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
246
diff
changeset
|
552 |
} |
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
246
diff
changeset
|
553 |
|
218 | 554 |
void job_finished(const struct Result *result, int jobid) |
8 | 555 |
{ |
218 | 556 |
struct Job *p; |
557 |
||
558 |
if (busy_slots <= 0) |
|
559 |
error("Wrong state in the server. busy_slots = %i instead of greater than 0", busy_slots); |
|
8 | 560 |
|
218 | 561 |
p = findjob(jobid); |
562 |
if (p == 0) |
|
563 |
error("on jobid %i finished, it doesn't exist", jobid); |
|
8 | 564 |
|
218 | 565 |
if (p->state != RUNNING) |
566 |
error("on jobid %i finished, it is not running but %i", |
|
567 |
jobid, p->state); |
|
19
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
568 |
|
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
569 |
/* Mark state */ |
156 | 570 |
if (result->skipped) |
218 | 571 |
p->state = SKIPPED; |
156 | 572 |
else |
218 | 573 |
p->state = FINISHED; |
574 |
p->result = *result; |
|
221
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
575 |
last_finished_jobid = p->jobid; |
218 | 576 |
notify_errorlevel(p); |
577 |
pinfo_set_end_time(&p->info); |
|
19
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
578 |
|
246
239b28c0cca9
Adding information on the exit status (signal/exit code).
viric@mandarina
parents:
231
diff
changeset
|
579 |
if (p->result.died_by_signal) |
239b28c0cca9
Adding information on the exit status (signal/exit code).
viric@mandarina
parents:
231
diff
changeset
|
580 |
pinfo_addinfo(&p->info, 100, "Exit status: killed by signal %i\n", p->result.signal); |
239b28c0cca9
Adding information on the exit status (signal/exit code).
viric@mandarina
parents:
231
diff
changeset
|
581 |
else |
239b28c0cca9
Adding information on the exit status (signal/exit code).
viric@mandarina
parents:
231
diff
changeset
|
582 |
pinfo_addinfo(&p->info, 100, "Exit status: died with exit code %i\n", p->result.errorlevel); |
239b28c0cca9
Adding information on the exit status (signal/exit code).
viric@mandarina
parents:
231
diff
changeset
|
583 |
|
218 | 584 |
/* Find the pointing node, to |
585 |
* update it removing the finished job. */ |
|
586 |
{ |
|
587 |
struct Job **jpointer = 0; |
|
588 |
struct Job *newfirst = p->next; |
|
589 |
if (firstjob == p) |
|
590 |
jpointer = &firstjob; |
|
591 |
else |
|
592 |
{ |
|
593 |
struct Job *p2; |
|
594 |
p2 = firstjob; |
|
595 |
while(p2 != 0) |
|
596 |
{ |
|
597 |
if (p2->next == p) |
|
598 |
{ |
|
599 |
jpointer = &(p2->next); |
|
600 |
break; |
|
601 |
} |
|
602 |
p2 = p2->next; |
|
603 |
} |
|
604 |
} |
|
19
5efc347cca8d
The finished jobs store the errorlevel, and can be listed.
viric@llimona
parents:
18
diff
changeset
|
605 |
|
218 | 606 |
/* Add it to the finished queue */ |
607 |
if (p->should_keep_finished) |
|
608 |
new_finished_job(p); |
|
8 | 609 |
|
218 | 610 |
/* Remove it from the run queue */ |
611 |
if (jpointer == 0) |
|
612 |
error("Cannot remove a finished job from the " |
|
613 |
"queue list (jobid=%i)", p->jobid); |
|
614 |
||
615 |
*jpointer = newfirst; |
|
616 |
} |
|
617 |
||
618 |
--busy_slots; |
|
8 | 619 |
} |
20
d85b4c0745fa
"-c" added, for clearing the finished tasks' list.
viric@llimona
parents:
19
diff
changeset
|
620 |
|
d85b4c0745fa
"-c" added, for clearing the finished tasks' list.
viric@llimona
parents:
19
diff
changeset
|
621 |
void s_clear_finished() |
d85b4c0745fa
"-c" added, for clearing the finished tasks' list.
viric@llimona
parents:
19
diff
changeset
|
622 |
{ |
d85b4c0745fa
"-c" added, for clearing the finished tasks' list.
viric@llimona
parents:
19
diff
changeset
|
623 |
struct Job *p; |
d85b4c0745fa
"-c" added, for clearing the finished tasks' list.
viric@llimona
parents:
19
diff
changeset
|
624 |
|
22 | 625 |
if (first_finished_job == 0) |
20
d85b4c0745fa
"-c" added, for clearing the finished tasks' list.
viric@llimona
parents:
19
diff
changeset
|
626 |
return; |
22 | 627 |
|
628 |
p = first_finished_job; |
|
629 |
first_finished_job = 0; |
|
20
d85b4c0745fa
"-c" added, for clearing the finished tasks' list.
viric@llimona
parents:
19
diff
changeset
|
630 |
|
64 | 631 |
while (p != 0) |
20
d85b4c0745fa
"-c" added, for clearing the finished tasks' list.
viric@llimona
parents:
19
diff
changeset
|
632 |
{ |
d85b4c0745fa
"-c" added, for clearing the finished tasks' list.
viric@llimona
parents:
19
diff
changeset
|
633 |
struct Job *tmp; |
d85b4c0745fa
"-c" added, for clearing the finished tasks' list.
viric@llimona
parents:
19
diff
changeset
|
634 |
tmp = p->next; |
22 | 635 |
free(p->command); |
636 |
free(p->output_filename); |
|
148 | 637 |
pinfo_free(&p->info); |
150 | 638 |
free(p->label); |
20
d85b4c0745fa
"-c" added, for clearing the finished tasks' list.
viric@llimona
parents:
19
diff
changeset
|
639 |
free(p); |
d85b4c0745fa
"-c" added, for clearing the finished tasks' list.
viric@llimona
parents:
19
diff
changeset
|
640 |
p = tmp; |
d85b4c0745fa
"-c" added, for clearing the finished tasks' list.
viric@llimona
parents:
19
diff
changeset
|
641 |
} |
d85b4c0745fa
"-c" added, for clearing the finished tasks' list.
viric@llimona
parents:
19
diff
changeset
|
642 |
} |
22 | 643 |
|
35 | 644 |
void s_process_runjob_ok(int jobid, char *oname, int pid) |
22 | 645 |
{ |
646 |
struct Job *p; |
|
647 |
p = findjob(jobid); |
|
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
648 |
if (p == 0) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
649 |
error("Job %i already run not found on runjob_ok", jobid); |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
650 |
if (p->state != RUNNING) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
651 |
error("Job %i not running, but %i on runjob_ok", jobid, |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
652 |
p->state); |
22 | 653 |
|
35 | 654 |
p->pid = pid; |
22 | 655 |
p->output_filename = oname; |
146 | 656 |
pinfo_set_start_time(&p->info); |
657 |
} |
|
658 |
||
218 | 659 |
void s_send_runjob(int s, int jobid) |
660 |
{ |
|
661 |
struct msg m; |
|
662 |
struct Job *p; |
|
663 |
||
664 |
p = findjob(jobid); |
|
665 |
if (p == 0) |
|
666 |
error("Job %i was expected to run", jobid); |
|
667 |
||
668 |
||
669 |
m.type = RUNJOB; |
|
670 |
||
671 |
/* TODO |
|
259 | 672 |
* We should make the dependencies update the jobids they're do_depending on. |
218 | 673 |
* Then, on finish, these could set the errorlevel to send to its dependency childs. |
674 |
* We cannot consider that the jobs will leave traces in the finished job list (-nf?) . */ |
|
675 |
||
676 |
m.u.last_errorlevel = p->dependency_errorlevel; |
|
677 |
||
678 |
send_msg(s, &m); |
|
679 |
} |
|
680 |
||
146 | 681 |
void s_job_info(int s, int jobid) |
682 |
{ |
|
683 |
struct Job *p = 0; |
|
684 |
struct msg m; |
|
685 |
||
686 |
if (jobid == -1) |
|
687 |
{ |
|
688 |
/* This means that we want the job info of the running task, or that |
|
689 |
* of the last job run */ |
|
218 | 690 |
if (busy_slots > 0) |
146 | 691 |
{ |
692 |
p = firstjob; |
|
693 |
if (p == 0) |
|
694 |
error("Internal state WAITING, but job not run." |
|
695 |
"firstjob = %x", firstjob); |
|
696 |
} |
|
697 |
else |
|
698 |
{ |
|
699 |
p = first_finished_job; |
|
700 |
if (p == 0) |
|
701 |
{ |
|
702 |
send_list_line(s, "No jobs.\n"); |
|
703 |
return; |
|
704 |
} |
|
705 |
while(p->next != 0) |
|
706 |
p = p->next; |
|
707 |
} |
|
708 |
} else |
|
709 |
{ |
|
154
b1618fe033aa
Fixed a bug on -i, when the job was not running or run. Added Command: in -i.
viric@llimona
parents:
153
diff
changeset
|
710 |
p = firstjob; |
b1618fe033aa
Fixed a bug on -i, when the job was not running or run. Added Command: in -i.
viric@llimona
parents:
153
diff
changeset
|
711 |
while (p != 0 && p->jobid != jobid) |
b1618fe033aa
Fixed a bug on -i, when the job was not running or run. Added Command: in -i.
viric@llimona
parents:
153
diff
changeset
|
712 |
p = p->next; |
b1618fe033aa
Fixed a bug on -i, when the job was not running or run. Added Command: in -i.
viric@llimona
parents:
153
diff
changeset
|
713 |
|
b1618fe033aa
Fixed a bug on -i, when the job was not running or run. Added Command: in -i.
viric@llimona
parents:
153
diff
changeset
|
714 |
/* Look in finished jobs if needed */ |
b1618fe033aa
Fixed a bug on -i, when the job was not running or run. Added Command: in -i.
viric@llimona
parents:
153
diff
changeset
|
715 |
if (p == 0) |
b1618fe033aa
Fixed a bug on -i, when the job was not running or run. Added Command: in -i.
viric@llimona
parents:
153
diff
changeset
|
716 |
{ |
b1618fe033aa
Fixed a bug on -i, when the job was not running or run. Added Command: in -i.
viric@llimona
parents:
153
diff
changeset
|
717 |
p = first_finished_job; |
b1618fe033aa
Fixed a bug on -i, when the job was not running or run. Added Command: in -i.
viric@llimona
parents:
153
diff
changeset
|
718 |
while (p != 0 && p->jobid != jobid) |
b1618fe033aa
Fixed a bug on -i, when the job was not running or run. Added Command: in -i.
viric@llimona
parents:
153
diff
changeset
|
719 |
p = p->next; |
b1618fe033aa
Fixed a bug on -i, when the job was not running or run. Added Command: in -i.
viric@llimona
parents:
153
diff
changeset
|
720 |
} |
146 | 721 |
} |
722 |
||
723 |
if (p == 0) |
|
724 |
{ |
|
725 |
char tmp[50]; |
|
726 |
sprintf(tmp, "Job %i not finished or not running.\n", jobid); |
|
727 |
send_list_line(s, tmp); |
|
728 |
return; |
|
729 |
} |
|
730 |
||
731 |
m.type = INFO_DATA; |
|
732 |
send_msg(s, &m); |
|
733 |
pinfo_dump(&p->info, s); |
|
218 | 734 |
fd_nprintf(s, 100, "Command: %s", (p->depend_on != -1)?"&& ":""); |
154
b1618fe033aa
Fixed a bug on -i, when the job was not running or run. Added Command: in -i.
viric@llimona
parents:
153
diff
changeset
|
735 |
write(s, p->command, strlen(p->command)); |
b1618fe033aa
Fixed a bug on -i, when the job was not running or run. Added Command: in -i.
viric@llimona
parents:
153
diff
changeset
|
736 |
fd_nprintf(s, 100, "\n"); |
146 | 737 |
fd_nprintf(s, 100, "Enqueue time: %s", |
738 |
ctime(&p->info.enqueue_time.tv_sec)); |
|
739 |
if (p->state == RUNNING) |
|
740 |
{ |
|
741 |
fd_nprintf(s, 100, "Start time: %s", |
|
742 |
ctime(&p->info.start_time.tv_sec)); |
|
743 |
fd_nprintf(s, 100, "Time running: %fs\n", |
|
744 |
pinfo_time_until_now(&p->info)); |
|
745 |
} else if (p->state == FINISHED) |
|
746 |
{ |
|
747 |
fd_nprintf(s, 100, "Start time: %s", |
|
748 |
ctime(&p->info.start_time.tv_sec)); |
|
749 |
fd_nprintf(s, 100, "End time: %s", |
|
750 |
ctime(&p->info.end_time.tv_sec)); |
|
751 |
fd_nprintf(s, 100, "Time run: %fs\n", |
|
752 |
pinfo_time_run(&p->info)); |
|
753 |
} |
|
22 | 754 |
} |
32 | 755 |
|
756 |
void s_send_output(int s, int jobid) |
|
757 |
{ |
|
758 |
struct Job *p = 0; |
|
759 |
struct msg m; |
|
760 |
||
761 |
if (jobid == -1) |
|
762 |
{ |
|
146 | 763 |
/* This means that we want the output info of the running task, or that |
32 | 764 |
* of the last job run */ |
218 | 765 |
if (busy_slots > 0) |
32 | 766 |
{ |
767 |
p = firstjob; |
|
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
768 |
if (p == 0) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
769 |
error("Internal state WAITING, but job not run." |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
770 |
"firstjob = %x", firstjob); |
32 | 771 |
} |
772 |
else |
|
773 |
{ |
|
774 |
p = first_finished_job; |
|
775 |
if (p == 0) |
|
776 |
{ |
|
777 |
send_list_line(s, "No jobs.\n"); |
|
778 |
return; |
|
779 |
} |
|
780 |
while(p->next != 0) |
|
781 |
p = p->next; |
|
782 |
} |
|
783 |
} else |
|
784 |
{ |
|
218 | 785 |
p = get_job(jobid); |
225
6c2583ea71eb
Bugfix: Improving the parent bugfix, so it displays a nicer message on SKIPPED
viric@mandarina
parents:
224
diff
changeset
|
786 |
if (p != 0 && p->state != RUNNING |
6c2583ea71eb
Bugfix: Improving the parent bugfix, so it displays a nicer message on SKIPPED
viric@mandarina
parents:
224
diff
changeset
|
787 |
&& p->state != FINISHED |
6c2583ea71eb
Bugfix: Improving the parent bugfix, so it displays a nicer message on SKIPPED
viric@mandarina
parents:
224
diff
changeset
|
788 |
&& p->state != SKIPPED) |
218 | 789 |
p = 0; |
32 | 790 |
} |
791 |
||
792 |
if (p == 0) |
|
793 |
{ |
|
794 |
char tmp[50]; |
|
196
bca29e2a1a86
Fixing a bug related to a message on -t on last job, when it was skipped.
viric@llimona
parents:
190
diff
changeset
|
795 |
if (jobid == -1) |
bca29e2a1a86
Fixing a bug related to a message on -t on last job, when it was skipped.
viric@llimona
parents:
190
diff
changeset
|
796 |
sprintf(tmp, "The last job has not finished or is not running.\n"); |
bca29e2a1a86
Fixing a bug related to a message on -t on last job, when it was skipped.
viric@llimona
parents:
190
diff
changeset
|
797 |
else |
bca29e2a1a86
Fixing a bug related to a message on -t on last job, when it was skipped.
viric@llimona
parents:
190
diff
changeset
|
798 |
sprintf(tmp, "Job %i not finished or not running.\n", jobid); |
32 | 799 |
send_list_line(s, tmp); |
800 |
return; |
|
801 |
} |
|
802 |
||
157 | 803 |
if (p->state == SKIPPED) |
156 | 804 |
{ |
805 |
char tmp[50]; |
|
196
bca29e2a1a86
Fixing a bug related to a message on -t on last job, when it was skipped.
viric@llimona
parents:
190
diff
changeset
|
806 |
if (jobid == -1) |
bca29e2a1a86
Fixing a bug related to a message on -t on last job, when it was skipped.
viric@llimona
parents:
190
diff
changeset
|
807 |
sprintf(tmp, "The last job was skipped due to a dependency.\n"); |
bca29e2a1a86
Fixing a bug related to a message on -t on last job, when it was skipped.
viric@llimona
parents:
190
diff
changeset
|
808 |
|
bca29e2a1a86
Fixing a bug related to a message on -t on last job, when it was skipped.
viric@llimona
parents:
190
diff
changeset
|
809 |
else |
bca29e2a1a86
Fixing a bug related to a message on -t on last job, when it was skipped.
viric@llimona
parents:
190
diff
changeset
|
810 |
sprintf(tmp, "Job %i was skipped due to a dependency.\n", jobid); |
156 | 811 |
send_list_line(s, tmp); |
812 |
return; |
|
813 |
} |
|
814 |
||
32 | 815 |
m.type = ANSWER_OUTPUT; |
816 |
m.u.output.store_output = p->store_output; |
|
35 | 817 |
m.u.output.pid = p->pid; |
153 | 818 |
if (m.u.output.store_output) |
819 |
m.u.output.ofilename_size = strlen(p->output_filename) + 1; |
|
820 |
else |
|
821 |
m.u.output.ofilename_size = 0; |
|
32 | 822 |
send_msg(s, &m); |
823 |
send_bytes(s, p->output_filename, m.u.output.ofilename_size); |
|
824 |
} |
|
41 | 825 |
|
218 | 826 |
void notify_errorlevel(struct Job *p) |
827 |
{ |
|
259 | 828 |
int i; |
829 |
||
221
fed80bc73128
Updating the "-d" behaviour, so it now works well also with "-nf" submitted
viric@mandarina
parents:
219
diff
changeset
|
830 |
last_errorlevel = p->result.errorlevel; |
259 | 831 |
|
832 |
for(i = 0; i < p->notify_errorlevel_to_size; ++i) |
|
218 | 833 |
{ |
834 |
struct Job *notified; |
|
259 | 835 |
notified = get_job(p->notify_errorlevel_to[i]); |
218 | 836 |
if (notified) |
837 |
{ |
|
838 |
notified->dependency_errorlevel = p->result.errorlevel; |
|
839 |
} |
|
840 |
} |
|
841 |
} |
|
842 |
||
134
5a6b8bb1f7a8
Fixing two bugs noted in buglist.bug (ts clients not dying on removejob, queue
viric@llimona
parents:
120
diff
changeset
|
843 |
int s_remove_job(int s, int jobid) |
41 | 844 |
{ |
845 |
struct Job *p = 0; |
|
846 |
struct msg m; |
|
847 |
struct Job *before_p = 0; |
|
848 |
||
849 |
if (jobid == -1) |
|
850 |
{ |
|
851 |
/* Find the last job added */ |
|
852 |
p = firstjob; |
|
853 |
if (p != 0) |
|
854 |
{ |
|
855 |
while (p->next != 0) |
|
856 |
{ |
|
857 |
before_p = p; |
|
858 |
p = p->next; |
|
859 |
} |
|
180 | 860 |
} else |
861 |
{ |
|
862 |
/* last 'finished' */ |
|
863 |
p = first_finished_job; |
|
190 | 864 |
if (p) |
180 | 865 |
{ |
190 | 866 |
while (p->next != 0) |
867 |
{ |
|
868 |
before_p = p; |
|
869 |
p = p->next; |
|
870 |
} |
|
180 | 871 |
} |
41 | 872 |
} |
873 |
} |
|
874 |
else |
|
875 |
{ |
|
876 |
p = firstjob; |
|
877 |
if (p != 0) |
|
878 |
{ |
|
879 |
while (p->next != 0 && p->jobid != jobid) |
|
880 |
{ |
|
881 |
before_p = p; |
|
882 |
p = p->next; |
|
883 |
} |
|
884 |
} |
|
180 | 885 |
|
886 |
/* If not found, look in the 'finished' list */ |
|
887 |
if (p == 0 || p->jobid != jobid) |
|
888 |
{ |
|
889 |
p = first_finished_job; |
|
890 |
if (p != 0) |
|
891 |
{ |
|
892 |
while (p->next != 0 && p->jobid != jobid) |
|
893 |
{ |
|
894 |
before_p = p; |
|
895 |
p = p->next; |
|
896 |
} |
|
227
3570252beade
Bugfix: '-r' has a better behaviour when all the jobs finished.
viric@mandarina
parents:
226
diff
changeset
|
897 |
if (p->jobid != jobid) |
3570252beade
Bugfix: '-r' has a better behaviour when all the jobs finished.
viric@mandarina
parents:
226
diff
changeset
|
898 |
p = 0; |
180 | 899 |
} |
900 |
} |
|
41 | 901 |
} |
902 |
||
227
3570252beade
Bugfix: '-r' has a better behaviour when all the jobs finished.
viric@mandarina
parents:
226
diff
changeset
|
903 |
if (p == 0 || p->state == RUNNING || p == firstjob) |
41 | 904 |
{ |
905 |
char tmp[50]; |
|
906 |
if (jobid == -1) |
|
44 | 907 |
sprintf(tmp, "The last job cannot be removed.\n"); |
41 | 908 |
else |
909 |
sprintf(tmp, "The job %i cannot be removed.\n", jobid); |
|
910 |
send_list_line(s, tmp); |
|
134
5a6b8bb1f7a8
Fixing two bugs noted in buglist.bug (ts clients not dying on removejob, queue
viric@llimona
parents:
120
diff
changeset
|
911 |
return 0; |
41 | 912 |
} |
913 |
||
178
5b64d66a8d89
Fixed awaking the wait_job clients on job removal.
viric@llimona
parents:
176
diff
changeset
|
914 |
/* Tricks for the check_notify_list */ |
5b64d66a8d89
Fixed awaking the wait_job clients on job removal.
viric@llimona
parents:
176
diff
changeset
|
915 |
p->state = FINISHED; |
5b64d66a8d89
Fixed awaking the wait_job clients on job removal.
viric@llimona
parents:
176
diff
changeset
|
916 |
p->result.errorlevel = -1; |
218 | 917 |
notify_errorlevel(p); |
918 |
||
178
5b64d66a8d89
Fixed awaking the wait_job clients on job removal.
viric@llimona
parents:
176
diff
changeset
|
919 |
/* Notify the clients in wait_job */ |
5b64d66a8d89
Fixed awaking the wait_job clients on job removal.
viric@llimona
parents:
176
diff
changeset
|
920 |
check_notify_list(m.u.jobid); |
5b64d66a8d89
Fixed awaking the wait_job clients on job removal.
viric@llimona
parents:
176
diff
changeset
|
921 |
|
180 | 922 |
/* Update the list pointers */ |
923 |
if (p == first_finished_job) |
|
924 |
first_finished_job = p->next; |
|
925 |
else |
|
926 |
before_p->next = p->next; |
|
927 |
||
259 | 928 |
free(p->notify_errorlevel_to); |
64 | 929 |
free(p->command); |
930 |
free(p->output_filename); |
|
146 | 931 |
pinfo_free(&p->info); |
150 | 932 |
free(p->label); |
41 | 933 |
free(p); |
180 | 934 |
|
41 | 935 |
m.type = REMOVEJOB_OK; |
936 |
send_msg(s, &m); |
|
134
5a6b8bb1f7a8
Fixing two bugs noted in buglist.bug (ts clients not dying on removejob, queue
viric@llimona
parents:
120
diff
changeset
|
937 |
return 1; |
41 | 938 |
} |
42 | 939 |
|
940 |
static void add_to_notify_list(int s, int jobid) |
|
941 |
{ |
|
942 |
struct Notify *n; |
|
943 |
struct Notify *new; |
|
944 |
||
195
cbe64953fa1f
Bugfix: the -w and -t only worked if there was a *single* ts process waiting.
viric@mandarina
parents:
190
diff
changeset
|
945 |
new = (struct Notify *) malloc(sizeof(*new)); |
42 | 946 |
|
947 |
new->socket = s; |
|
948 |
new->jobid = jobid; |
|
949 |
new->next = 0; |
|
950 |
||
951 |
n = first_notify; |
|
952 |
if (n == 0) |
|
953 |
{ |
|
954 |
first_notify = new; |
|
955 |
return; |
|
956 |
} |
|
957 |
||
958 |
while(n->next != 0) |
|
959 |
n = n->next; |
|
960 |
||
961 |
n->next = new; |
|
962 |
} |
|
963 |
||
51
aa6e05d77537
'-w' returns the waited errorlevel. Added a testbench.
viric@llimona
parents:
49
diff
changeset
|
964 |
static void send_waitjob_ok(int s, int errorlevel) |
42 | 965 |
{ |
966 |
struct msg m; |
|
967 |
||
968 |
m.type = WAITJOB_OK; |
|
112 | 969 |
m.u.result.errorlevel = errorlevel; |
42 | 970 |
send_msg(s, &m); |
971 |
} |
|
972 |
||
51
aa6e05d77537
'-w' returns the waited errorlevel. Added a testbench.
viric@llimona
parents:
49
diff
changeset
|
973 |
static struct Job * |
aa6e05d77537
'-w' returns the waited errorlevel. Added a testbench.
viric@llimona
parents:
49
diff
changeset
|
974 |
get_job(int jobid) |
42 | 975 |
{ |
976 |
struct Job *j; |
|
977 |
||
978 |
j = findjob(jobid); |
|
979 |
if (j != NULL) |
|
51
aa6e05d77537
'-w' returns the waited errorlevel. Added a testbench.
viric@llimona
parents:
49
diff
changeset
|
980 |
return j; |
42 | 981 |
|
982 |
j = find_finished_job(jobid); |
|
983 |
||
984 |
if (j != NULL) |
|
51
aa6e05d77537
'-w' returns the waited errorlevel. Added a testbench.
viric@llimona
parents:
49
diff
changeset
|
985 |
return j; |
42 | 986 |
|
51
aa6e05d77537
'-w' returns the waited errorlevel. Added a testbench.
viric@llimona
parents:
49
diff
changeset
|
987 |
return 0; |
42 | 988 |
} |
989 |
||
990 |
/* Don't complain, if the socket doesn't exist */ |
|
991 |
void s_remove_notification(int s) |
|
992 |
{ |
|
993 |
struct Notify *n; |
|
994 |
struct Notify *previous; |
|
995 |
n = first_notify; |
|
996 |
while (n != 0 && n->socket != s) |
|
997 |
n = n->next; |
|
176
306890eeeffa
Fixing a bug on s_remove_job, related to -w and dying with signals
viric@llimona
parents:
166
diff
changeset
|
998 |
if (n == 0 || n->socket != s) |
42 | 999 |
return; |
1000 |
||
1001 |
/* Remove the notification */ |
|
1002 |
previous = first_notify; |
|
1003 |
if (n == previous) |
|
1004 |
{ |
|
254
41252d5e85f5
Fixed a bug in the notify list, reported by mark meissonnier.
viric@mandarina
parents:
253
diff
changeset
|
1005 |
first_notify = n->next; |
41252d5e85f5
Fixed a bug in the notify list, reported by mark meissonnier.
viric@mandarina
parents:
253
diff
changeset
|
1006 |
free(n); |
42 | 1007 |
return; |
1008 |
} |
|
1009 |
||
1010 |
/* if not the first... */ |
|
1011 |
while(previous->next != n) |
|
1012 |
previous = previous->next; |
|
1013 |
||
1014 |
previous->next = n->next; |
|
1015 |
free(n); |
|
1016 |
} |
|
1017 |
||
1018 |
/* This is called when a job finishes */ |
|
1019 |
void check_notify_list(int jobid) |
|
1020 |
{ |
|
206
7acb031b40b8
Better managing of notifications on job finish.
viric@llimona
parents:
198
diff
changeset
|
1021 |
struct Notify *n, *tmp; |
51
aa6e05d77537
'-w' returns the waited errorlevel. Added a testbench.
viric@llimona
parents:
49
diff
changeset
|
1022 |
struct Job *j; |
42 | 1023 |
|
1024 |
n = first_notify; |
|
195
cbe64953fa1f
Bugfix: the -w and -t only worked if there was a *single* ts process waiting.
viric@mandarina
parents:
190
diff
changeset
|
1025 |
while (n != 0) |
42 | 1026 |
{ |
206
7acb031b40b8
Better managing of notifications on job finish.
viric@llimona
parents:
198
diff
changeset
|
1027 |
tmp = n; |
7acb031b40b8
Better managing of notifications on job finish.
viric@llimona
parents:
198
diff
changeset
|
1028 |
n = n->next; |
7acb031b40b8
Better managing of notifications on job finish.
viric@llimona
parents:
198
diff
changeset
|
1029 |
if (tmp->jobid == jobid) |
195
cbe64953fa1f
Bugfix: the -w and -t only worked if there was a *single* ts process waiting.
viric@mandarina
parents:
190
diff
changeset
|
1030 |
{ |
cbe64953fa1f
Bugfix: the -w and -t only worked if there was a *single* ts process waiting.
viric@mandarina
parents:
190
diff
changeset
|
1031 |
j = get_job(jobid); |
cbe64953fa1f
Bugfix: the -w and -t only worked if there was a *single* ts process waiting.
viric@mandarina
parents:
190
diff
changeset
|
1032 |
/* If the job finishes, notify the waiter */ |
cbe64953fa1f
Bugfix: the -w and -t only worked if there was a *single* ts process waiting.
viric@mandarina
parents:
190
diff
changeset
|
1033 |
if (j->state == FINISHED || j->state == SKIPPED) |
cbe64953fa1f
Bugfix: the -w and -t only worked if there was a *single* ts process waiting.
viric@mandarina
parents:
190
diff
changeset
|
1034 |
{ |
209
507bd37ab1d3
Bug resolving a pointer when notifying job_ends.
lbatlle@npdl268.bpo.hp.com
parents:
206
diff
changeset
|
1035 |
send_waitjob_ok(tmp->socket, j->result.errorlevel); |
195
cbe64953fa1f
Bugfix: the -w and -t only worked if there was a *single* ts process waiting.
viric@mandarina
parents:
190
diff
changeset
|
1036 |
/* We want to get the next Nofity* before we remove |
cbe64953fa1f
Bugfix: the -w and -t only worked if there was a *single* ts process waiting.
viric@mandarina
parents:
190
diff
changeset
|
1037 |
* the actual 'n'. As s_remove_notification() simply |
cbe64953fa1f
Bugfix: the -w and -t only worked if there was a *single* ts process waiting.
viric@mandarina
parents:
190
diff
changeset
|
1038 |
* removes the element from the linked list, we can |
cbe64953fa1f
Bugfix: the -w and -t only worked if there was a *single* ts process waiting.
viric@mandarina
parents:
190
diff
changeset
|
1039 |
* safely follow on the list from n->next. */ |
cbe64953fa1f
Bugfix: the -w and -t only worked if there was a *single* ts process waiting.
viric@mandarina
parents:
190
diff
changeset
|
1040 |
s_remove_notification(tmp->socket); |
cbe64953fa1f
Bugfix: the -w and -t only worked if there was a *single* ts process waiting.
viric@mandarina
parents:
190
diff
changeset
|
1041 |
} |
cbe64953fa1f
Bugfix: the -w and -t only worked if there was a *single* ts process waiting.
viric@mandarina
parents:
190
diff
changeset
|
1042 |
} |
42 | 1043 |
} |
1044 |
} |
|
1045 |
||
1046 |
void s_wait_job(int s, int jobid) |
|
1047 |
{ |
|
1048 |
struct Job *p = 0; |
|
1049 |
||
1050 |
if (jobid == -1) |
|
1051 |
{ |
|
1052 |
/* Find the last job added */ |
|
1053 |
p = firstjob; |
|
1054 |
||
1055 |
if (p != 0) |
|
1056 |
while (p->next != 0) |
|
1057 |
p = p->next; |
|
1058 |
||
1059 |
/* Look in finished jobs if needed */ |
|
1060 |
if (p == 0) |
|
1061 |
{ |
|
1062 |
p = first_finished_job; |
|
1063 |
if (p != 0) |
|
1064 |
while (p->next != 0) |
|
1065 |
p = p->next; |
|
1066 |
} |
|
1067 |
} |
|
1068 |
else |
|
1069 |
{ |
|
1070 |
p = firstjob; |
|
1071 |
while (p != 0 && p->jobid != jobid) |
|
1072 |
p = p->next; |
|
1073 |
||
1074 |
/* Look in finished jobs if needed */ |
|
1075 |
if (p == 0) |
|
1076 |
{ |
|
1077 |
p = first_finished_job; |
|
1078 |
while (p != 0 && p->jobid != jobid) |
|
1079 |
p = p->next; |
|
1080 |
} |
|
1081 |
} |
|
1082 |
||
1083 |
if (p == 0) |
|
1084 |
{ |
|
1085 |
char tmp[50]; |
|
1086 |
if (jobid == -1) |
|
44 | 1087 |
sprintf(tmp, "The last job cannot be waited.\n"); |
42 | 1088 |
else |
1089 |
sprintf(tmp, "The job %i cannot be waited.\n", jobid); |
|
1090 |
send_list_line(s, tmp); |
|
1091 |
return; |
|
1092 |
} |
|
1093 |
||
166
8c19a66b5407
Fixing a bug on wait_job on skipped jobs. Moving vnumber to 0.5
viric@vicerveza
parents:
157
diff
changeset
|
1094 |
if (p->state == FINISHED || p->state == SKIPPED) |
42 | 1095 |
{ |
112 | 1096 |
send_waitjob_ok(s, p->result.errorlevel); |
42 | 1097 |
} |
1098 |
else |
|
1099 |
add_to_notify_list(s, p->jobid); |
|
1100 |
} |
|
53 | 1101 |
|
226
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1102 |
void s_wait_running_job(int s, int jobid) |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1103 |
{ |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1104 |
struct Job *p = 0; |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1105 |
|
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1106 |
/* The job finding algorithm should be similar to that of |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1107 |
* s_send_output, because this will be used by "-t" and "-c" */ |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1108 |
if (jobid == -1) |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1109 |
{ |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1110 |
/* This means that we want the output info of the running task, or that |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1111 |
* of the last job run */ |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1112 |
if (busy_slots > 0) |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1113 |
{ |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1114 |
p = firstjob; |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1115 |
if (p == 0) |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1116 |
error("Internal state WAITING, but job not run." |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1117 |
"firstjob = %x", firstjob); |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1118 |
} |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1119 |
else |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1120 |
{ |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1121 |
p = first_finished_job; |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1122 |
if (p == 0) |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1123 |
{ |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1124 |
send_list_line(s, "No jobs.\n"); |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1125 |
return; |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1126 |
} |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1127 |
while(p->next != 0) |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1128 |
p = p->next; |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1129 |
} |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1130 |
} |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1131 |
else |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1132 |
{ |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1133 |
p = firstjob; |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1134 |
while (p != 0 && p->jobid != jobid) |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1135 |
p = p->next; |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1136 |
|
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1137 |
/* Look in finished jobs if needed */ |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1138 |
if (p == 0) |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1139 |
{ |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1140 |
p = first_finished_job; |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1141 |
while (p != 0 && p->jobid != jobid) |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1142 |
p = p->next; |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1143 |
} |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1144 |
} |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1145 |
|
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1146 |
if (p == 0) |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1147 |
{ |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1148 |
char tmp[50]; |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1149 |
if (jobid == -1) |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1150 |
sprintf(tmp, "The last job cannot be waited.\n"); |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1151 |
else |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1152 |
sprintf(tmp, "The job %i cannot be waited.\n", jobid); |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1153 |
send_list_line(s, tmp); |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1154 |
return; |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1155 |
} |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1156 |
|
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1157 |
if (p->state == FINISHED || p->state == SKIPPED) |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1158 |
{ |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1159 |
send_waitjob_ok(s, p->result.errorlevel); |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1160 |
} |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1161 |
else |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1162 |
add_to_notify_list(s, p->jobid); |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1163 |
} |
472ab90fd6a1
Bugfix: some "-t" and "-c" were not notified at end of job.
viric@mandarina
parents:
225
diff
changeset
|
1164 |
|
219 | 1165 |
void s_set_max_slots(int new_max_slots) |
1166 |
{ |
|
1167 |
if (new_max_slots > 0) |
|
1168 |
max_slots = new_max_slots; |
|
1169 |
else |
|
1170 |
warning("Received new_max_slots=%i", new_max_slots); |
|
1171 |
} |
|
1172 |
||
253
e9b153f4ae40
Making "-S" to return the number of slots set, if without additional argument.
viric@mandarina
parents:
252
diff
changeset
|
1173 |
void s_get_max_slots(int s) |
e9b153f4ae40
Making "-S" to return the number of slots set, if without additional argument.
viric@mandarina
parents:
252
diff
changeset
|
1174 |
{ |
e9b153f4ae40
Making "-S" to return the number of slots set, if without additional argument.
viric@mandarina
parents:
252
diff
changeset
|
1175 |
struct msg m; |
e9b153f4ae40
Making "-S" to return the number of slots set, if without additional argument.
viric@mandarina
parents:
252
diff
changeset
|
1176 |
|
e9b153f4ae40
Making "-S" to return the number of slots set, if without additional argument.
viric@mandarina
parents:
252
diff
changeset
|
1177 |
/* Message */ |
e9b153f4ae40
Making "-S" to return the number of slots set, if without additional argument.
viric@mandarina
parents:
252
diff
changeset
|
1178 |
m.type = GET_MAX_SLOTS_OK; |
e9b153f4ae40
Making "-S" to return the number of slots set, if without additional argument.
viric@mandarina
parents:
252
diff
changeset
|
1179 |
m.u.max_slots = max_slots; |
e9b153f4ae40
Making "-S" to return the number of slots set, if without additional argument.
viric@mandarina
parents:
252
diff
changeset
|
1180 |
|
e9b153f4ae40
Making "-S" to return the number of slots set, if without additional argument.
viric@mandarina
parents:
252
diff
changeset
|
1181 |
send_msg(s, &m); |
e9b153f4ae40
Making "-S" to return the number of slots set, if without additional argument.
viric@mandarina
parents:
252
diff
changeset
|
1182 |
} |
e9b153f4ae40
Making "-S" to return the number of slots set, if without additional argument.
viric@mandarina
parents:
252
diff
changeset
|
1183 |
|
53 | 1184 |
void s_move_urgent(int s, int jobid) |
1185 |
{ |
|
1186 |
struct Job *p = 0; |
|
1187 |
struct Job *tmp1; |
|
1188 |
||
1189 |
if (jobid == -1) |
|
1190 |
{ |
|
1191 |
/* Find the last job added */ |
|
1192 |
p = firstjob; |
|
1193 |
||
1194 |
if (p != 0) |
|
1195 |
while (p->next != 0) |
|
1196 |
p = p->next; |
|
1197 |
} |
|
1198 |
else |
|
1199 |
{ |
|
1200 |
p = firstjob; |
|
1201 |
while (p != 0 && p->jobid != jobid) |
|
1202 |
p = p->next; |
|
1203 |
} |
|
1204 |
||
1205 |
if (p == 0 || firstjob->next == 0) |
|
1206 |
{ |
|
1207 |
char tmp[50]; |
|
1208 |
if (jobid == -1) |
|
1209 |
sprintf(tmp, "The last job cannot be urged.\n"); |
|
1210 |
else |
|
1211 |
sprintf(tmp, "The job %i cannot be urged.\n", jobid); |
|
1212 |
send_list_line(s, tmp); |
|
1213 |
return; |
|
1214 |
} |
|
1215 |
||
1216 |
/* Interchange the pointers */ |
|
1217 |
tmp1 = find_previous_job(p); |
|
1218 |
tmp1->next = p->next; |
|
1219 |
p->next = firstjob->next; |
|
1220 |
firstjob->next = p; |
|
1221 |
||
1222 |
||
1223 |
send_urgent_ok(s); |
|
1224 |
} |
|
63 | 1225 |
|
66
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1226 |
void s_swap_jobs(int s, int jobid1, int jobid2) |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1227 |
{ |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1228 |
struct Job *p1, *p2; |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1229 |
struct Job *prev1, *prev2; |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1230 |
struct Job *tmp; |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1231 |
|
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1232 |
p1 = findjob(jobid1); |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1233 |
p2 = findjob(jobid2); |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1234 |
|
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1235 |
if (p1 == 0 || p2 == 0 || p1 == firstjob || p2 == firstjob) |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1236 |
{ |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1237 |
char prev[60]; |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1238 |
sprintf(prev, "The jobs %i and %i cannot be swapped.\n", jobid1, jobid2); |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1239 |
send_list_line(s, prev); |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1240 |
return; |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1241 |
} |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1242 |
|
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1243 |
/* Interchange the pointers */ |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1244 |
prev1 = find_previous_job(p1); |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1245 |
prev2 = find_previous_job(p2); |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1246 |
prev1->next = p2; |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1247 |
prev2->next = p1; |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1248 |
tmp = p1->next; |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1249 |
p1->next = p2->next; |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1250 |
p2->next = tmp; |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1251 |
|
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1252 |
send_swap_jobs_ok(s); |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1253 |
} |
f70a27afd92e
Adding "swap jobs" with -U. Fixed a big problem with fds 0, 1, 2.
viric@mandarina
parents:
64
diff
changeset
|
1254 |
|
63 | 1255 |
static void send_state(int s, enum Jobstate state) |
1256 |
{ |
|
1257 |
struct msg m; |
|
1258 |
||
1259 |
m.type = ANSWER_STATE; |
|
1260 |
m.u.state = state; |
|
1261 |
||
1262 |
send_msg(s, &m); |
|
1263 |
} |
|
1264 |
||
1265 |
void s_send_state(int s, int jobid) |
|
1266 |
{ |
|
1267 |
struct Job *p = 0; |
|
1268 |
||
1269 |
if (jobid == -1) |
|
1270 |
{ |
|
1271 |
/* Find the last job added */ |
|
1272 |
p = firstjob; |
|
1273 |
||
1274 |
if (p != 0) |
|
1275 |
while (p->next != 0) |
|
1276 |
p = p->next; |
|
1277 |
||
1278 |
/* Look in finished jobs if needed */ |
|
1279 |
if (p == 0) |
|
1280 |
{ |
|
1281 |
p = first_finished_job; |
|
1282 |
if (p != 0) |
|
1283 |
while (p->next != 0) |
|
1284 |
p = p->next; |
|
1285 |
} |
|
1286 |
||
1287 |
} |
|
1288 |
else |
|
1289 |
{ |
|
1290 |
p = get_job(jobid); |
|
1291 |
} |
|
1292 |
||
1293 |
if (p == 0) |
|
1294 |
{ |
|
1295 |
char tmp[50]; |
|
1296 |
if (jobid == -1) |
|
1297 |
sprintf(tmp, "The last job cannot be stated.\n"); |
|
1298 |
else |
|
1299 |
sprintf(tmp, "The job %i cannot be stated.\n", jobid); |
|
1300 |
send_list_line(s, tmp); |
|
1301 |
return; |
|
1302 |
} |
|
1303 |
||
1304 |
/* Interchange the pointers */ |
|
1305 |
send_state(s, p->state); |
|
1306 |
} |
|
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1307 |
|
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1308 |
static void dump_job_struct(FILE *out, const struct Job *p) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1309 |
{ |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1310 |
fprintf(out, " new_job\n"); |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1311 |
fprintf(out, " jobid %i\n", p->jobid); |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1312 |
fprintf(out, " command \"%s\"\n", p->command); |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1313 |
fprintf(out, " state %s\n", |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1314 |
jstate2string(p->state)); |
112 | 1315 |
fprintf(out, " result.errorlevel %i\n", p->result.errorlevel); |
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1316 |
fprintf(out, " output_filename \"%s\"\n", |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1317 |
p->output_filename ? p->output_filename : "NULL"); |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1318 |
fprintf(out, " store_output %i\n", p->store_output); |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1319 |
fprintf(out, " pid %i\n", p->pid); |
252
f0af96f58947
Fixing the problem of ts clients being killed. The queue should be reusable
viric@mandarina
parents:
246
diff
changeset
|
1320 |
fprintf(out, " should_keep_finished %i\n", p->should_keep_finished); |
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1321 |
} |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1322 |
|
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1323 |
void dump_jobs_struct(FILE *out) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1324 |
{ |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1325 |
const struct Job *p; |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1326 |
|
104 | 1327 |
fprintf(out, "New_jobs\n"); |
92
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1328 |
|
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1329 |
p = firstjob; |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1330 |
while (p != 0) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1331 |
{ |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1332 |
dump_job_struct(out, p); |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1333 |
p = p->next; |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1334 |
} |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1335 |
|
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1336 |
p = first_finished_job; |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1337 |
while (p != 0) |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1338 |
{ |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1339 |
dump_job_struct(out, p); |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1340 |
p = p->next; |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1341 |
} |
05004c52ecff
Better error reports on internal handled errors.
viric@llimona
parents:
66
diff
changeset
|
1342 |
} |
120 | 1343 |
|
254
41252d5e85f5
Fixed a bug in the notify list, reported by mark meissonnier.
viric@mandarina
parents:
253
diff
changeset
|
1344 |
static void dump_notify_struct(FILE *out, const struct Notify *n) |
41252d5e85f5
Fixed a bug in the notify list, reported by mark meissonnier.
viric@mandarina
parents:
253
diff
changeset
|
1345 |
{ |
41252d5e85f5
Fixed a bug in the notify list, reported by mark meissonnier.
viric@mandarina
parents:
253
diff
changeset
|
1346 |
fprintf(out, " notify\n"); |
41252d5e85f5
Fixed a bug in the notify list, reported by mark meissonnier.
viric@mandarina
parents:
253
diff
changeset
|
1347 |
fprintf(out, " jobid %i\n", n->jobid); |
41252d5e85f5
Fixed a bug in the notify list, reported by mark meissonnier.
viric@mandarina
parents:
253
diff
changeset
|
1348 |
fprintf(out, " socket \"%i\"\n", n->socket); |
41252d5e85f5
Fixed a bug in the notify list, reported by mark meissonnier.
viric@mandarina
parents:
253
diff
changeset
|
1349 |
} |
41252d5e85f5
Fixed a bug in the notify list, reported by mark meissonnier.
viric@mandarina
parents:
253
diff
changeset
|
1350 |
|
41252d5e85f5
Fixed a bug in the notify list, reported by mark meissonnier.
viric@mandarina
parents:
253
diff
changeset
|
1351 |
void dump_notifies_struct(FILE *out) |
41252d5e85f5
Fixed a bug in the notify list, reported by mark meissonnier.
viric@mandarina
parents:
253
diff
changeset
|
1352 |
{ |
41252d5e85f5
Fixed a bug in the notify list, reported by mark meissonnier.
viric@mandarina
parents:
253
diff
changeset
|
1353 |
const struct Notify *n; |
41252d5e85f5
Fixed a bug in the notify list, reported by mark meissonnier.
viric@mandarina
parents:
253
diff
changeset
|
1354 |
|
41252d5e85f5
Fixed a bug in the notify list, reported by mark meissonnier.
viric@mandarina
parents:
253
diff
changeset
|
1355 |
fprintf(out, "New_notifies\n"); |
41252d5e85f5
Fixed a bug in the notify list, reported by mark meissonnier.
viric@mandarina
parents:
253
diff
changeset
|
1356 |
|
41252d5e85f5
Fixed a bug in the notify list, reported by mark meissonnier.
viric@mandarina
parents:
253
diff
changeset
|
1357 |
n = first_notify; |
41252d5e85f5
Fixed a bug in the notify list, reported by mark meissonnier.
viric@mandarina
parents:
253
diff
changeset
|
1358 |
while (n != 0) |
41252d5e85f5
Fixed a bug in the notify list, reported by mark meissonnier.
viric@mandarina
parents:
253
diff
changeset
|
1359 |
{ |
41252d5e85f5
Fixed a bug in the notify list, reported by mark meissonnier.
viric@mandarina
parents:
253
diff
changeset
|
1360 |
dump_notify_struct(out, n); |
41252d5e85f5
Fixed a bug in the notify list, reported by mark meissonnier.
viric@mandarina
parents:
253
diff
changeset
|
1361 |
n = n->next; |
41252d5e85f5
Fixed a bug in the notify list, reported by mark meissonnier.
viric@mandarina
parents:
253
diff
changeset
|
1362 |
} |
41252d5e85f5
Fixed a bug in the notify list, reported by mark meissonnier.
viric@mandarina
parents:
253
diff
changeset
|
1363 |
} |
41252d5e85f5
Fixed a bug in the notify list, reported by mark meissonnier.
viric@mandarina
parents:
253
diff
changeset
|
1364 |
|
120 | 1365 |
void joblist_dump(int fd) |
1366 |
{ |
|
1367 |
struct Job *p; |
|
1368 |
char *buffer; |
|
1369 |
||
1370 |
buffer = joblistdump_headers(); |
|
1371 |
write(fd,buffer, strlen(buffer)); |
|
1372 |
free(buffer); |
|
1373 |
||
1374 |
/* We reuse the headers from the list */ |
|
1375 |
buffer = joblist_headers(); |
|
1376 |
write(fd, "# ", 2); |
|
1377 |
write(fd, buffer, strlen(buffer)); |
|
1378 |
||
1379 |
/* Show Finished jobs */ |
|
1380 |
p = first_finished_job; |
|
1381 |
while(p != 0) |
|
1382 |
{ |
|
1383 |
buffer = joblist_line(p); |
|
1384 |
write(fd, "# ", 2); |
|
1385 |
write(fd,buffer, strlen(buffer)); |
|
1386 |
free(buffer); |
|
1387 |
p = p->next; |
|
1388 |
} |
|
1389 |
||
1390 |
write(fd, "\n", 1); |
|
1391 |
||
1392 |
/* Show Queued or Running jobs */ |
|
1393 |
p = firstjob; |
|
1394 |
while(p != 0) |
|
1395 |
{ |
|
1396 |
buffer = joblistdump_torun(p); |
|
1397 |
write(fd,buffer,strlen(buffer)); |
|
1398 |
free(buffer); |
|
1399 |
p = p->next; |
|
1400 |
} |
|
1401 |
} |