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_gen_conn.erl | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'lib/common_test/src/ct_gen_conn.erl') diff --git a/lib/common_test/src/ct_gen_conn.erl b/lib/common_test/src/ct_gen_conn.erl index 5aab4dd2dd..12d5b5b9fd 100644 --- a/lib/common_test/src/ct_gen_conn.erl +++ b/lib/common_test/src/ct_gen_conn.erl @@ -27,7 +27,7 @@ -compile(export_all). -export([start/4, stop/1]). --export([call/2, do_within_time/2]). +-export([call/2, call/3, do_within_time/2]). -ifdef(debug). -define(dbg,true). @@ -97,7 +97,7 @@ start(Name,Address,InitData,CallbackMod) -> %%% %%% @doc Close the telnet connection and stop the process managing it. stop(Pid) -> - call(Pid,stop). + call(Pid,stop,5000). %%%----------------------------------------------------------------- %%% @spec log(Heading,Format,Args) -> ok @@ -176,7 +176,10 @@ do_within_time(Fun,Timeout) -> %%%================================================================= %%% Internal functions -call(Pid,Msg) -> +call(Pid, Msg) -> + call(Pid, Msg, infinity). + +call(Pid, Msg, Timeout) -> MRef = erlang:monitor(process,Pid), Ref = make_ref(), Pid ! {Msg,{self(),Ref}}, @@ -191,6 +194,12 @@ call(Pid,Msg) -> end; {'DOWN',MRef,process,_,Reason} -> {error,{process_down,Pid,Reason}} + after Timeout -> + log("ct_gen_conn", + "Connection process ~p not responding. Killing now!", + [Pid]), + exit(Pid, kill), + {error,{process_down,Pid,forced_termination}} end. return({To,Ref},Result) -> -- cgit v1.2.3