vmmd_stats: cleanups

This commit is contained in:
Hannes Mehnert 2018-11-01 22:40:32 +01:00
parent 0c58ebeedf
commit 6a92e572e3

View file

@ -38,11 +38,10 @@ let handle s addr () =
| Ok (t', action, out) -> | Ok (t', action, out) ->
t := t' ; t := t' ;
let pids = match action with let pids = match action with
| `Add pid -> pid :: pids | `Add pid -> pid :: pids
| `Remove pid -> List.filter (fun m -> m <> pid) pids | `Remove pid -> List.filter (fun m -> m <> pid) pids
| `Close _ -> pids | `Close _ -> pids
in in
t := t' ;
Vmm_lwt.write_wire s (fst wire, `Success (`String out)) >>= function Vmm_lwt.write_wire s (fst wire, `Success (`String out)) >>= function
| Ok () -> | Ok () ->
(match action with (match action with
@ -58,8 +57,7 @@ let handle s addr () =
loop [] >>= fun vmids -> loop [] >>= fun vmids ->
Vmm_lwt.safe_close s >|= fun () -> Vmm_lwt.safe_close s >|= fun () ->
Logs.warn (fun m -> m "disconnect, dropping %d vms!" (List.length vmids)) ; Logs.warn (fun m -> m "disconnect, dropping %d vms!" (List.length vmids)) ;
let t' = remove_vmids !t vmids in t := remove_vmids !t vmids
t := t'
let rec timer interval () = let rec timer interval () =
let t', outs = tick !t in let t', outs = tick !t in
@ -68,6 +66,7 @@ let rec timer interval () =
Vmm_lwt.write_wire s stat >>= function Vmm_lwt.write_wire s stat >>= function
| Ok () -> Lwt.return_unit | Ok () -> Lwt.return_unit
| Error `Exception -> | Error `Exception ->
Logs.debug (fun m -> m "removing entry %a" Vmm_core.pp_id name) ;
t := remove_entry !t name ; t := remove_entry !t name ;
Vmm_lwt.safe_close s) Vmm_lwt.safe_close s)
outs >>= fun () -> outs >>= fun () ->