From e13b9c155d266946be86e52ba9344f43ca8640cc Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Mon, 9 Jul 2012 20:54:01 +0200 Subject: Fix deadlock problem in connection handling --- lib/common_test/src/ct_ssh.erl | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'lib/common_test/src/ct_ssh.erl') diff --git a/lib/common_test/src/ct_ssh.erl b/lib/common_test/src/ct_ssh.erl index 2e8e46d184..09cd4ef02a 100644 --- a/lib/common_test/src/ct_ssh.erl +++ b/lib/common_test/src/ct_ssh.erl @@ -235,7 +235,7 @@ connect(KeyOrName, ConnType, ExtraOpts) -> disconnect(SSH) -> case get_handle(SSH) of {ok,Pid} -> - try_log(heading(disconnect,SSH), "Handle: ~p", [Pid]), + try_log(heading(disconnect,SSH), "Handle: ~p", [Pid], 5000), case ct_gen_conn:stop(Pid) of {error,{process_down,Pid,noproc}} -> {error,already_closed}; @@ -1228,11 +1228,11 @@ terminate(SSHRef, State) -> case State#state.conn_type of ssh -> try_log(heading(disconnect_ssh,State#state.target), - "SSH Ref: ~p",[SSHRef]), + "SSH Ref: ~p",[SSHRef], 5000), ssh:close(SSHRef); sftp -> try_log(heading(disconnect_sftp,State#state.target), - "SFTP Ref: ~p",[SSHRef]), + "SFTP Ref: ~p",[SSHRef], 5000), ssh_sftp:stop_channel(SSHRef) end. @@ -1337,9 +1337,12 @@ get_handle(SSH) -> %%%----------------------------------------------------------------- %%% call(SSH, Msg) -> + call(SSH, Msg, infinity). + +call(SSH, Msg, Timeout) -> case get_handle(SSH) of {ok,Pid} -> - ct_gen_conn:call(Pid, Msg); + ct_gen_conn:call(Pid, Msg, Timeout); Error -> Error end. @@ -1368,11 +1371,16 @@ log(Heading, Str, Args) -> %%%----------------------------------------------------------------- %%% try_log(Heading, Str, Args) -> - case ct_util:is_silenced(ssh) of + try_log(Heading, Str, Args, infinity). + +try_log(Heading, Str, Args, Timeout) -> + case ct_util:is_silenced(ssh, Timeout) of true -> ok; false -> - ct_gen_conn:log(Heading, Str, Args) + ct_gen_conn:log(Heading, Str, Args); + _Error -> + ok end. %%%----------------------------------------------------------------- -- cgit v1.2.3