Skip to content

Commit

Permalink
establish_server_generic: handle ECONNABORTED
Browse files Browse the repository at this point in the history
Call accept again if ECONNABORTED.
Fixes ocsigen#829
  • Loading branch information
reynir authored and raphael-proust committed Feb 11, 2021
1 parent b4ebb85 commit 274b83f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/unix/lwt_io.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1597,8 +1597,14 @@ let establish_server_generic

let rec accept_loop () =
let try_to_accept =
Lwt_unix.accept listening_socket >|= fun x ->
`Accepted x
Lwt.catch
(fun () ->
Lwt_unix.accept listening_socket >|= fun x ->
`Accepted x)
(function
| Unix.Unix_error (Unix.ECONNABORTED, _, _) ->
Lwt.return `Try_again
| e -> Lwt.fail e)
in

Lwt.pick [try_to_accept; should_stop] >>= function
Expand All @@ -1624,6 +1630,8 @@ let establish_server_generic

Lwt.wakeup_later notify_listening_socket_closed ();
Lwt.return_unit
| `Try_again ->
accept_loop ()
in

let server =
Expand Down

0 comments on commit 274b83f

Please sign in to comment.