aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh/src/ssh_connection_handler.erl
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2014-10-17 11:49:38 +0200
committerHans Nilsson <[email protected]>2014-10-17 11:49:38 +0200
commit545a85827e65c9939b701a87b60adf7a58c373fa (patch)
tree524700e4589df9943f70037203821fef22d7c4fe /lib/ssh/src/ssh_connection_handler.erl
parenta4cd7efbbbf174ae283cfac60a8e5492e340e3a6 (diff)
downloadotp-545a85827e65c9939b701a87b60adf7a58c373fa.tar.gz
otp-545a85827e65c9939b701a87b60adf7a58c373fa.tar.bz2
otp-545a85827e65c9939b701a87b60adf7a58c373fa.zip
ssh: reduce amount of printouts
Diffstat (limited to 'lib/ssh/src/ssh_connection_handler.erl')
-rw-r--r--lib/ssh/src/ssh_connection_handler.erl25
1 files changed, 16 insertions, 9 deletions
diff --git a/lib/ssh/src/ssh_connection_handler.erl b/lib/ssh/src/ssh_connection_handler.erl
index e9d35c4c4c..678ec89e44 100644
--- a/lib/ssh/src/ssh_connection_handler.erl
+++ b/lib/ssh/src/ssh_connection_handler.erl
@@ -176,11 +176,18 @@ init([Role, Socket, SshOpts]) ->
end.
%% Temporary fix for the Nessus error. SYN-> <-SYNACK ACK-> RST-> ?
-error(_Event, {Error, %%={badmatch,{error,enotconn}},
- State=#state{socket=Socket,
- transport_cb=Transport}}) ->
- (catch Transport:close(Socket)),
- {stop, {shutdown,init,Error}, State}.
+error(_Event, {Error,State=#state{}}) ->
+ case Error of
+ {badmatch,{error,enotconn}} ->
+ %% {error,enotconn} probably from inet:peername in
+ %% init_ssh(server,..)/5 called from init/1
+ {stop, {shutdown,"TCP connenction to server was prematurely closed by the client"}, State};
+ _ ->
+ {stop, {shutdown,{init,Error}}, State}
+ end;
+error(Event, State) ->
+ %% State deliberately not checked beeing #state. This is a panic-clause...
+ {stop, {shutdown,{init,{spurious_error,Event}}}, State}.
%%--------------------------------------------------------------------
-spec open_channel(pid(), string(), iodata(), integer(), integer(),
@@ -944,6 +951,10 @@ terminate(normal, _, #state{transport_cb = Transport,
(catch Transport:close(Socket)),
ok;
+terminate({shutdown,{init,Reason}}, StateName, State) ->
+ error_logger:info_report(io_lib:format("Erlang ssh in connection handler init: ~p~n",[Reason])),
+ terminate(normal, StateName, State);
+
%% Terminated by supervisor
terminate(shutdown, StateName, #state{ssh_params = Ssh0} = State) ->
DisconnectMsg =
@@ -963,10 +974,6 @@ terminate({shutdown, #ssh_msg_disconnect{} = Msg}, StateName,
terminate({shutdown, _}, StateName, State) ->
terminate(normal, StateName, State);
-terminate({shutdown,init,Reason}, StateName, State) ->
- error_logger:info_report(io_lib:format("Erlang ssh in connection handler init: ~p~n",[Reason])),
- terminate(normal, StateName, State);
-
terminate(Reason, StateName, #state{ssh_params = Ssh0, starter = _Pid,
connection_state = Connection} = State) ->
terminate_subsytem(Connection),