fix(persistent_sessions): we only need to persist if the session expired

This commit is contained in:
Tobias Lindahl 2021-11-02 09:27:50 +01:00
parent 62f9f6fd91
commit 8385eff98e
1 changed files with 1 additions and 2 deletions

View File

@ -1179,14 +1179,13 @@ terminate(_, #channel{conn_state = idle}) -> ok;
terminate(normal, Channel) -> terminate(normal, Channel) ->
run_terminate_hook(normal, Channel); run_terminate_hook(normal, Channel);
terminate({shutdown, kicked}, Channel) -> terminate({shutdown, kicked}, Channel) ->
persist_if_session(Channel),
run_terminate_hook(kicked, Channel); run_terminate_hook(kicked, Channel);
terminate({shutdown, Reason}, Channel) when Reason =:= discarded; terminate({shutdown, Reason}, Channel) when Reason =:= discarded;
Reason =:= takeovered -> Reason =:= takeovered ->
run_terminate_hook(Reason, Channel); run_terminate_hook(Reason, Channel);
terminate(Reason, Channel = #channel{will_msg = WillMsg}) -> terminate(Reason, Channel = #channel{will_msg = WillMsg}) ->
(WillMsg =/= undefined) andalso publish_will_msg(WillMsg), (WillMsg =/= undefined) andalso publish_will_msg(WillMsg),
persist_if_session(Channel), (Reason =:= expired) andalso persist_if_session(Channel),
run_terminate_hook(Reason, Channel). run_terminate_hook(Reason, Channel).
persist_if_session(#channel{session = Session} = Channel) -> persist_if_session(#channel{session = Session} = Channel) ->