forked from ocaml-multicore/eio
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
eio_windows: unregister FDs on cancel
This was fixed in cc19aa1 for `eio_posix`, but not for `eio_windows`. The error looks like: exception Unix.Unix_error(Unix.ENOTSOCK, "select", "")
- Loading branch information
Showing
4 changed files
with
69 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
open Eio.Std | ||
|
||
let () = | ||
Eio_posix.run @@ fun _ -> | ||
let a, b = Unix.(socketpair PF_UNIX SOCK_STREAM 0) in | ||
(* Start awaiting readable/writable state, but cancel immediately. *) | ||
try | ||
Eio.Cancel.sub (fun cc -> | ||
Fiber.all [ | ||
(fun () -> Eio_unix.await_readable a); | ||
(fun () -> Eio_unix.await_writable b); | ||
(fun () -> Eio.Cancel.cancel cc Exit); | ||
]; | ||
assert false | ||
) | ||
with Eio.Cancel.Cancelled _ -> | ||
(* Now wait for something else. Will fail if the old FDs are still being waited on. *) | ||
let c, d = Unix.(socketpair PF_UNIX SOCK_STREAM 0) in | ||
Unix.close a; | ||
Unix.close b; | ||
Fiber.first | ||
(fun () -> Eio_unix.await_readable c) | ||
(fun () -> Eio_unix.await_writable d); | ||
Unix.close c; | ||
Unix.close d |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters