<div dir="ltr"><div style="font-family:arial,sans-serif;font-size:12.666666984558105px"><span lang="en">Hello, friends!</span></div><div style="font-family:arial,sans-serif;font-size:12.666666984558105px"><span lang="en"><br>
</span></div><div style="font-family:arial,sans-serif;font-size:12.666666984558105px"><span lang="en">ssh-3.0 (and below) has the following bug: </span></div><div style="font-family:arial,sans-serif;font-size:12.666666984558105px">
<span lang="en">If we have a lot of SSH sessions, we will be much more timeout. (4 seconds per each instance).</span></div><div style="font-family:arial,sans-serif;font-size:12.666666984558105px"><br></div><div style="font-family:arial,sans-serif;font-size:12.666666984558105px">
When trying to complete the ssh-application, process, was created by a call ssh_connection_handler:init/1, receives a message of the form {'EXIT', Pid, shutdown}. After receiving this message, will been completed a series of calls ssh_connetion_handler:terminate, which ends the call ssh_connetion_handler:terminate_subsystem/1->ssh_system_sup:stop_subsystem/2 . At the end of the chain calls the supervisor:which_children (SystemSup).<br>
</div><div style="font-family:arial,sans-serif;font-size:12.666666984558105px"><span lang="en">In this place there is a deadlock, because SystemSup process awaits the completion message. Since SystemSup not receive the completion message, it completes them forcibly by timeout (after 4 second)</span></div>
<div><br></div><div style="font-family:arial,sans-serif;font-size:12.666666984558105px"><span lang="en">How can I see, in the ssh_connection_handler.erl module, invalid method terminate by initiative supervisor. In case of shutdown, we must not call terminate_subsytem/1<br>
<br>Suggest a patch that fixes this problem :</span><span lang="en"><span title="Предлагаю патч, который устраняет данную проблему:"></span></span></div><div style="font-family:arial,sans-serif;font-size:12.666666984558105px">
<br>--- src/ssh_connection_handler.erl<br>+++ src/ssh_connection_handler.erl<br>@@ -904,26 +904,31 @@<br> socket = Socket}) -><br> terminate_subsytem(Connection),<br> (catch Transport:close(Socket)),<br>
ok;<br> <br> %% Terminated by supervisor<br>-terminate(shutdown, StateName, #state{ssh_params = Ssh0} = State) -><br>+terminate(shutdown, _StateName, #state{ssh_params = Ssh0, <br>+ transport_cb = Transport,<br>
+ socket = Socket} = State) -><br> DisconnectMsg = <br> #ssh_msg_disconnect{code = ?SSH_DISCONNECT_BY_APPLICATION,<br> description = "Application shutdown",<br>
language = "en"},<br>- {SshPacket, Ssh} = ssh_transport:ssh_packet(DisconnectMsg, Ssh0),<br>+ {SshPacket, _Ssh} = ssh_transport:ssh_packet(DisconnectMsg, Ssh0),<br> send_msg(SshPacket, State),<br>
- terminate(normal, StateName, State#state{ssh_params = Ssh});<br>+ (catch Transport:close(Socket)),<br>+ ok;<br> <br> terminate({shutdown, #ssh_msg_disconnect{} = Msg}, StateName,<br> #state{ssh_params = Ssh0} = State) -><br>
{SshPacket, Ssh} = ssh_transport:ssh_packet(Msg, Ssh0),<br> send_msg(SshPacket, State),<br></div><div style="font-family:arial,sans-serif;font-size:12.666666984558105px"><br></div><div style="font-family:arial,sans-serif;font-size:12.666666984558105px">
<br></div>-- <br>---------------------------------------------<br>With best regards,<br>Alexander.
</div>