Skip to content

Commit

Permalink
Use read_ahead in SSL for KTLS
Browse files Browse the repository at this point in the history
  • Loading branch information
RaimoNiskanen committed Aug 20, 2024
1 parent 7cb3eb7 commit 32f4631
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
12 changes: 7 additions & 5 deletions lib/ssl/src/inet_tls_dist.erl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 2011-2023. All Rights Reserved.
%% Copyright Ericsson AB 2011-2024. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -233,7 +233,8 @@ listen(Name, Host) ->

fam_listen(Family, Name, Host) ->
ForcedOptions =
[Family, {active, false}, {packet, 4}, {nodelay, true}],
[Family, {active, false}, {packet, 4},
{read_ahead, false}, {nodelay, true}],
ListenFun =
fun (First, Last, ListenOptions) ->
listen_loop(
Expand Down Expand Up @@ -342,7 +343,7 @@ accept_one(Family, Socket, NetKernel) ->
case
ssl:handshake(
Socket,
trace([{active, false},{packet, 4}|Opts]),
trace([{active, false}, {packet, 4}, {read_ahead, false} | Opts]),
net_kernel:connecttime())
of
{ok, SslSocket} ->
Expand Down Expand Up @@ -640,7 +641,8 @@ do_setup(
inet_tcp_dist:merge_options(
ConnectOptions,
get_ssl_options(client)),
[Family, binary, {active, false}, {packet, 4}, {nodelay, true}],
[Family, binary, {active, false}, {packet, 4},
{read_ahead, false}, {nodelay, true}],
[{server_name_indication, Host}]),
KTLS = proplists:get_value(ktls, Opts, false),
dist_util:reset_timer(Timer),
Expand Down Expand Up @@ -943,7 +945,7 @@ inet_set_ktls(
inet:setopts(
Socket,
[list, {packet, Packet}, {packet_size, PacketSize},
{header, Header}, {active, Active}])
{read_ahead, false}, {header, Header}, {active, Active}])
of
ok ->
ok;
Expand Down
4 changes: 2 additions & 2 deletions lib/ssl/src/tls_gen_connection_1_3.erl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
%% Copyright Ericsson AB 2022-2023. All Rights Reserved.
%% Copyright Ericsson AB 2022-2024. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
%% you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -380,7 +380,7 @@ init_max_early_data_size(server) ->
ssl_config:get_max_early_data_size().

internal_active_n(#{ktls := true}, Socket) ->
inet:setopts(Socket, [{packet, ssl_tls}]),
inet:setopts(Socket, [{packet, ssl_tls}, {read_ahead, false}]),
1;
internal_active_n(#{erl_dist := true}, _) ->
%% Start with a random number between 1 and ?INTERNAL_ACTIVE_N
Expand Down

0 comments on commit 32f4631

Please sign in to comment.