Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pipe hang (issue #319) #327

Merged
merged 1 commit into from
Oct 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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