git.annexia.org
/
whenjobs.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
bf5d28f
)
Compare job names intelligently, so "job$9" < "job$10".
author
Richard W.M. Jones
<rjones@redhat.com>
Tue, 21 Feb 2012 13:57:07 +0000
(13:57 +0000)
committer
Richard W.M. Jones
<rjones@redhat.com>
Tue, 21 Feb 2012 13:57:07 +0000
(13:57 +0000)
daemon/daemon.ml
patch
|
blob
|
history
diff --git
a/daemon/daemon.ml
b/daemon/daemon.ml
index
fd986fb
..
a6cc2fa
100644
(file)
--- a/
daemon/daemon.ml
+++ b/
daemon/daemon.ml
@@
-210,7
+210,7
@@
and reevaluate_whenjobs jobnames =
let set = loop StringSet.empty jobnames in
let jobnames = StringSet.elements set in
(* Ensure the jobs always run in predictable (name) order. *)
let set = loop StringSet.empty jobnames in
let jobnames = StringSet.elements set in
(* Ensure the jobs always run in predictable (name) order. *)
- let jobnames = List.sort compare jobnames in
+ let jobnames = List.sort compare
_jobnames
jobnames in
List.iter run_job
(List.map (fun jobname -> StringMap.find jobname !jobs) jobnames)
List.iter run_job
(List.map (fun jobname -> StringMap.find jobname !jobs) jobnames)
@@
-263,7
+263,8
@@
and schedule_next_everyjob () =
if jobs <> [] then (
(* Ensure the jobs always run in predictable (name) order. *)
let jobs =
if jobs <> [] then (
(* Ensure the jobs always run in predictable (name) order. *)
let jobs =
- List.sort (fun { job_name = a } { job_name = b } -> compare a b) jobs in
+ List.sort (fun {job_name = a} {job_name = b} -> compare_jobnames a b)
+ jobs in
if !debug then
Syslog.notice "scheduling job(s) %s to run at %s"
if !debug then
Syslog.notice "scheduling job(s) %s to run at %s"
@@
-356,5
+357,21
@@
and cleanup_job job dir =
let cmd = sprintf "rm -rf '%s'" dir in
ignore (Sys.command cmd)
let cmd = sprintf "rm -rf '%s'" dir in
ignore (Sys.command cmd)
+(* Intelligent comparison of job names. *)
+and compare_jobnames name1 name2 =
+ try
+ let len1 = String.length name1
+ and len2 = String.length name2 in
+ if len1 > 4 && len2 > 4 &&
+ String.sub name1 0 4 = "job$" && String.sub name2 0 4 = "job$"
+ then (
+ let i1 = int_of_string (String.sub name1 4 (len1-4)) in
+ let i2 = int_of_string (String.sub name2 4 (len2-4)) in
+ compare i1 i2
+ )
+ else raise Not_found
+ with _ ->
+ compare name1 name2
+
let main_loop () =
Unixqueue.run esys
let main_loop () =
Unixqueue.run esys