diff options
author | Zandra Hird <[email protected]> | 2015-05-05 15:03:26 +0200 |
---|---|---|
committer | Zandra Hird <[email protected]> | 2015-05-05 15:06:07 +0200 |
commit | 66260d0606fcbaad3d5179288fea90cfe546cbbe (patch) | |
tree | 03859862bc2b6d482cfffddca6fa2d65b99ba9a5 /lib/ssh/src | |
parent | d6421c98edf2cdd5c3e27c2c7f7a2f59b17487ab (diff) | |
parent | c08c4a88a73453bd60fb93d0462482a6afc50544 (diff) | |
download | otp-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/src')
-rw-r--r-- | lib/ssh/src/ssh_sftp.erl | 13 |
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}; |