From 8e2b7cce464ee7a1eac21ed1d5359114382cff75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reynir=20Bj=C3=B6rnsson?= Date: Tue, 1 Dec 2020 12:09:33 +0100 Subject: [PATCH] Acquire create_lock in self_destruct We need to acquire the lock for updating the state. --- daemon/albatrossd.ml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/daemon/albatrossd.ml b/daemon/albatrossd.ml index 38c9995..558e2ec 100644 --- a/daemon/albatrossd.ml +++ b/daemon/albatrossd.ml @@ -175,11 +175,13 @@ let jump _ systemd influx tmpdir dbdir retries enable_stats = let self_destruct_mutex = Lwt_mutex.create () in let self_destruct () = Lwt_mutex.with_lock self_destruct_mutex (fun () -> - (let state', tasks = Vmm_vmmd.killall !state Lwt.task in - state := state'; - Lwt_list.iter_s (fun exit_code -> - exit_code >>= fun (_ : process_exit) -> Lwt.return_unit) - tasks) >>= fun () -> + Lwt_mutex.with_lock create_lock (fun () -> + let state', tasks = Vmm_vmmd.killall !state Lwt.task in + state := state'; + Lwt.return tasks) >>= fun tasks -> + Lwt_list.iter_s (fun exit_code -> + exit_code >>= fun (_ : process_exit) -> Lwt.return_unit) + tasks >>= fun () -> Vmm_lwt.safe_close ss) in Sys.(set_signal sigterm