diff options
author | Sverker Eriksson <[email protected]> | 2016-11-17 17:35:17 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2016-11-30 14:17:09 +0100 |
commit | 20eea6a99b25b99db728fcae5b8303739e5c1cc8 (patch) | |
tree | 21236e0756ecca2649a869531d2a476491a5e0ee /erts/emulator/test | |
parent | 15789e168811d6e6bed082ea7c64db93e1d968e8 (diff) | |
download | otp-20eea6a99b25b99db728fcae5b8303739e5c1cc8.tar.gz otp-20eea6a99b25b99db728fcae5b8303739e5c1cc8.tar.bz2 otp-20eea6a99b25b99db728fcae5b8303739e5c1cc8.zip |
erts: Fix race in code_SUITE:call_purged_fun_*
Must wait for process P0 to enter fun F2
before starting purge, to make sure it's not suspended.
Diffstat (limited to 'erts/emulator/test')
-rw-r--r-- | erts/emulator/test/code_SUITE_data/call_purged_fun_tester.erl | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/erts/emulator/test/code_SUITE_data/call_purged_fun_tester.erl b/erts/emulator/test/code_SUITE_data/call_purged_fun_tester.erl index 10d00b7d2a..699f0c1161 100644 --- a/erts/emulator/test/code_SUITE_data/call_purged_fun_tester.erl +++ b/erts/emulator/test/code_SUITE_data/call_purged_fun_tester.erl @@ -39,14 +39,16 @@ do_it(Priv, Data, Type, Opts) -> ets:insert(T, {my_fun,my_code_test2:make_fun(4711)}), ets:insert(T, {my_fun2,my_code_test2:make_fun2()}), - spawn(fun () -> - [{my_fun2,F2}] = ets:lookup(T, my_fun2), - F2(fun () -> - receive after infinity -> ok end - end, - fun () -> ok end), - exit(completed) - end), + Papa = self(), + {P0,M0} = spawn_monitor(fun () -> + [{my_fun2,F2}] = ets:lookup(T, my_fun2), + F2(fun () -> + Papa ! {self(),"going to sleep"}, + receive {Papa,"wake up"} -> ok end + end, + fun () -> ok end), + exit(completed) + end), ?line PurgeType = case Type of code_gone -> @@ -60,6 +62,10 @@ do_it(Priv, Data, Type, Opts) -> ?line true = erlang:delete_module(my_code_test2), + ?line ok = receive {P0, "going to sleep"} -> ok + after 1000 -> timeout + end, + ?line Purge = start_purge(my_code_test2, PurgeType), ?line {P1, M1} = spawn_monitor(fun () -> @@ -110,9 +116,12 @@ do_it(Priv, Data, Type, Opts) -> case Type of code_there -> - ?line false = complete_purge(Purge); + ?line false = complete_purge(Purge), + P0 ! {self(), "wake up"}, + ?line completed = wait_for_down(P0,M0); _ -> - ?line {true, true} = complete_purge(Purge) + ?line {true, true} = complete_purge(Purge), + ?line killed = wait_for_down(P0,M0) end, case Type of |