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 May 27, 2021
1 parent a7fe944 commit 04c2e5a
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 @@ -1625,8 +1625,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 @@ -1652,6 +1658,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 04c2e5a

Please sign in to comment.