Skip to content

Commit 57ace76

Browse files
authored
Merge pull request #574 from talex5/fix-invalid-fd
Eio_posix: fix update to watched FDs on cancel
2 parents b4b3540 + fc68c00 commit 57ace76

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

eio_windows.opam

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ build: [
3030
]
3131
]
3232
dev-repo: "git+https://github.com/ocaml-multicore/eio.git"
33-
available: [os-family = "windows"]
33+
#available: [os-family = "windows"]

eio_windows.opam.template

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
available: [os-family = "windows"]
1+
#available: [os-family = "windows"]

lib_eio_posix/sched.ml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ let resume t node =
145145

146146
(* Called when poll indicates that an event we requested for [fd] is ready. *)
147147
let ready t _index fd revents =
148+
assert (not Poll.Flags.(mem revents pollnval));
148149
if fd == t.eventfd_r then (
149150
clear_event_fd t
150151
(* The scheduler will now look at the run queue again and notice any new items. *)
@@ -259,6 +260,8 @@ let await_readable t (k : unit Suspended.t) fd =
259260
if was_empty then update t waiters fd;
260261
Fiber_context.set_cancel_fn k.fiber (fun ex ->
261262
Lwt_dllist.remove node;
263+
if Lwt_dllist.is_empty waiters.read then
264+
update t waiters fd;
262265
t.active_ops <- t.active_ops - 1;
263266
enqueue_failed_thread t k ex
264267
);
@@ -275,6 +278,8 @@ let await_writable t (k : unit Suspended.t) fd =
275278
if was_empty then update t waiters fd;
276279
Fiber_context.set_cancel_fn k.fiber (fun ex ->
277280
Lwt_dllist.remove node;
281+
if Lwt_dllist.is_empty waiters.write then
282+
update t waiters fd;
278283
t.active_ops <- t.active_ops - 1;
279284
enqueue_failed_thread t k ex
280285
);

0 commit comments

Comments
 (0)