Acquire create_lock in self_destruct

We need to acquire the lock for updating the state.
This commit is contained in:
Reynir Björnsson 2020-12-01 12:09:33 +01:00
parent 472e42717e
commit 8e2b7cce46

View file

@ -175,11 +175,13 @@ let jump _ systemd influx tmpdir dbdir retries enable_stats =
let self_destruct_mutex = Lwt_mutex.create () in let self_destruct_mutex = Lwt_mutex.create () in
let self_destruct () = let self_destruct () =
Lwt_mutex.with_lock self_destruct_mutex (fun () -> Lwt_mutex.with_lock self_destruct_mutex (fun () ->
(let state', tasks = Vmm_vmmd.killall !state Lwt.task in Lwt_mutex.with_lock create_lock (fun () ->
state := state'; let state', tasks = Vmm_vmmd.killall !state Lwt.task in
Lwt_list.iter_s (fun exit_code -> state := state';
exit_code >>= fun (_ : process_exit) -> Lwt.return_unit) Lwt.return tasks) >>= fun tasks ->
tasks) >>= fun () -> Lwt_list.iter_s (fun exit_code ->
exit_code >>= fun (_ : process_exit) -> Lwt.return_unit)
tasks >>= fun () ->
Vmm_lwt.safe_close ss) Vmm_lwt.safe_close ss)
in in
Sys.(set_signal sigterm Sys.(set_signal sigterm