diff --git a/CHANGES.md b/CHANGES.md index 0beaf4d54..bdf711db9 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,6 @@ ## Unreleased +- cohttp-eio: Don't blow up `Server.callback` on connection timeout. (mefyl #1021) - cohttp-eio: Don't blow up `Server.callback` on client disconnections. (mefyl #1015) - http: Fix assertion in `Source.to_string_trim` when `pos <> 0` (mefyl #1017) diff --git a/cohttp-eio/src/server.ml b/cohttp-eio/src/server.ml index 364c83385..c73c65e2c 100644 --- a/cohttp-eio/src/server.ml +++ b/cohttp-eio/src/server.ml @@ -103,11 +103,16 @@ let callback { conn_closed; handler } ((_, peer_address) as conn) input output = in conn_closed (conn, id) | exception Eio.Io (Eio.Net.E (Connection_reset _), _) -> - let () = - Logs.info (fun m -> - m "%a: connection reset" Eio.Net.Sockaddr.pp peer_address) - in - () + Logs.info (fun m -> + m "%a: connection reset" Eio.Net.Sockaddr.pp peer_address) + | exception + Eio.Io + ( Eio.Exn.X _ + (* To catch the backend-specific Eio_unix.Unix_error + (ETIMEDOUT, _, _), at least *), + _ ) -> + Logs.info (fun m -> + m "%a: connection timed out" Eio.Net.Sockaddr.pp peer_address) | `Invalid e -> write output (Http.Response.make ~status:`Bad_request ())