(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).
(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).