Skip to content
This repository has been archived by the owner on Apr 22, 2024. It is now read-only.

Commit

Permalink
Allow configuring the number of tcp acceptor processes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vagabond committed Aug 17, 2021
1 parent ac2c148 commit dd6bd9a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/libp2p_transport_tcp.erl
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
}).

-define(DEFAULT_MAX_TCP_CONNECTIONS, 1024).
-define(DEFAULT_MAX_TCP_ACCEPTORS, 10).

%% libp2p_transport
%%
Expand Down Expand Up @@ -721,8 +722,10 @@ listen_on(Addr, TID) ->
ok = libp2p_cache:insert(Cache, {tcp_local_listen_addrs, Type}, ListenAddrs),

MaxTCPConnections = application:get_env(libp2p, max_tcp_connections, ?DEFAULT_MAX_TCP_CONNECTIONS),
MaxAcceptors = application:get_env(libp2p, max_tcp_connections, ?DEFAULT_MAX_TCP_ACCEPTORS),
ChildSpec = ranch:child_spec(ListenAddrs,
ranch_tcp, [{socket, Socket}, {max_connections, MaxTCPConnections}],
ranch_tcp, [{socket, Socket}, {max_connections, MaxTCPConnections},
{num_acceptors, MaxAcceptors}],
libp2p_transport_ranch_protocol, {?MODULE, TID}),
case supervisor:start_child(Sup, ChildSpec) of
{ok, Pid} ->
Expand Down

0 comments on commit dd6bd9a

Please sign in to comment.