ssh

Claes Wikström klacke@REDACTED
Mon May 22 14:06:27 CEST 2006


Here is yet another bug fix for ssh. The problem
arise when we close an ssh connection, WE cannot call close
since the other end may be talking the ssh protocol to us.
If so, other end sends data to us, our end is closed and
our kernel replies with RST and everything goes wrong.

We MUST call shutdown.

[klacke@REDACTED]src > svn diff .
Index: ssh_transport.erl
===================================================================
--- ssh_transport.erl   (revision 2964)
+++ ssh_transport.erl   (working copy)
@@ -747,8 +747,15 @@

         {ssh_call, From, close} ->
             ?dbg(true, "Call: close from ~p\n", [From]),
-           gen_tcp:close(S),
-           reply(From, ok),
+           gen_tcp:shutdown(S, write),
+           inet:setopts(S, [{active, true}]),
+           receive
+               {tcp_closed, S} ->
+                   reply(From, ok)
+           after 5000 ->
+                   gen_tcp:close(S),
+                   reply(From, ok)
+           end,
             ok;

         {ssh_call, From, peername} ->


/klacke

-- 
Claes Wikstrom                        -- Caps lock is nowhere and
http://www.tail-f.com                 -- everything is under control
cellphone: +46 70 2097763



More information about the erlang-patches mailing list