Skip to content

Commit

Permalink
Merge pull request #327 from haesbaert/fixhang
Browse files Browse the repository at this point in the history
Fix pipe hang (issue #319)
  • Loading branch information
haesbaert authored Oct 21, 2022
2 parents 13daa37 + a702def commit 63f5896
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib_eio_linux/eio_linux.ml
Original file line number Diff line number Diff line change
Expand Up @@ -953,16 +953,20 @@ let fast_copy src dst =
with End_of_file -> ()

(* Try a fast copy using splice. If the FDs don't support that, switch to copying. *)
let fast_copy_try_splice src dst =
let _fast_copy_try_splice src dst =
try
while true do
let _ : int = Low_level.splice src ~dst ~len:max_int in
()
done
with
| End_of_file -> ()
| Unix.Unix_error (Unix.EAGAIN, "splice", _) -> fast_copy src dst
| Unix.Unix_error (Unix.EINVAL, "splice", _) -> fast_copy src dst

(* XXX workaround for issue #319, PR #327 *)
let fast_copy_try_splice src dst = fast_copy src dst

(* Copy using the [Read_source_buffer] optimisation.
Avoids a copy if the source already has the data. *)
let copy_with_rsb rsb dst =
Expand Down Expand Up @@ -1290,6 +1294,9 @@ let stdenv ~run_event_loop =

let pipe sw =
let r, w = Unix.pipe () in
(* XXX workaround for issue #319, PR #327 *)
Unix.set_nonblock r;
Unix.set_nonblock w;
let r = source (FD.of_unix ~sw ~seekable:false ~close_unix:true r) in
let w = sink (FD.of_unix ~sw ~seekable:false ~close_unix:true w) in
r, w
Expand Down

0 comments on commit 63f5896

Please sign in to comment.