Skip to content

Commit 7f81454

Browse files
committed
ssl: Remove code duplication
1 parent ac94173 commit 7f81454

6 files changed

Lines changed: 5 additions & 28 deletions

File tree

lib/ssl/src/dtls_packet_demux.erl

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ getstat(PacketSocket, Opts) ->
113113
%%%===================================================================
114114

115115
init([Owner, Port0, TransportInfo, EmOpts, DTLSOptions, Socket]) ->
116-
InternalActiveN = get_internal_active_n(),
116+
InternalActiveN = ssl_config:get_internal_active_n(),
117117
erlang:monitor(process, Owner),
118118
{ok, SessionIdHandle} = session_id_tracker(Socket, DTLSOptions),
119119
proc_lib:set_label({dtls_server_packet_demultiplexer, Port0}),
@@ -419,11 +419,3 @@ emulated_opts_list(Opts, [active | Rest], Acc) ->
419419
session_id_tracker(Listener,_) ->
420420
dtls_server_session_cache_sup:start_child(Listener).
421421

422-
get_internal_active_n() ->
423-
case application:get_env(ssl, internal_active_n) of
424-
{ok, N} when is_integer(N) ->
425-
N;
426-
_ ->
427-
?INTERNAL_ACTIVE_N
428-
end.
429-

lib/ssl/src/dtls_server_session_cache_sup.erl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
%% Supervisor callback
3737
-export([init/1]).
3838

39-
-define(DEFAULT_MAX_SESSION_CACHE, 1000).
4039
%%%=========================================================================
4140
%%% API
4241
%%%=========================================================================

lib/ssl/src/ssl_config.erl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
-define(DEFAULT_MAX_SESSION_CACHE, 1000).
3131
-define(DEFAULT_MAX_CRL_CACHE, 150).
32+
-define(INTERNAL_ACTIVE_N, 100).
3233

3334
-export([init/2,
3435
pre_1_3_session_opts/1,

lib/ssl/src/ssl_internal.hrl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050

5151
-define(CDR_MAGIC, "GIOP").
5252
-define(CDR_HDR_SIZE, 12).
53-
-define(INTERNAL_ACTIVE_N, 100).
5453
-define(DEPTH, 20).
5554

5655
-define(DEFAULT_TIMEOUT, 5000).

lib/ssl/src/ssl_manager.erl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@
7474
-define(SESSION_VALIDATION_INTERVAL, 60000).
7575
-define(CLEAN_SESSION_DB, 60000).
7676
-define(CLEAN_CERT_DB, 500).
77-
-define(DEFAULT_MAX_SESSION_CACHE, 1000).
7877
-define(LOAD_MITIGATION, 10).
7978

8079
%%====================================================================

lib/ssl/src/tls_gen_connection_1_3.erl

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -425,22 +425,9 @@ init_max_early_data_size(server) ->
425425
internal_active_n(#{ktls := true}, Socket) ->
426426
inet:setopts(Socket, [{packet, ssl_tls}]),
427427
1;
428-
internal_active_n(#{erl_dist := true}, _) ->
429-
%% Start with a random number between 1 and ?INTERNAL_ACTIVE_N
430-
%% In most cases distribution connections are established all at
431-
%% the same time, and flow control engages with ?INTERNAL_ACTIVE_N for
432-
%% all connections. Which creates a wave of "passive" messages, leading
433-
%% to significant bump of memory & scheduler utilisation. Starting with
434-
%% a random number between 1 and ?INTERNAL_ACTIVE_N helps to spread the
435-
%% spike.
436-
erlang:system_time() rem ?INTERNAL_ACTIVE_N + 1;
437-
internal_active_n(_,_) ->
438-
case application:get_env(ssl, internal_active_n) of
439-
{ok, N} when is_integer(N) ->
440-
N;
441-
_ ->
442-
?INTERNAL_ACTIVE_N
443-
end.
428+
internal_active_n(Options, _) ->
429+
Boolean = maps:get(erl_dist, Options, false),
430+
ssl_config:get_internal_active_n(Boolean).
444431

445432
exporter_secrets(ExporterMasterSecret, Labels, PRFAlgorithm) ->
446433
DeriveSecret =

0 commit comments

Comments
 (0)