Skip to content

Commit

Permalink
Merge pull request #574 from talex5/fix-invalid-fd
Browse files Browse the repository at this point in the history
Eio_posix: fix update to watched FDs on cancel
  • Loading branch information
talex5 authored Jul 8, 2023
2 parents b4b3540 + fc68c00 commit 57ace76
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion eio_windows.opam
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ build: [
]
]
dev-repo: "git+https://github.com/ocaml-multicore/eio.git"
available: [os-family = "windows"]
#available: [os-family = "windows"]
2 changes: 1 addition & 1 deletion eio_windows.opam.template
Original file line number Diff line number Diff line change
@@ -1 +1 @@
available: [os-family = "windows"]
#available: [os-family = "windows"]
5 changes: 5 additions & 0 deletions lib_eio_posix/sched.ml
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ let resume t node =

(* Called when poll indicates that an event we requested for [fd] is ready. *)
let ready t _index fd revents =
assert (not Poll.Flags.(mem revents pollnval));
if fd == t.eventfd_r then (
clear_event_fd t
(* The scheduler will now look at the run queue again and notice any new items. *)
Expand Down Expand Up @@ -259,6 +260,8 @@ let await_readable t (k : unit Suspended.t) fd =
if was_empty then update t waiters fd;
Fiber_context.set_cancel_fn k.fiber (fun ex ->
Lwt_dllist.remove node;
if Lwt_dllist.is_empty waiters.read then
update t waiters fd;
t.active_ops <- t.active_ops - 1;
enqueue_failed_thread t k ex
);
Expand All @@ -275,6 +278,8 @@ let await_writable t (k : unit Suspended.t) fd =
if was_empty then update t waiters fd;
Fiber_context.set_cancel_fn k.fiber (fun ex ->
Lwt_dllist.remove node;
if Lwt_dllist.is_empty waiters.write then
update t waiters fd;
t.active_ops <- t.active_ops - 1;
enqueue_failed_thread t k ex
);
Expand Down

0 comments on commit 57ace76

Please sign in to comment.