diff options
author | Hans Nilsson <[email protected]> | 2017-02-16 17:54:23 +0100 |
---|---|---|
committer | Hans Nilsson <[email protected]> | 2017-02-16 17:54:23 +0100 |
commit | 818989e624cebf061c1fc6311080350a95cb1e66 (patch) | |
tree | e00f8d8fed54e9dbeaa11a1d393377c9e7cb242f /lib/ssh | |
parent | 66cda469630d5ce5b27493355b96c6d6e225f86b (diff) | |
parent | 8fbb5b7c55c78f5696a3c504a1f7c164d5be3dc3 (diff) | |
download | otp-818989e624cebf061c1fc6311080350a95cb1e66.tar.gz otp-818989e624cebf061c1fc6311080350a95cb1e66.tar.bz2 otp-818989e624cebf061c1fc6311080350a95cb1e66.zip |
Merge branch 'hans/ssh/ssh_acceptor_bug/OTP-14108' into maint
Diffstat (limited to 'lib/ssh')
-rw-r--r-- | lib/ssh/src/ssh.erl | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/lib/ssh/src/ssh.erl b/lib/ssh/src/ssh.erl index f408086c0f..68d98d3875 100644 --- a/lib/ssh/src/ssh.erl +++ b/lib/ssh/src/ssh.erl @@ -280,9 +280,11 @@ valid_socket_to_use(Socket, Options) -> {error, {unsupported,L4}} end. -is_tcp_socket(Socket) -> {ok,[]} =/= inet:getopts(Socket, [delay_send]). - - +is_tcp_socket(Socket) -> + case inet:getopts(Socket, [delay_send]) of + {ok,[_]} -> true; + _ -> false + end. daemon_shell_opt(Options) -> case proplists:get_value(shell, Options) of @@ -317,6 +319,7 @@ start_daemon(Socket, Options) -> do_start_daemon(Socket, [{role,server}|SshOptions], SocketOptions) catch throw:bad_fd -> {error,bad_fd}; + throw:bad_socket -> {error,bad_socket}; _C:_E -> {error,{cannot_start_daemon,_C,_E}} end; {error,SockError} -> @@ -333,6 +336,7 @@ start_daemon(Host, Port, Options, Inet) -> do_start_daemon(Host, Port, [{role,server}|SshOptions] , [Inet|SocketOptions]) catch throw:bad_fd -> {error,bad_fd}; + throw:bad_socket -> {error,bad_socket}; _C:_E -> {error,{cannot_start_daemon,_C,_E}} end end. @@ -362,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 @@ -376,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 @@ -447,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}) -> |