Skip to content

Commit

Permalink
Fix pipe hang (issue #319)
Browse files Browse the repository at this point in the history
Turns out the kernel needs to handle blocking file descriptors differently, it
needs to do thread-pooling and it's a different code path (also slower).

It also seems that this is bugged in some cases. This makes sense as I believe
most people don't test with blocking FDs. I believe we should make all our FDs
non blocking as a precaution.

There is a program listed in issue #319 that replicates this. I could hang it in
< 5 seconds, and it's now running for 10minutes with the fix, so kaboom.

A fix has been committed to mainline Linux (should be in Linux 6.1):
torvalds/linux@46a525e
  • Loading branch information
haesbaert authored and talex5 committed Oct 20, 2022
1 parent a638009 commit c542234
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib_eio_linux/eio_linux.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,8 @@ let stdenv ~run_event_loop =

let pipe sw =
let r, w = Unix.pipe () in
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 c542234

Please sign in to comment.