Client/Context_unix: code style

This commit is contained in:
MBourgoin 2018-11-06 13:10:24 +01:00 committed by Grégoire Henry
parent 24355f0ae9
commit e35e263fd6
No known key found for this signature in database
GPG Key ID: 50D984F20BD445D2

View File

@ -37,8 +37,7 @@ class unix_wallet ~base_dir : wallet = object (self)
let unlock fd =
let fd = Lwt_unix.unix_file_descr fd in
Unix.lockf fd Unix.F_ULOCK 0 ;
Unix.close fd
in
Unix.close fd in
let lock () =
Lwt_unix.openfile (Filename.concat base_dir "wallet_lock")
Lwt_unix.[ O_CREAT ; O_WRONLY ] 0o644 >>= fun fd ->
@ -46,8 +45,7 @@ class unix_wallet ~base_dir : wallet = object (self)
Lwt.return (fd, (Lwt_unix.on_signal Sys.sigint
(fun _s ->
unlock fd ;
exit 0 (* exit code? *) )))
in
exit 0 (* exit code? *) ))) in
lock () >>= fun (fd, sh) ->
(* catch might be useless if f always uses the error monad *)
Lwt.catch f (function e -> Lwt.return (unlock fd ; raise e)) >>= fun res ->