File 0424-Fixed-some-review-comments.patch of Package erlang
From 760c8380300638ba7c09ffe5d37633bf3a0b2eec Mon Sep 17 00:00:00 2001
From: Yaroslav Maslennikov <ymaslenn@cisco.com>
Date: Tue, 22 Apr 2025 12:00:38 +0200
Subject: [PATCH 4/5] Fixed some review comments
---
lib/ssh/src/ssh_connection_handler.erl | 1 -
lib/ssh/test/ssh_connection_SUITE.erl | 27 ++++++++++++++------------
lib/ssh/test/ssh_protocol_SUITE.erl | 18 ++++++++---------
3 files changed, 24 insertions(+), 22 deletions(-)
diff --git a/lib/ssh/src/ssh_connection_handler.erl b/lib/ssh/src/ssh_connection_handler.erl
index 222969e365..f91fd55631 100644
--- a/lib/ssh/src/ssh_connection_handler.erl
+++ b/lib/ssh/src/ssh_connection_handler.erl
@@ -2087,7 +2087,6 @@ cond_set_idle_timer(D) ->
end.
channel_close_timer(D, ChannelId) ->
- %{{timeout, {channel_close, ChannelId}}, 3000, none}. %?GET_OPT(idle_time, (D#data.ssh_params)#ssh.opts), none}.
{{timeout, {channel_close, ChannelId}},
?GET_OPT(channel_close_timeout, (D#data.ssh_params)#ssh.opts), none}.
diff --git a/lib/ssh/test/ssh_connection_SUITE.erl b/lib/ssh/test/ssh_connection_SUITE.erl
index 130b5d614f..c93c1c9178 100644
--- a/lib/ssh/test/ssh_connection_SUITE.erl
+++ b/lib/ssh/test/ssh_connection_SUITE.erl
@@ -1999,37 +1999,40 @@ handler_down_before_open(Config) ->
Other ->
ct:log("~p:~p Got unexpected ~p~nExpect: ~p~n",
[?MODULE,?LINE, Other, {ssh_cm, ConnectionRef,
- {data, ChannelId0, 0, Expect}}]),
+ {data, ChannelId0, 0, Expect}}]),
{fail, "Unexpected data"}
after 5000 ->
{fail, "Exec Timeout"}
end;
- stop -> {fail, "Stopped"}
+ stop -> {fail, "Stopped"}
end,
Parent ! {self(), Result}
end),
try
TestResult = receive
{ExecChannelPid, channelId, ExId} ->
- ct:log("~p:~p Channel that should stay: ~p pid ~p", [?MODULE, ?LINE, ExId, ExecChannelPid]),
+ ct:log("~p:~p Channel that should stay: ~p pid ~p",
+ [?MODULE, ?LINE, ExId, ExecChannelPid]),
+ %% This is sent by the echo subsystem as a reaction to channel1 above
ConnPeer = receive {conn_peer, CM} -> CM end,
- %% The sole purpose of this channel is to go down before the opening procedure is complete
+ %% The sole purpose of this channel is to go down
+ %% before the opening procedure is complete
DownChannelPid = spawn(
fun() ->
ct:log("~p:~p open channel (incomplete)",[?MODULE,?LINE]),
Parent ! {self(), channelId, ok},
%% This is to prevent the peer from answering our 'channel-open' in time
sys:suspend(ConnPeer),
- {ok, _ChannelId} = ssh_connection:session_channel(ConnectionRef, infinity),
- ct:log("~p:~p open incomplete channel done - should not have happened",[?MODULE,?LINE]),
- Parent ! {self(), {fail, "Unexpected channel success"}}
+ {ok, _} = ssh_connection:session_channel(ConnectionRef, infinity)
end),
MonRef = erlang:monitor(process, DownChannelPid),
receive
{DownChannelPid, channelId, ok} ->
- ct:log("~p:~p Channel handler that won't continue: pid ~p", [?MODULE, ?LINE, DownChannelPid]),
+ ct:log("~p:~p Channel handler that won't continue: pid ~p",
+ [?MODULE, ?LINE, DownChannelPid]),
ensure_channels(ConnectionRef, 2),
- channel_down_sequence(DownChannelPid, ExecChannelPid, ExId, MonRef, ConnectionRef, ConnPeer)
+ channel_down_sequence(DownChannelPid, ExecChannelPid,
+ ExId, MonRef, ConnectionRef, ConnPeer)
end
end,
ensure_channels(ConnectionRef, 0)
@@ -2045,15 +2048,15 @@ ensure_channels(ConnRef, Expected) ->
do_ensure_channels(_ConnRef, NumExpected, NumExpected) ->
ok;
do_ensure_channels(ConnRef, NumExpected, _ChannelListLen) ->
- receive after 100 -> ok end,
+ ct:sleep(100),
{ok, ChannelList} = ssh_connection_handler:info(ConnRef),
do_ensure_channels(ConnRef, NumExpected, length(ChannelList)).
channel_down_sequence(DownChannelPid, ExecChannelPid, ExecChannelId, MonRef, ConnRef, Peer) ->
- ct:log("~p:~p sending order to go down", [?MODULE, ?LINE]),
+ ct:log("~p:~p sending order to ~p to go down", [?MODULE, ?LINE, DownChannelPid]),
exit(DownChannelPid, die),
receive {'DOWN', MonRef, _, _, _} -> ok end,
- ct:log("~p:~p order executed, sending order to proceed", [?MODULE, ?LINE]),
+ ct:log("~p:~p order executed, sending order to ~p to proceed", [?MODULE, ?LINE, Peer]),
%% Resume the peer connection to let it clean up among its channels
sys:resume(Peer),
ensure_channels(ConnRef, 1),
diff --git a/lib/ssh/test/ssh_protocol_SUITE.erl b/lib/ssh/test/ssh_protocol_SUITE.erl
index 449e2dd763..656edb7614 100644
--- a/lib/ssh/test/ssh_protocol_SUITE.erl
+++ b/lib/ssh/test/ssh_protocol_SUITE.erl
@@ -1582,15 +1582,15 @@ channel_close_timeout(Config) ->
%% connect to it with a regular Erlang SSH client:
ChannelCloseTimeout = 3000,
{ok, ConnRef} = std_connect(HostPort, Config,
- [{preferred_algorithms,[{kex,[?DEFAULT_KEX]},
- {cipher,?DEFAULT_CIPHERS}
- ]},
- {channel_close_timeout, ChannelCloseTimeout},
- {idle_time, 50000}
- ]
- ),
- {ok, Channel0} = ssh_connection:session_channel(ConnRef, 50000),
- {ok, Channel1} = ssh_connection:session_channel(ConnRef, 50000),
+ [{preferred_algorithms,[{kex,[?DEFAULT_KEX]},
+ {cipher,?DEFAULT_CIPHERS}
+ ]},
+ {channel_close_timeout, ChannelCloseTimeout},
+ {idle_time, 50000}
+ ]
+ ),
+ {ok, Channel0} = ssh_connection:session_channel(ConnRef, 50000),
+ {ok, _Channel1} = ssh_connection:session_channel(ConnRef, 50000),
%% Close the channel from client side, the server does not reply with 'channel-close'
%% After the timeout, the client should drop the cache entry
_ = ssh_connection:close(ConnRef, Channel0),
--
2.43.0