vmmd_console: reuse ring if already present in map - this preserves console output between re-creations
This commit is contained in:
parent
943ea45e25
commit
d9f76312ed
|
@ -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 = match String.Map.find name !t with
|
||||
| None ->
|
||||
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 ;
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue