Commit 7d59031e authored by Fardale's avatar Fardale

Fix race condition in end_job function

The end_job function was calling Lwt.pause between the selection of the
node and its update which was making capacity of the node to decrease.
parent 83fa825f
......@@ -22,12 +22,22 @@ let string_of_sockaddr = function
let end_job id sockaddr =
let n, l = SHashtbl.find nodes (string_of_sockaddr sockaddr) in
let j = List.find (fun c -> c.id = id) l in
Lwt.pause () >|= fun () ->
let j =
{ id
; env= []
; script= ""
; args= []
; time= None
; pass= ""
; port= 0
; cpu= 0
; ram= 0 }
in
SHashtbl.replace nodes
(string_of_sockaddr sockaddr)
( { n with cpu = n.cpu + j.cpu; ram = n.ram + j.ram },
CCList.remove ~eq:(fun c1 c2 -> c1.id = c2.id) ~key:j l )
( {n with cpu= n.cpu + j.cpu; ram= n.ram + j.ram}
, CCList.remove_one ~eq:(fun c1 c2 -> c1.id = c2.id) j l );
Lwt.return_unit
let rec launch_job () =
if not (CCDeque.is_empty jobs) then (
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment