aboutsummaryrefslogtreecommitdiffstats
path: root/erts/preloaded/src
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2018-04-10 10:17:30 +0200
committerLukas Larsson <[email protected]>2018-04-10 10:17:30 +0200
commit994a1229418c34846c1e2b5d08e72aa30ac5fa5f (patch)
treec6569886fcaa63a8af02455c5ff5953c79e5d260 /erts/preloaded/src
parent4c29e451d8839fbfd3733444640a761c2c9b1f2a (diff)
downloadotp-994a1229418c34846c1e2b5d08e72aa30ac5fa5f.tar.gz
otp-994a1229418c34846c1e2b5d08e72aa30ac5fa5f.tar.bz2
otp-994a1229418c34846c1e2b5d08e72aa30ac5fa5f.zip
erts: Flush messages before doing init restart
If messages are not flushed they would cause problems when the system is booting. For instance module load requests would be issued before the prim loader has been launched.
Diffstat (limited to 'erts/preloaded/src')
-rw-r--r--erts/preloaded/src/init.erl9
1 files changed, 9 insertions, 0 deletions
diff --git a/erts/preloaded/src/init.erl b/erts/preloaded/src/init.erl
index e0ae6b1656..0c74169e97 100644
--- a/erts/preloaded/src/init.erl
+++ b/erts/preloaded/src/init.erl
@@ -545,6 +545,8 @@ stop(Reason,State) ->
do_stop(Reason,State1).
do_stop(restart,#state{start = Start, flags = Flags, args = Args}) ->
+ %% Make sure we don't have any outstanding messages before doing the restart.
+ flush(),
boot(Start,Flags,Args);
do_stop(reboot,_) ->
halt();
@@ -560,6 +562,13 @@ clear_system(BootPid,State) ->
shutdown_pids(Heart,BootPid,State),
unload(Heart).
+flush() ->
+ receive
+ _M -> flush()
+ after 0 ->
+ ok
+ end.
+
stop_heart(State) ->
case get_heart(State#state.kernel) of
false ->