The unpac monorepo manager self-hosting as a monorepo using unpac
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge pull request #756 from talex5/win-unregister-fd

eio_windows: unregister FDs on cancel

authored by

Thomas Leonard and committed by
GitHub
1c470fa4 a449dc99

+65 -4
+2 -2
vendor/opam/eio/lib_eio_posix/test/dune
··· 3 3 (enabled_if (= %{os_type} "Unix")) 4 4 (deps (package eio_posix))) 5 5 6 - (test 7 - (name open_beneath) 6 + (tests 7 + (names open_beneath test_await) 8 8 (package eio_posix) 9 9 (build_if (= %{os_type} "Unix")) 10 10 (libraries eio_posix))
+25
vendor/opam/eio/lib_eio_posix/test/test_await.ml
··· 1 + open Eio.Std 2 + 3 + let () = 4 + Eio_posix.run @@ fun _ -> 5 + let a, b = Unix.(socketpair PF_UNIX SOCK_STREAM 0) in 6 + (* Start awaiting readable/writable state, but cancel immediately. *) 7 + try 8 + Eio.Cancel.sub (fun cc -> 9 + Fiber.all [ 10 + (fun () -> Eio_unix.await_readable a); 11 + (fun () -> Eio_unix.await_writable b); 12 + (fun () -> Eio.Cancel.cancel cc Exit); 13 + ]; 14 + assert false 15 + ) 16 + with Eio.Cancel.Cancelled _ -> 17 + (* Now wait for something else. Will fail if the old FDs are still being waited on. *) 18 + let c, d = Unix.(socketpair PF_UNIX SOCK_STREAM 0) in 19 + Unix.close a; 20 + Unix.close b; 21 + Fiber.first 22 + (fun () -> Eio_unix.await_readable c) 23 + (fun () -> Eio_unix.await_writable d); 24 + Unix.close c; 25 + Unix.close d
+4
vendor/opam/eio/lib_eio_windows/sched.ml
··· 271 271 if was_empty then update t waiters fd; 272 272 Fiber_context.set_cancel_fn k.fiber (fun ex -> 273 273 Lwt_dllist.remove node; 274 + if Lwt_dllist.is_empty waiters.read then 275 + update t waiters fd; 274 276 t.active_ops <- t.active_ops - 1; 275 277 enqueue_failed_thread t k ex 276 278 ); ··· 287 289 if was_empty then update t waiters fd; 288 290 Fiber_context.set_cancel_fn k.fiber (fun ex -> 289 291 Lwt_dllist.remove node; 292 + if Lwt_dllist.is_empty waiters.write then 293 + update t waiters fd; 290 294 t.active_ops <- t.active_ops - 1; 291 295 enqueue_failed_thread t k ex 292 296 );
+34 -2
vendor/opam/eio/lib_eio_windows/test/test.ml
··· 1 + open Eio.Std 2 + 1 3 module Timeout = struct 2 4 let test clock () = 3 5 let t0 = Unix.gettimeofday () in ··· 48 50 ] 49 51 end 50 52 53 + module Await_fd = struct 54 + let test_cancel () = 55 + let a, b = Unix.(socketpair PF_UNIX SOCK_STREAM 0) in 56 + (* Start awaiting readable/writable state, but cancel immediately. *) 57 + try 58 + Eio.Cancel.sub (fun cc -> 59 + Fiber.all [ 60 + (fun () -> Eio_unix.await_readable a); 61 + (fun () -> Eio_unix.await_writable b); 62 + (fun () -> Eio.Cancel.cancel cc Exit); 63 + ]; 64 + assert false 65 + ) 66 + with Eio.Cancel.Cancelled _ -> 67 + (* Now wait for something else. Will fail if the old FDs are still being waited on. *) 68 + let c, d = Unix.(socketpair PF_UNIX SOCK_STREAM 0) in 69 + Unix.close a; 70 + Unix.close b; 71 + Fiber.first 72 + (fun () -> Eio_unix.await_readable c) 73 + (fun () -> Eio_unix.await_writable d); 74 + Unix.close c; 75 + Unix.close d 76 + 77 + let tests = [ 78 + "cancel", `Quick, test_cancel; 79 + ] 80 + end 81 + 51 82 52 83 let () = 53 84 Eio_windows.run @@ fun env -> ··· 56 87 "fs", Test_fs.tests env; 57 88 "timeout", Timeout.tests env; 58 89 "random", Random.tests env; 59 - "dla", Dla.tests 60 - ] 90 + "dla", Dla.tests; 91 + "await", Await_fd.tests; 92 + ]