From 44debece63b2ea9fa3ca6fb5df1f7c1a0aea84da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reynir=20Bj=C3=B6rnsson?= Date: Wed, 16 Dec 2020 18:45:17 +0100 Subject: [PATCH 1/2] Handle ECONNABORTED in accept --- opium/src/app.ml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/opium/src/app.ml b/opium/src/app.ml index c66552b..00511f8 100644 --- a/opium/src/app.ml +++ b/opium/src/app.ml @@ -50,9 +50,14 @@ let run_unix_multicore ?middlewares ~host ~port ~jobs handler = (let+ () = Lwt_unix.bind socket listen_address in Lwt_unix.listen socket (Lwt_unix.somaxconn () [@ocaml.warning "-3"])); let rec accept_loop socket instance = - let* socket', sockaddr' = Lwt_unix.accept socket in - Lwt.async (fun () -> connection_handler sockaddr' socket'); - accept_loop socket instance + Lwt.try_bind + (fun () -> Lwt_unix.accept socket) + (fun (socket', sockaddr') -> + Lwt.async (fun () -> connection_handler sockaddr' socket'); + accept_loop socket instance) + (function + | Unix.Unix_error (Unix.ECONNABORTED, _, _) -> accept_loop socket instance + | e -> Lwt.fail e) in for i = 1 to jobs do flush_all (); From 8b5fd862e60d688c97adaa55ee9b2179c535d4ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reynir=20Bj=C3=B6rnsson?= Date: Wed, 16 Dec 2020 18:52:04 +0100 Subject: [PATCH 2/2] Add CHANGES entry --- CHANGES.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 99969c0..e2fb6ac 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,9 @@ +# Unreleased + +## Fixed + +- Handle ECONNABORTED in accept (#250) + # 0.20.0 ## Added