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

Commit 75d5e3c

Browse files
committed
Allow configuring the number of tcp acceptor processes
1 parent ac2c148 commit 75d5e3c

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/libp2p_transport_tcp.erl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@
9494
}).
9595

9696
-define(DEFAULT_MAX_TCP_CONNECTIONS, 1024).
97+
-define(DEFAULT_MAX_TCP_ACCEPTORS, 10).
9798

9899
%% libp2p_transport
99100
%%
@@ -721,8 +722,10 @@ listen_on(Addr, TID) ->
721722
ok = libp2p_cache:insert(Cache, {tcp_local_listen_addrs, Type}, ListenAddrs),
722723

723724
MaxTCPConnections = application:get_env(libp2p, max_tcp_connections, ?DEFAULT_MAX_TCP_CONNECTIONS),
725+
MaxAcceptors = application:get_env(libp2p, num_tcp_acceptors, ?DEFAULT_MAX_TCP_ACCEPTORS),
724726
ChildSpec = ranch:child_spec(ListenAddrs,
725-
ranch_tcp, [{socket, Socket}, {max_connections, MaxTCPConnections}],
727+
ranch_tcp, [{socket, Socket}, {max_connections, MaxTCPConnections},
728+
{num_acceptors, MaxAcceptors}],
726729
libp2p_transport_ranch_protocol, {?MODULE, TID}),
727730
case supervisor:start_child(Sup, ChildSpec) of
728731
{ok, Pid} ->

0 commit comments

Comments
 (0)