From cbe475a8e1b0236b4ac363d4f7a01d448fa64ef8 Mon Sep 17 00:00:00 2001 From: Thomas Leonard Date: Wed, 25 Sep 2024 16:04:08 +0100 Subject: [PATCH] On FreeBSD, close can fail with ECONNRESET Seen in CI. See: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=159179 --- unix/unix_flow.ml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/unix/unix_flow.ml b/unix/unix_flow.ml index 1c08b2ab..6d5d9c35 100644 --- a/unix/unix_flow.ml +++ b/unix/unix_flow.ml @@ -23,7 +23,12 @@ let close t = t.closed <- true; opt_cancel t.current_read; opt_cancel t.current_write; - Lwt_unix.close t.fd + Lwt.catch + (fun () -> Lwt_unix.close t.fd) + (function + | Unix.Unix_error (Unix.ECONNRESET, _, _) -> Lwt.return_unit (* FreeBSD *) + | ex -> raise ex + ) ) let pp_error f = function