diff --git a/apps/sdlan/src/sdlan_stun.erl b/apps/sdlan/src/sdlan_stun.erl index 5631ea0..ea40b8e 100644 --- a/apps/sdlan/src/sdlan_stun.erl +++ b/apps/sdlan/src/sdlan_stun.erl @@ -16,8 +16,7 @@ -behaviour(gen_server). %% API --export([start_link/2]). --export([get_name/1]). +-export([start_link/1]). %% gen_server callbacks -export([init/1, handle_call/3, handle_cast/2, handle_info/2, terminate/2, code_change/3]). @@ -32,15 +31,11 @@ %%% API %%%=================================================================== --spec get_name(Id :: integer()) -> atom(). -get_name(Id) when is_integer(Id) -> - list_to_atom("sdlan_stun:" ++ integer_to_list(Id)). - %% @doc Spawns the server and registers the local name (unique) --spec(start_link(Name :: atom(), Socket :: inet:socket()) -> +-spec(start_link(Socket :: inet:socket()) -> {ok, Pid :: pid()} | ignore | {error, Reason :: term()}). -start_link(Name, Socket) when is_atom(Name) -> - gen_server:start_link({local, Name}, ?MODULE, [Socket], []). +start_link(Socket) -> + gen_server:start_link(?MODULE, [Socket], []). %%%=================================================================== %%% gen_server callbacks diff --git a/apps/sdlan/src/sdlan_stun_pool.erl b/apps/sdlan/src/sdlan_stun_pool.erl index 4eceb4e..c40028d 100644 --- a/apps/sdlan/src/sdlan_stun_pool.erl +++ b/apps/sdlan/src/sdlan_stun_pool.erl @@ -70,10 +70,9 @@ init([]) -> {sndbuf, 5 * 1024 * 1024} ], - Workers = lists:map(fun(Id) -> - Name = sdlan_stun:get_name(Id), + Workers = lists:map(fun(_Id) -> {ok, Socket} = gen_udp:open(Port, Opts), - {ok, Pid} = sdlan_stun:start_link(Name, Socket), + {ok, Pid} = sdlan_stun:start_link(Socket), {Socket, Pid} end, lists:seq(1, AcceptorNums)), {ok, #state{workers = list_to_tuple(Workers), idx = 1, num = length(Workers)}}. diff --git a/apps/sdlan/src/sdlan_sup.erl b/apps/sdlan/src/sdlan_sup.erl index 06ee8e8..ed9a7be 100644 --- a/apps/sdlan/src/sdlan_sup.erl +++ b/apps/sdlan/src/sdlan_sup.erl @@ -65,7 +65,7 @@ init([]) -> } ], - {ok, {SupFlags, pools() ++ Specs ++ stun_specs()}}. + {ok, {SupFlags, pools() ++ Specs}}. %% internal functions @@ -73,17 +73,4 @@ pools() -> {ok, Pools} = application:get_env(sdlan, pools), lists:map(fun({Name, PoolArgs, WorkerArgs}) -> poolboy:child_spec(Name, [{name, {local, Name}}|PoolArgs], WorkerArgs) - end, Pools). - -stun_specs() -> - {ok, StunServers} = application:get_env(sdlan, stun_servers), - lists:map(fun({Name, Port}) -> - #{ - id => Name, - start => {sdlan_stun, start_link, [Name, Port]}, - restart => permanent, - shutdown => 2000, - type => worker, - modules => ['sdlan_stun'] - } - end, StunServers). \ No newline at end of file + end, Pools). \ No newline at end of file diff --git a/config/sys-dev.config b/config/sys-dev.config index a3848c4..ec9b47d 100644 --- a/config/sys-dev.config +++ b/config/sys-dev.config @@ -3,7 +3,7 @@ {http_server, [ {port, 18082}, - {acceptors, 500}, + {acceptors, 1}, {max_connections, 10240}, {backlog, 10240} ]},