diff --git a/.travis.yml b/.travis.yml index caa9269..9aaf7cb 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,14 @@ language: c -sudo: require -install: wget https://raw.githubusercontent.com/ocaml/ocaml-ci-scripts/master/.travis-docker.sh +sudo: false +services: + - docker +install: + - wget https://raw.githubusercontent.com/ocaml/ocaml-ci-scripts/master/.travis-docker.sh script: bash -ex .travis-docker.sh env: global: - OCAML_VERSION=4.04.2 - - DISTRO=debian-stable + - DISTRO=centos-7 - PACKAGE=xapi-nbd matrix: - BASE_REMOTE=git://github.com/xapi-project/xs-opam diff --git a/lib/vbd_store.ml b/lib/vbd_store.ml index 5e688cd..1829036 100644 --- a/lib/vbd_store.ml +++ b/lib/vbd_store.ml @@ -21,7 +21,7 @@ module Make(Config : sig Lwt.catch (fun () -> Lwt_unix.mkdir vbd_list_dir 0o755) (function - | Unix.(Unix_error (EEXIST, "mkdir", dir)) when dir = vbd_list_dir -> Lwt.return_unit + | Unix.Unix_error (EEXIST, "mkdir", dir) when dir = vbd_list_dir -> Lwt.return_unit | e -> (* In any other case we let the client fail. In this case the user/admin should go and fix the root cause of the issue *) log_and_reraise_error ("Failed to create directory " ^ vbd_list_dir) e @@ -38,7 +38,7 @@ module Make(Config : sig Lwt.catch (fun () -> Lwt_io.lines_of_file vbd_list_file |> Lwt_stream.to_list) (function - | Unix.(Unix_error (ENOENT, "open", file)) when file = vbd_list_file -> Lwt.return [] + | Unix.Unix_error (ENOENT, "open", file) when file = vbd_list_file -> Lwt.return [] | e -> (* In any other case we let the client fail. In this case the user/admin should go and fix the root cause of the issue *) log_and_reraise_error ("Failed to read file " ^ vbd_list_file) e diff --git a/src/cleanup.ml b/src/cleanup.ml index c11cc87..3c81b4d 100644 --- a/src/cleanup.ml +++ b/src/cleanup.ml @@ -29,7 +29,7 @@ module VBD = struct let vbds_to_clean_up = ref StringSet.empty let vbds_to_clean_up_mutex = Lwt_mutex.create () - let with_tracking rpc session_id vbd f = + let with_tracking vbd f = Lwt_mutex.with_lock vbds_to_clean_up_mutex (fun () -> Lwt.wrap (fun () -> vbds_to_clean_up := StringSet.add (API.Ref.string_of vbd) !vbds_to_clean_up)) >>= fun () -> @@ -105,7 +105,7 @@ module VBD = struct Xen_api.VBD.create ~rpc ~session_id ~vM ~vDI ~userdevice:"autodetect" ~bootable:false ~mode ~_type:`Disk ~unpluggable:true ~empty:false ~other_config:[] ~qos_algorithm_type:"" ~qos_algorithm_params:[] >>= fun vbd -> Persistent.with_tracking rpc session_id vbd (fun () -> - Runtime.with_tracking rpc session_id vbd (fun () -> + Runtime.with_tracking vbd (fun () -> Lwt.finalize (fun () -> Lwt_log.notice_f "Plugging VBD %s" (API.Ref.string_of vbd) >>= fun () -> diff --git a/src/main.ml b/src/main.ml index 38a98ad..6e7ae1c 100644 --- a/src/main.ml +++ b/src/main.ml @@ -120,7 +120,7 @@ let main port certfile ciphersuites = Lwt_log.notice "Setting up server socket" >>= fun () -> Lwt_unix.setsockopt sock Lwt_unix.SO_REUSEADDR true; let sockaddr = Lwt_unix.ADDR_INET(Unix.inet_addr_any, port) in - Lwt_unix.bind sock sockaddr; + Lwt_unix.bind sock sockaddr >>= fun () -> Lwt_unix.listen sock 5; Lwt_log.notice "Listening for incoming connections" >>= fun () -> @@ -165,13 +165,14 @@ let main port certfile ciphersuites = (ignore_exn_delayed (fun () -> Lwt_unix.close sock)) in (* Log unexpected exceptions *) - Lwt_main.run + let () = Lwt_main.run (Lwt.catch t (fun e -> Lwt_log.fatal_f "Caught unexpected exception: %s" (Printexc.to_string e) >>= fun () -> Lwt.fail e ) - ); + ) + in `Ok ()