aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Andersson <[email protected]>2014-10-10 17:29:52 +0200
committerPeter Andersson <[email protected]>2014-10-13 16:58:33 +0200
commita5a4794998d26e8be30b4d5f2d8665227c7e3153 (patch)
tree6980248ef22f51458d52ef32651744394e5b22d4
parente34a36c29118f86764cf3769c9ae8347c6a7d793 (diff)
downloadotp-a5a4794998d26e8be30b4d5f2d8665227c7e3153.tar.gz
otp-a5a4794998d26e8be30b4d5f2d8665227c7e3153.tar.bz2
otp-a5a4794998d26e8be30b4d5f2d8665227c7e3153.zip
Fix problem with buffered async io messages executed too late
-rw-r--r--lib/common_test/src/ct_logs.erl30
1 files changed, 27 insertions, 3 deletions
diff --git a/lib/common_test/src/ct_logs.erl b/lib/common_test/src/ct_logs.erl
index ca958ce854..2d32d441cb 100644
--- a/lib/common_test/src/ct_logs.erl
+++ b/lib/common_test/src/ct_logs.erl
@@ -730,6 +730,7 @@ logger_loop(State) ->
%% CtLog or unexpected_io log instead
unexpected_io(Pid,Category,Importance,
List,State),
+
logger_loop(State)
end;
{ct_log,_Fd,TCGLs} ->
@@ -849,12 +850,35 @@ print_to_log(async, FromPid, Category, TCGL, List, State) ->
IoFun = create_io_fun(FromPid, State),
fun() ->
test_server:permit_io(TCGL, self()),
- io:format(TCGL, "~ts", [lists:foldl(IoFun, [], List)])
+
+ %% Since asynchronous io gets can get buffered if
+ %% the file system is slow, there is also a risk that
+ %% the group leader has terminated before we get to
+ %% the io:format(GL, ...) call. We check this and
+ %% print "expired" messages to the unexpected io
+ %% log instead (best we can do).
+
+ case erlang:is_process_alive(TCGL) of
+ true ->
+ try io:format(TCGL, "~ts",
+ [lists:foldl(IoFun,[],List)]) of
+ _ -> ok
+ catch
+ _:terminated ->
+ unexpected_io(FromPid, Category,
+ ?MAX_IMPORTANCE,
+ List, State)
+ end;
+ false ->
+ unexpected_io(FromPid, Category,
+ ?MAX_IMPORTANCE,
+ List, State)
+ end
end;
true ->
fun() ->
- unexpected_io(FromPid,Category,?MAX_IMPORTANCE,
- List,State)
+ unexpected_io(FromPid, Category, ?MAX_IMPORTANCE,
+ List, State)
end
end,
case State#logger_state.async_print_jobs of