aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErlang/OTP <[email protected]>2015-06-01 12:06:31 +0200
committerErlang/OTP <[email protected]>2015-06-01 12:06:31 +0200
commit6ba8e4dcff857ef6933a7c91c7d85c165977a970 (patch)
tree064b0dd1a8ceab341d69e65d440dc074a369f5d8
parent3bdac8db40a1e57699514fad9d5e93b79b01a3ed (diff)
parent92a9ddf4c4169c486c1b3bfe958464a90b553289 (diff)
downloadotp-6ba8e4dcff857ef6933a7c91c7d85c165977a970.tar.gz
otp-6ba8e4dcff857ef6933a7c91c7d85c165977a970.tar.bz2
otp-6ba8e4dcff857ef6933a7c91c7d85c165977a970.zip
Merge branch 'ia/ssh/recvbuf/OTP-12782' into maint-17
* ia/ssh/recvbuf/OTP-12782: ssh: handle that inet:getopts(Socket, [recbuf]) may return {ok, []}
-rw-r--r--lib/ssh/src/ssh_connection_handler.erl19
1 files changed, 16 insertions, 3 deletions
diff --git a/lib/ssh/src/ssh_connection_handler.erl b/lib/ssh/src/ssh_connection_handler.erl
index 0f6162db60..d4bbb0b32e 100644
--- a/lib/ssh/src/ssh_connection_handler.erl
+++ b/lib/ssh/src/ssh_connection_handler.erl
@@ -326,9 +326,13 @@ info(ConnectionHandler, ChannelProcess) ->
hello(socket_control, #state{socket = Socket, ssh_params = Ssh} = State) ->
VsnMsg = ssh_transport:hello_version_msg(string_version(Ssh)),
send_msg(VsnMsg, State),
- {ok, [{recbuf, Size}]} = inet:getopts(Socket, [recbuf]),
- inet:setopts(Socket, [{packet, line}, {active, once}, {recbuf, ?MAX_PROTO_VERSION}]),
- {next_state, hello, State#state{recbuf = Size}};
+ case getopt(recbuf, Socket) of
+ {ok, Size} ->
+ inet:setopts(Socket, [{packet, line}, {active, once}, {recbuf, ?MAX_PROTO_VERSION}]),
+ {next_state, hello, State#state{recbuf = Size}};
+ {error, Reason} ->
+ {stop, {shutdown, Reason}, State}
+ end;
hello({info_line, _Line},#state{role = client, socket = Socket} = State) ->
%% The server may send info lines before the version_exchange
@@ -1719,3 +1723,12 @@ start_timeout(_,_, infinity) ->
ok;
start_timeout(Channel, From, Time) ->
erlang:send_after(Time, self(), {timeout, {Channel, From}}).
+
+getopt(Opt, Socket) ->
+ case inet:getopts(Socket, [Opt]) of
+ {ok, [{Opt, Value}]} ->
+ {ok, Value};
+ Other ->
+ {error, {unexpected_getopts_return, Other}}
+ end.
+