diff options
author | Peter Andersson <[email protected]> | 2013-08-23 15:58:56 +0200 |
---|---|---|
committer | Peter Andersson <[email protected]> | 2013-09-02 12:14:01 +0200 |
commit | 32fae66768d11bc62ff75705e1d5a6ebe2978432 (patch) | |
tree | b960aaff4683842155d5abeea3521dde19e7c0b4 /lib | |
parent | a5c108b7eed9badc3b0ea0b4bad3af4bf36bc55b (diff) | |
download | otp-32fae66768d11bc62ff75705e1d5a6ebe2978432.tar.gz otp-32fae66768d11bc62ff75705e1d5a6ebe2978432.tar.bz2 otp-32fae66768d11bc62ff75705e1d5a6ebe2978432.zip |
Fix timing related problem
Diffstat (limited to 'lib')
-rw-r--r-- | lib/test_server/src/test_server_io.erl | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/lib/test_server/src/test_server_io.erl b/lib/test_server/src/test_server_io.erl index a92dbf5887..62af3d5b28 100644 --- a/lib/test_server/src/test_server_io.erl +++ b/lib/test_server/src/test_server_io.erl @@ -274,8 +274,14 @@ handle_call(reset_state, _From, #st{fds=Fds,tags=Tags,gls=Gls, end, Tags), GlList = gb_sets:to_list(Gls), [test_server_gl:stop(GL) || GL <- GlList], - timer:sleep(2000), - [exit(GL, kill) || GL <- GlList], + timer:sleep(100), + case lists:filter(fun(GlPid) -> is_process_alive(GlPid) end, GlList) of + [] -> + ok; + _ -> + timer:sleep(2000), + [exit(GL, kill) || GL <- GlList] + end, Empty = gb_trees:empty(), {ok,Shared} = test_server_gl:start_link(), {reply,ok,#st{fds=Empty,shared_gl=Shared,gls=gb_sets:empty(), @@ -304,7 +310,7 @@ handle_call({stop,FdTags}, From, #st{fds=Fds0,tags=Tags0, end, {Fds0,Tags0}, FdTags), %% Give the users of the surviving group leaders some %% time to finish. - erlang:send_after(2000, self(), stop_group_leaders), + erlang:send_after(1000, self(), stop_group_leaders), {noreply,St#st{fds=Fds1,tags=Tags1}}; handle_call(finish, From, St) -> gen_server:reply(From, ok), @@ -325,8 +331,15 @@ handle_info({'EXIT',_Pid,Reason}, _St) -> exit(Reason); handle_info(stop_group_leaders, #st{gls=Gls}=St) -> %% Stop the remaining group leaders. - [test_server_gl:stop(GL) || GL <- gb_sets:to_list(Gls)], - erlang:send_after(2000, self(), kill_group_leaders), + GlPids = gb_sets:to_list(Gls), + [test_server_gl:stop(GL) || GL <- GlPids], + timer:sleep(100), + Wait = + case lists:filter(fun(GlPid) -> is_process_alive(GlPid) end, GlPids) of + [] -> 0; + _ -> 2000 + end, + erlang:send_after(Wait, self(), kill_group_leaders), {noreply,St}; handle_info(kill_group_leaders, #st{gls=Gls,stopping=From, pending_ops=Ops}=St) -> |