Skip to content

Commit 451b8ba

Browse files
committed
ssl: Remove code duplication
1 parent 1cb7b1c commit 451b8ba

5 files changed

Lines changed: 4 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
@@ -115,7 +115,7 @@ getstat(PacketSocket, Opts) ->
115115
%%%===================================================================
116116

117117
init([Owner, Port0, TransportInfo, EmOpts, DTLSOptions, Socket]) ->
118-
InternalActiveN = get_internal_active_n(),
118+
InternalActiveN = ssl_config:get_internal_active_n(),
119119
erlang:monitor(process, Owner),
120120
{ok, SessionIdHandle} = session_id_tracker(Socket, DTLSOptions),
121121
proc_lib:set_label({dtls_server_packet_demultiplexer, Port0}),
@@ -428,11 +428,3 @@ emulated_opts_list(Opts, [active | Rest], Acc) ->
428428
session_id_tracker(Listener,_) ->
429429
dtls_server_session_cache_sup:start_child(Listener).
430430

431-
get_internal_active_n() ->
432-
case application:get_env(ssl, internal_active_n) of
433-
{ok, N} when is_integer(N) ->
434-
N;
435-
_ ->
436-
?INTERNAL_ACTIVE_N
437-
end.
438-

lib/ssl/src/dtls_server_session_cache_sup.erl

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

41-
-define(DEFAULT_MAX_SESSION_CACHE, 1000).
4241
%%%=========================================================================
4342
%%% API
4443
%%%=========================================================================

lib/ssl/src/ssl_internal.hrl

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

5353
-define(CDR_MAGIC, "GIOP").
5454
-define(CDR_HDR_SIZE, 12).
55-
-define(INTERNAL_ACTIVE_N, 100).
5655
-define(DEPTH, 20).
5756

5857
-define(DEFAULT_TIMEOUT, 5000).

lib/ssl/src/ssl_manager.erl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@
7676
-define(SESSION_VALIDATION_INTERVAL, 60000).
7777
-define(CLEAN_SESSION_DB, 60000).
7878
-define(CLEAN_CERT_DB, 500).
79-
-define(DEFAULT_MAX_SESSION_CACHE, 1000).
8079
-define(LOAD_MITIGATION, 10).
8180

8281
%%====================================================================

lib/ssl/src/tls_gen_connection_1_3.erl

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

450437
exporter_secrets(ExporterMasterSecret, Labels, PRFAlgorithm) ->
451438
DeriveSecret =

0 commit comments

Comments
 (0)