Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Lwt_io.establish_server_generic doesn't handle ECONNABORTED #829

@reynir

Description

@reynir

I have been running an opium server on FreeBSD, and it failed with ECONNABORTED in Lwt_unix.accept. It seems Lwt_io.establish_server_generic doesn't handle this error as well.

lwt/src/unix/lwt_io.ml

Lines 1598 to 1627 in 0985a5b

let rec accept_loop () =
let try_to_accept =
Lwt_unix.accept listening_socket >|= fun x ->
`Accepted x
in
Lwt.pick [try_to_accept; should_stop] >>= function
| `Accepted (client_socket, client_address) ->
begin
try Lwt_unix.set_close_on_exec client_socket
with Invalid_argument _ -> ()
end;
connection_handler_callback client_address client_socket;
accept_loop ()
| `Should_stop ->
Lwt_unix.close listening_socket >>= fun () ->
begin match listening_address with
| Unix.ADDR_UNIX path when path <> "" && path.[0] <> '\x00' ->
Unix.unlink path
| _ ->
()
end [@ocaml.warning "-4"];
Lwt.wakeup_later notify_listening_socket_closed ();
Lwt.return_unit
in

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions