aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test/src/ct_gen_conn.erl
diff options
context:
space:
mode:
authorPeter Andersson <[email protected]>2012-07-09 20:54:01 +0200
committerPeter Andersson <[email protected]>2012-07-09 20:54:01 +0200
commite13b9c155d266946be86e52ba9344f43ca8640cc (patch)
treedb0c460f2e5760aaa71c8e230286a6e50805a5e9 /lib/common_test/src/ct_gen_conn.erl
parentb6ba818603c8a6f0191fa43aa419f44d41a71436 (diff)
downloadotp-e13b9c155d266946be86e52ba9344f43ca8640cc.tar.gz
otp-e13b9c155d266946be86e52ba9344f43ca8640cc.tar.bz2
otp-e13b9c155d266946be86e52ba9344f43ca8640cc.zip
Fix deadlock problem in connection handling
Diffstat (limited to 'lib/common_test/src/ct_gen_conn.erl')
-rw-r--r--lib/common_test/src/ct_gen_conn.erl15
1 files changed, 12 insertions, 3 deletions
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) ->