From d9f76312ed2b074bb7ff519eb0ed750a4660ca77 Mon Sep 17 00:00:00 2001 From: Hannes Mehnert Date: Sun, 27 Jan 2019 12:55:23 +0100 Subject: [PATCH] vmmd_console: reuse ring if already present in map - this preserves console output between re-creations --- app/vmmd_console.ml | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/app/vmmd_console.ml b/app/vmmd_console.ml index 6c0ac54..7c01485 100644 --- a/app/vmmd_console.ml +++ b/app/vmmd_console.ml @@ -69,15 +69,18 @@ let t = ref String.Map.empty let add_fifo id = let name = Vmm_core.Name.to_string id in open_fifo id >|= function + | None -> Error (`Msg "opening") | Some f -> - let ring = Vmm_ring.create "" () in - Logs.debug (fun m -> m "inserting fifo %s" name) ; - let map = String.Map.add name ring !t in - t := map ; + let ring = match String.Map.find name !t with + | None -> + let ring = Vmm_ring.create "" () in + let map = String.Map.add name ring !t in + t := map ; + ring + | Some ring -> ring + in Lwt.async (read_console id name ring f) ; Ok () - | None -> - Error (`Msg "opening") let subscribe s id = let name = Vmm_core.Name.to_string id in