Skip to content

Commit

Permalink
CA-364138 XSI-1217: log number of FDs in use
Browse files Browse the repository at this point in the history
After starting a new server (for a varstored), report the number of open
file descriptors in the log.

Signed-off-by: Christian Lindig <christian.lindig@citrix.com>
  • Loading branch information
lindig committed Apr 8, 2022
1 parent 703b967 commit 05e22a4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ocaml/xapi-guard/src/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ let ret v = v >>= Lwt.return_ok |> Rpc_lwt.T.put

let sockets = Hashtbl.create 127

let log_fds () =
let fds = Sys.readdir "/proc/self/fd" |> Array.length in
D.info "file descriptors in use: %d" fds ;
Lwt.return_unit

module Persistent = struct
type args = {
vm_uuid: Varstore_privileged_interface.Uuidm.t
Expand Down Expand Up @@ -71,6 +76,7 @@ let listen_for_vm {Persistent.vm_uuid; path; gid} =
D.debug "resume: listening on socket %s for VM %s" path vm_uuid_str ;
safe_unlink path >>= fun () ->
make_server_rpcfn path vm_uuid_str >>= fun stop_server ->
log_fds () >>= fun () ->
Hashtbl.add sockets path (stop_server, (vm_uuid, gid)) ;
Lwt_unix.chmod path 0o660 >>= fun () -> Lwt_unix.chown path 0 gid

Expand Down

0 comments on commit 05e22a4

Please sign in to comment.