Skip to content

Commit

Permalink
cohttp-eio.Server: Don't blow up in callback on client read timeout.
Browse files Browse the repository at this point in the history
  • Loading branch information
mefyl committed Feb 8, 2024
1 parent 6ed9bae commit 6399acc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions 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)

Expand Down
15 changes: 10 additions & 5 deletions cohttp-eio/src/server.ml
Expand Up @@ -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 ())
Expand Down

0 comments on commit 6399acc

Please sign in to comment.