Apply suggestions from code review

Co-authored-by: Hannes Mehnert <hannes@mehnert.org>
This commit is contained in:
Reynir Björnsson 2020-11-26 07:30:14 +01:00 committed by Reynir Björnsson
parent c3cd5bd5ff
commit 9afe691de2
6 changed files with 6 additions and 6 deletions

View file

@ -163,7 +163,7 @@ let jump _ systemd influx tmpdir =
Albatross_cli.set_tmpdir tmpdir; Albatross_cli.set_tmpdir tmpdir;
Lwt_main.run Lwt_main.run
(Albatross_cli.init_influx "albatross_console" influx; (Albatross_cli.init_influx "albatross_console" influx;
Vmm_lwt.server_socket systemd `Console >>= fun s -> Vmm_lwt.server_socket ~systemd `Console >>= fun s ->
let rec loop () = let rec loop () =
Lwt_unix.accept s >>= fun (cs, addr) -> Lwt_unix.accept s >>= fun (cs, addr) ->
m `Open; m `Open;

View file

@ -161,7 +161,7 @@ let jump _ systemd file read_only influx tmpdir =
Lwt.return_unit Lwt.return_unit
end else begin end else begin
Albatross_cli.init_influx "albatross_log" influx; Albatross_cli.init_influx "albatross_log" influx;
Vmm_lwt.server_socket systemd `Log >>= fun s -> Vmm_lwt.server_socket ~systemd `Log >>= fun s ->
let ring = Vmm_ring.create `Startup () in let ring = Vmm_ring.create `Startup () in
List.iter (Vmm_ring.write ring) entries ; List.iter (Vmm_ring.write ring) entries ;
let mvar = Lwt_mvar.create_empty () in let mvar = Lwt_mvar.create_empty () in

View file

@ -165,7 +165,7 @@ let jump _ systemd influx tmpdir dbdir retries enable_stats =
else else
Lwt.return_none) >>= fun s -> Lwt.return_none) >>= fun s ->
Lwt.catch Lwt.catch
(fun () -> Vmm_lwt.server_socket systemd `Vmmd) (fun () -> Vmm_lwt.server_socket ~systemd `Vmmd)
(fun e -> (fun e ->
let str = let str =
Fmt.strf "unable to create server socket %a: %s" Fmt.strf "unable to create server socket %a: %s"

View file

@ -12,7 +12,7 @@ let safe_close fd =
(fun () -> Lwt_unix.close fd) (fun () -> Lwt_unix.close fd)
(fun _ -> Lwt.return_unit) (fun _ -> Lwt.return_unit)
let server_socket systemd sock = let server_socket ~systemd sock =
if systemd if systemd
then match Vmm_unix.sd_listen_fds () with then match Vmm_unix.sd_listen_fds () with
| Some [fd] -> Lwt.return (Lwt_unix.of_unix_file_descr fd) | Some [fd] -> Lwt.return (Lwt_unix.of_unix_file_descr fd)

View file

@ -2,7 +2,7 @@
val pp_sockaddr : Format.formatter -> Lwt_unix.sockaddr -> unit val pp_sockaddr : Format.formatter -> Lwt_unix.sockaddr -> unit
val server_socket : bool -> Vmm_core.service -> Lwt_unix.file_descr Lwt.t val server_socket : systemd:bool -> Vmm_core.service -> Lwt_unix.file_descr Lwt.t
val connect : Lwt_unix.socket_domain -> Lwt_unix.sockaddr -> Lwt_unix.file_descr option Lwt.t val connect : Lwt_unix.socket_domain -> Lwt_unix.sockaddr -> Lwt_unix.file_descr option Lwt.t

View file

@ -72,7 +72,7 @@ let jump _ systemd interval influx tmpdir =
let interval = Duration.(to_f (of_sec interval)) in let interval = Duration.(to_f (of_sec interval)) in
Lwt_main.run Lwt_main.run
(Albatross_cli.init_influx "albatross_stats" influx; (Albatross_cli.init_influx "albatross_stats" influx;
Vmm_lwt.server_socket systemd `Stats >>= fun s -> Vmm_lwt.server_socket ~systemd `Stats >>= fun s ->
let _ev = Lwt_engine.on_timer interval true (fun _e -> Lwt.async timer) in let _ev = Lwt_engine.on_timer interval true (fun _e -> Lwt.async timer) in
let rec loop () = let rec loop () =
Lwt_unix.accept s >>= fun (cs, addr) -> Lwt_unix.accept s >>= fun (cs, addr) ->