···11+open Eio.Std
22+33+let () =
44+ Eio_posix.run @@ fun _ ->
55+ let a, b = Unix.(socketpair PF_UNIX SOCK_STREAM 0) in
66+ (* Start awaiting readable/writable state, but cancel immediately. *)
77+ try
88+ Eio.Cancel.sub (fun cc ->
99+ Fiber.all [
1010+ (fun () -> Eio_unix.await_readable a);
1111+ (fun () -> Eio_unix.await_writable b);
1212+ (fun () -> Eio.Cancel.cancel cc Exit);
1313+ ];
1414+ assert false
1515+ )
1616+ with Eio.Cancel.Cancelled _ ->
1717+ (* Now wait for something else. Will fail if the old FDs are still being waited on. *)
1818+ let c, d = Unix.(socketpair PF_UNIX SOCK_STREAM 0) in
1919+ Unix.close a;
2020+ Unix.close b;
2121+ Fiber.first
2222+ (fun () -> Eio_unix.await_readable c)
2323+ (fun () -> Eio_unix.await_writable d);
2424+ Unix.close c;
2525+ Unix.close d
+4
vendor/opam/eio/lib_eio_windows/sched.ml
···271271 if was_empty then update t waiters fd;
272272 Fiber_context.set_cancel_fn k.fiber (fun ex ->
273273 Lwt_dllist.remove node;
274274+ if Lwt_dllist.is_empty waiters.read then
275275+ update t waiters fd;
274276 t.active_ops <- t.active_ops - 1;
275277 enqueue_failed_thread t k ex
276278 );
···287289 if was_empty then update t waiters fd;
288290 Fiber_context.set_cancel_fn k.fiber (fun ex ->
289291 Lwt_dllist.remove node;
292292+ if Lwt_dllist.is_empty waiters.write then
293293+ update t waiters fd;
290294 t.active_ops <- t.active_ops - 1;
291295 enqueue_failed_thread t k ex
292296 );
+34-2
vendor/opam/eio/lib_eio_windows/test/test.ml
···11+open Eio.Std
22+13module Timeout = struct
24 let test clock () =
35 let t0 = Unix.gettimeofday () in
···4850 ]
4951end
50525353+module Await_fd = struct
5454+ let test_cancel () =
5555+ let a, b = Unix.(socketpair PF_UNIX SOCK_STREAM 0) in
5656+ (* Start awaiting readable/writable state, but cancel immediately. *)
5757+ try
5858+ Eio.Cancel.sub (fun cc ->
5959+ Fiber.all [
6060+ (fun () -> Eio_unix.await_readable a);
6161+ (fun () -> Eio_unix.await_writable b);
6262+ (fun () -> Eio.Cancel.cancel cc Exit);
6363+ ];
6464+ assert false
6565+ )
6666+ with Eio.Cancel.Cancelled _ ->
6767+ (* Now wait for something else. Will fail if the old FDs are still being waited on. *)
6868+ let c, d = Unix.(socketpair PF_UNIX SOCK_STREAM 0) in
6969+ Unix.close a;
7070+ Unix.close b;
7171+ Fiber.first
7272+ (fun () -> Eio_unix.await_readable c)
7373+ (fun () -> Eio_unix.await_writable d);
7474+ Unix.close c;
7575+ Unix.close d
7676+7777+ let tests = [
7878+ "cancel", `Quick, test_cancel;
7979+ ]
8080+end
8181+51825283let () =
5384 Eio_windows.run @@ fun env ->
···5687 "fs", Test_fs.tests env;
5788 "timeout", Timeout.tests env;
5889 "random", Random.tests env;
5959- "dla", Dla.tests
6060- ]9090+ "dla", Dla.tests;
9191+ "await", Await_fd.tests;
9292+ ]