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 add_fifo id =
|
||||||
let name = Vmm_core.Name.to_string id in
|
let name = Vmm_core.Name.to_string id in
|
||||||
open_fifo id >|= function
|
open_fifo id >|= function
|
||||||
|
| None -> Error (`Msg "opening")
|
||||||
| Some f ->
|
| Some f ->
|
||||||
let ring = Vmm_ring.create "" () in
|
let ring = match String.Map.find name !t with
|
||||||
Logs.debug (fun m -> m "inserting fifo %s" name) ;
|
| None ->
|
||||||
let map = String.Map.add name ring !t in
|
let ring = Vmm_ring.create "" () in
|
||||||
t := map ;
|
let map = String.Map.add name ring !t in
|
||||||
|
t := map ;
|
||||||
|
ring
|
||||||
|
| Some ring -> ring
|
||||||
|
in
|
||||||
Lwt.async (read_console id name ring f) ;
|
Lwt.async (read_console id name ring f) ;
|
||||||
Ok ()
|
Ok ()
|
||||||
| None ->
|
|
||||||
Error (`Msg "opening")
|
|
||||||
|
|
||||||
let subscribe s id =
|
let subscribe s id =
|
||||||
let name = Vmm_core.Name.to_string id in
|
let name = Vmm_core.Name.to_string id in
|
||||||
|
|
Loading…
Reference in a new issue