aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh
diff options
context:
space:
mode:
authorZandra Hird <[email protected]>2015-05-05 15:03:26 +0200
committerZandra Hird <[email protected]>2015-05-05 15:06:07 +0200
commit66260d0606fcbaad3d5179288fea90cfe546cbbe (patch)
tree03859862bc2b6d482cfffddca6fa2d65b99ba9a5 /lib/ssh
parentd6421c98edf2cdd5c3e27c2c7f7a2f59b17487ab (diff)
parentc08c4a88a73453bd60fb93d0462482a6afc50544 (diff)
downloadotp-66260d0606fcbaad3d5179288fea90cfe546cbbe.tar.gz
otp-66260d0606fcbaad3d5179288fea90cfe546cbbe.tar.bz2
otp-66260d0606fcbaad3d5179288fea90cfe546cbbe.zip
Merge branch 'dotsimon/ssh_sftp_version_negotiation_timeout'
OTP-12708
Diffstat (limited to 'lib/ssh')
-rw-r--r--lib/ssh/src/ssh_sftp.erl13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/ssh/src/ssh_sftp.erl b/lib/ssh/src/ssh_sftp.erl
index c264eabc78..bab688f226 100644
--- a/lib/ssh/src/ssh_sftp.erl
+++ b/lib/ssh/src/ssh_sftp.erl
@@ -508,12 +508,12 @@ init([Cm, ChannelId, Options]) ->
%%--------------------------------------------------------------------
handle_call({{timeout, infinity}, wait_for_version_negotiation}, From,
#state{xf = #ssh_xfer{vsn = undefined} = Xf} = State) ->
- {noreply, State#state{xf = Xf#ssh_xfer{vsn = From}}};
+ {noreply, State#state{xf = Xf#ssh_xfer{vsn = {wait, From, undefined}}}};
handle_call({{timeout, Timeout}, wait_for_version_negotiation}, From,
#state{xf = #ssh_xfer{vsn = undefined} = Xf} = State) ->
- timer:send_after(Timeout, {timeout, undefined, From}),
- {noreply, State#state{xf = Xf#ssh_xfer{vsn = From}}};
+ TRef = erlang:send_after(Timeout, self(), {timeout, undefined, From}),
+ {noreply, State#state{xf = Xf#ssh_xfer{vsn = {wait, From, TRef}}}};
handle_call({_, wait_for_version_negotiation}, _, State) ->
{reply, ok, State};
@@ -865,7 +865,12 @@ do_handle_reply(#state{xf = Xf} = State,
case Xf#ssh_xfer.vsn of
undefined ->
ok;
- From ->
+ {wait, From, TRef} ->
+ if is_reference(TRef) ->
+ erlang:cancel_timer(TRef);
+ true ->
+ ok
+ end,
ssh_channel:reply(From, ok)
end,
State#state{xf = Xf#ssh_xfer{vsn = Version, ext = Ext}, rep_buf = Rest};