|
|
@@ -47,6 +47,7 @@
|
|
|
-include("emqx_mqtt.hrl").
|
|
|
-include("logger.hrl").
|
|
|
-include("types.hrl").
|
|
|
+-include_lib("snabbkaffe/include/snabbkaffe.hrl").
|
|
|
|
|
|
-ifdef(TEST).
|
|
|
-compile(export_all).
|
|
|
@@ -802,7 +803,7 @@ replay(ClientInfo, Session = #session{inflight = Inflight}) ->
|
|
|
-spec terminate(emqx_types:clientinfo(), Reason :: term(), session()) -> ok.
|
|
|
terminate(ClientInfo, Reason, Session) ->
|
|
|
run_terminate_hooks(ClientInfo, Reason, Session),
|
|
|
- redispatch_shared_messages(Reason, Session),
|
|
|
+ maybe_redispatch_shared_messages(Reason, Session),
|
|
|
ok.
|
|
|
|
|
|
run_terminate_hooks(ClientInfo, discarded, Session) ->
|
|
|
@@ -812,11 +813,13 @@ run_terminate_hooks(ClientInfo, takenover, Session) ->
|
|
|
run_terminate_hooks(ClientInfo, Reason, Session) ->
|
|
|
run_hook('session.terminated', [ClientInfo, Reason, info(Session)]).
|
|
|
|
|
|
-redispatch_shared_messages(takenover, _Session) ->
|
|
|
+maybe_redispatch_shared_messages(takenover, _Session) ->
|
|
|
+ ?tp(debug, ignore_redispatch_shared_messages, #{reason => takenover}),
|
|
|
ok;
|
|
|
-redispatch_shared_messages(kicked, _Session) ->
|
|
|
+maybe_redispatch_shared_messages(kicked, _Session) ->
|
|
|
+ ?tp(debug, ignore_redispatch_shared_messages, #{reason => kicked}),
|
|
|
ok;
|
|
|
-redispatch_shared_messages(_Reason, #session{inflight = Inflight, mqueue = Q}) ->
|
|
|
+maybe_redispatch_shared_messages(_Reason, #session{inflight = Inflight, mqueue = Q}) ->
|
|
|
AllInflights = emqx_inflight:to_list(fun sort_fun/2, Inflight),
|
|
|
F = fun
|
|
|
({_PacketId, #inflight_data{message = #message{qos = ?QOS_1} = Msg}}) ->
|