Skip to content

Commit 9b7f0f4

Browse files
committed
Merge branch 'michal/ssh/fix-sftp-slowdown/ERIERL-1273/OTP-19839' into maint
* michal/ssh/fix-sftp-slowdown/ERIERL-1273/OTP-19839: Limit buffer and packet_size instead of recbuf for hello message
2 parents afb30d0 + 39efa97 commit 9b7f0f4

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

lib/ssh/src/ssh_connection_handler.erl

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -615,17 +615,18 @@ handle_event(cast, socket_control, {wait_for_socket, Role},
615615
handle_event(internal, socket_ready, {hello,_}=StateName, #data{ssh_params = Ssh0} = D) ->
616616
VsnMsg = ssh_transport:hello_version_msg(string_version(Ssh0)),
617617
send_bytes(VsnMsg, D),
618-
case inet:getopts(Socket=D#data.socket, [recbuf]) of
619-
{ok, [{recbuf,Size}]} ->
618+
case inet:getopts(Socket=D#data.socket, [buffer]) of
619+
{ok, [{buffer,Size}]} ->
620620
%% Set the socket to the hello text line handling mode:
621621
inet:setopts(Socket, [{packet, line},
622622
{active, once},
623623
% Expecting the version string which might
624624
% be max ?MAX_PROTO_VERSION bytes:
625-
{recbuf, ?MAX_PROTO_VERSION},
625+
{buffer, ?MAX_PROTO_VERSION},
626+
{packet_size, ?MAX_PROTO_VERSION},
626627
{nodelay,true}]),
627628
Time = ?GET_OPT(hello_timeout, Ssh0#ssh.opts, infinity),
628-
{keep_state, D#data{inet_initial_recbuf_size=Size}, [{state_timeout,Time,no_hello_received}] };
629+
{keep_state, D#data{inet_initial_buffer_size=Size}, [{state_timeout,Time,no_hello_received}] };
629630

630631
Other ->
631632
?call_disconnectfun_and_log_cond("Option return",
@@ -654,11 +655,12 @@ handle_event(internal, {version_exchange,Version}, {hello,Role}, D0) ->
654655
case handle_version(NumVsn, StrVsn, D0#data.ssh_params) of
655656
{ok, Ssh1} ->
656657
%% Since the hello part is finished correctly, we set the
657-
%% socket to the packet handling mode (including recbuf size):
658+
%% socket to the packet handling mode (including buffer size):
658659
inet:setopts(D0#data.socket, [{packet,0},
659660
{mode,binary},
660661
{active, once},
661-
{recbuf, D0#data.inet_initial_recbuf_size}]),
662+
{buffer, D0#data.inet_initial_buffer_size},
663+
{packet_size, 0}]),
662664
{KeyInitMsg, SshPacket, Ssh} = ssh_transport:key_exchange_init_msg(Ssh1),
663665
send_bytes(SshPacket, D0),
664666
D = D0#data{ssh_params = Ssh,

lib/ssh/src/ssh_fsm.hrl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
| undefined,
6060
last_size_rekey = 0 :: non_neg_integer(),
6161
event_queue = [] :: list(),
62-
inet_initial_recbuf_size :: pos_integer()
62+
inet_initial_buffer_size :: pos_integer()
6363
| undefined
6464
}).
6565

0 commit comments

Comments
 (0)