aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh
diff options
context:
space:
mode:
authorHans Nilsson <[email protected]>2017-02-15 17:00:09 +0100
committerHans Nilsson <[email protected]>2017-02-15 17:00:09 +0100
commit8fbb5b7c55c78f5696a3c504a1f7c164d5be3dc3 (patch)
tree89fa25c94d51e2a2ffdef5d5e1c52161a89e926a /lib/ssh
parentcd88d70ffb0f325fa84c8548b3dca1f7865ee86d (diff)
downloadotp-8fbb5b7c55c78f5696a3c504a1f7c164d5be3dc3.tar.gz
otp-8fbb5b7c55c78f5696a3c504a1f7c164d5be3dc3.tar.bz2
otp-8fbb5b7c55c78f5696a3c504a1f7c164d5be3dc3.zip
ssh: handle return values and exceptions from ssh_acceptor:handle_connection
Diffstat (limited to 'lib/ssh')
-rw-r--r--lib/ssh/src/ssh.erl16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/ssh/src/ssh.erl b/lib/ssh/src/ssh.erl
index 657cf4c62d..f572e02d5f 100644
--- a/lib/ssh/src/ssh.erl
+++ b/lib/ssh/src/ssh.erl
@@ -366,8 +366,7 @@ do_start_daemon(Socket, SshOptions, SocketOptions) ->
{error, {already_started, _}} ->
{error, eaddrinuse};
Result = {ok,_} ->
- ssh_acceptor:handle_connection(Callback, Host, Port, Opts, Socket),
- Result;
+ call_ssh_acceptor_handle_connection(Callback, Host, Port, Opts, Socket, Result);
Result = {error, _} ->
Result
catch
@@ -380,8 +379,7 @@ do_start_daemon(Socket, SshOptions, SocketOptions) ->
{error, {already_started, _}} ->
{error, eaddrinuse};
{ok, _} ->
- ssh_acceptor:handle_connection(Callback, Host, Port, Opts, Socket),
- {ok, Sup};
+ call_ssh_acceptor_handle_connection(Callback, Host, Port, Opts, Socket, {ok, Sup});
Other ->
Other
end
@@ -451,6 +449,16 @@ do_start_daemon(Host0, Port0, SshOptions, SocketOptions) ->
end
end.
+call_ssh_acceptor_handle_connection(Callback, Host, Port, Opts, Socket, DefaultResult) ->
+ try ssh_acceptor:handle_connection(Callback, Host, Port, Opts, Socket)
+ of
+ {error,Error} -> {error,Error};
+ _ -> DefaultResult
+ catch
+ C:R -> {error,{could_not_start_connection,{C,R}}}
+ end.
+
+
sync_request_control(false) ->
ok;
sync_request_control({LSock,Callback}) ->