Skip to content

Commit

Permalink
Ignore ECONNRESET on close
Browse files Browse the repository at this point in the history
FreeBSD returns ECONNRESET in certain (unclear) circumstances, but it
does still close the FD successfully. If you care about this case, you
should probably use `shutdown` instead and check for it there.

Python and Ruby at least both explicitly check for and ignore this error
too.
  • Loading branch information
talex5 committed Dec 2, 2024
1 parent f26d70d commit 2ea34b4
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib_eio_posix/flow.ml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,12 @@ module Impl = struct

let fd t = t

let close = Eio_unix.Fd.close
let close t =
try
Eio_unix.Fd.close t
with Unix.Unix_error (ECONNRESET, _, _) ->
(* For FreeBSD. See https://github.com/ocaml-multicore/eio/issues/786 *)
()
end

let handler = Eio_unix.Pi.flow_handler (module Impl)
Expand Down

0 comments on commit 2ea34b4

Please sign in to comment.