Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eio_posix: fix update to watched FDs on cancel #574

Merged
merged 2 commits into from
Jul 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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