Skip to content

Commit

Permalink
Merge pull request xapi-project#3507 from krizex/timebox
Browse files Browse the repository at this point in the history
Eliminate fd leak in timebox
  • Loading branch information
krizex committed Mar 14, 2018
2 parents e14d893 + 808eb52 commit d0f9d51
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion ocaml/xapi/helpers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1141,8 +1141,9 @@ let timebox ~timeout ~otherwise f =
with e ->
result := fun () -> raise e);
Unix.close fd_out) () in
let _ = Thread.wait_timed_read fd_in timeout in
let finished = Thread.wait_timed_read fd_in timeout in
Unix.close fd_in;
if not finished then ignore_exn (fun () -> Unix.close fd_out);
!result ()

(**************************************************************************************)
Expand Down

0 comments on commit d0f9d51

Please sign in to comment.