Skip to content

Commit 561a92c

Browse files
committed
eio_posix: ignore some errors writing to the wake up pipe
The README test failed in CI on macos with: # File "README.md", line 1, characters 0-0: # /usr/local/bin/git --no-pager diff --no-index --color=always -u _build/default/README.md _build/default/.mdx/README.md.corrected # diff --git a/_build/default/README.md b/_build/default/.mdx/README.md.corrected # index e710380..e1d7eb2 100644 # --- a/_build/default/README.md # +++ b/_build/default/.mdx/README.md.corrected # @@ -1673,7 +1673,7 @@ Joining with the other domain # # ```ocaml # # y + Domain.join foreign_domain # -- : int = 42 # +Exception: Unix.Unix_error(Unix.EPIPE, "single_write", "") # ``` # # we arrive at the answer. Ignore EPIPE when writing, since it means we've shut down and don't need a wake-up (the event has presumably already been processed). Also, ignore EAGAIN and EWOULDBLOCK. If the pipe is full, then a wake-up is already pending.
1 parent 1493f01 commit 561a92c

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)