Skip to content

Commit 1b2ea52

Browse files
authored
Merge pull request #600 from talex5/fix-epipe
eio_posix: ignore some errors writing to the wake up pipe
2 parents 1493f01 + 561a92c commit 1b2ea52

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lib_eio_posix/sched.ml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,15 @@ let wakeup t =
7373
Rcfd.use t.eventfd
7474
~if_closed:ignore (* Domain has shut down (presumably after handling the event) *)
7575
(fun fd ->
76-
(* This can fail if the pipe is full, but then a wake up is pending anyway. *)
77-
ignore (Unix.single_write fd wake_buffer 0 1 : int);
76+
try
77+
ignore (Unix.single_write fd wake_buffer 0 1 : int)
78+
with
79+
| Unix.Unix_error ((Unix.EAGAIN | EWOULDBLOCK), _, _) ->
80+
(* If the pipe is full then a wake up is pending anyway. *)
81+
()
82+
| Unix.Unix_error (Unix.EPIPE, _, _) ->
83+
(* We're shutting down; the event has already been processed. *)
84+
()
7885
)
7986

8087
(* Safe to call from anywhere (other systhreads, domains, signal handlers, GC finalizers) *)

0 commit comments

Comments
 (0)