aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib
diff options
context:
space:
mode:
authorRaimo Niskanen <[email protected]>2016-04-27 13:58:07 +0200
committerRaimo Niskanen <[email protected]>2016-04-27 13:58:07 +0200
commit3c39afdc491dff6b90f5fff7d699850d5b2e112f (patch)
treef2a1ab15c7939eeb95d84c851adf7eb34f266d32 /lib/stdlib
parent840afcb34d7f3bcd9349bbf6834c95352334a274 (diff)
downloadotp-3c39afdc491dff6b90f5fff7d699850d5b2e112f.tar.gz
otp-3c39afdc491dff6b90f5fff7d699850d5b2e112f.tar.bz2
otp-3c39afdc491dff6b90f5fff7d699850d5b2e112f.zip
Fix callback mode after code change not used
Diffstat (limited to 'lib/stdlib')
-rw-r--r--lib/stdlib/src/gen_statem.erl5
-rw-r--r--lib/stdlib/test/gen_statem_SUITE.erl10
2 files changed, 12 insertions, 3 deletions
diff --git a/lib/stdlib/src/gen_statem.erl b/lib/stdlib/src/gen_statem.erl
index 36476b56ae..ffb6e4babc 100644
--- a/lib/stdlib/src/gen_statem.erl
+++ b/lib/stdlib/src/gen_statem.erl
@@ -639,7 +639,10 @@ system_code_change(
{NewCallbackMode,NewState,NewData} ->
callback_mode(NewCallbackMode) orelse
error({callback_mode,NewCallbackMode}),
- {ok,S#{state := NewState, data := NewData}};
+ {ok,
+ S#{callback_mode := NewCallbackMode,
+ state := NewState,
+ data := NewData}};
{ok,_} = Error ->
error({case_clause,Error});
Error ->
diff --git a/lib/stdlib/test/gen_statem_SUITE.erl b/lib/stdlib/test/gen_statem_SUITE.erl
index 3deb5fd986..364314f91b 100644
--- a/lib/stdlib/test/gen_statem_SUITE.erl
+++ b/lib/stdlib/test/gen_statem_SUITE.erl
@@ -634,12 +634,14 @@ sys1(Config) ->
stop_it(Pid).
code_change(Config) ->
+ Mode = handle_event_function,
{ok,Pid} = gen_statem:start(?MODULE, start_arg(Config, []), []),
{idle,data} = sys:get_state(Pid),
sys:suspend(Pid),
- sys:change_code(Pid, ?MODULE, old_vsn, state_functions),
+ sys:change_code(Pid, ?MODULE, old_vsn, Mode),
sys:resume(Pid),
- {idle,{old_vsn,data,state_functions}} = sys:get_state(Pid),
+ {idle,{old_vsn,data,Mode}} = sys:get_state(Pid),
+ Mode = gen_statem:call(Pid, get_callback_mode),
stop_it(Pid).
call_format_status(Config) ->
@@ -1478,6 +1480,8 @@ next_events(Type, Content, Data) ->
end.
+handle_common_events({call,From}, get_callback_mode, _, _) ->
+ {keep_state_and_data,{reply,From,state_functions}};
handle_common_events({call,From}, get, State, Data) ->
{keep_state,Data,
[{reply,From,{state,State,Data}}]};
@@ -1501,6 +1505,8 @@ handle_common_events(cast, {'alive?',Pid}, _, Data) ->
handle_common_events(_, _, _, _) ->
undefined.
+handle_event({call,From}, get_callback_mode, _, _) ->
+ {keep_state_and_data,{reply,From,handle_event_function}};
%% Wrapper state machine that uses a map state machine spec
handle_event(
Type, Event, State, [Data|Machine])