Skip to content

Commit cc19aa1

Browse files
committed
Eio_posix: fix update to watched FDs on cancel
Reported by Daniel Quernheim.
1 parent b4b3540 commit cc19aa1

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

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)