Skip to content

Lwt_io.establish_server*: max number of connections #1111

Description

@raphael-proust

(I received by email from a user who doesn't use github)

By now, Lwt_io.establish_server* accept all connections, with no limit.
Such a server will crash (with a Unix_error EMFILE) when accepting one
connection too many. This makes such servers very vulnerable to simple
attacks.

Would it be possible to add an optional parameter to establish_server*
functions to be able to set a limit to current alive connections ?

This parameter could be:

  • an integer, and the establish_server* functions would have to count
    current connections and only call Lwt_unix.accept if a new connection
    can be accepted.

  • or a function (unit -> unit Lwt.t) which would block until
    Lwt_unix.accept can be called; it would be up to the user code to
    handle counting of connections.

(I have a preference for the second solution, which is more flexible
and will not complexify Lwt_io's code).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions