From d7974d835faf63f7531bc84be4191a940c4c4b5e Mon Sep 17 00:00:00 2001 From: Andrew Mayorov Date: Mon, 20 Nov 2023 15:49:01 +0700 Subject: [PATCH] fix(sharesub): anticipate messages w/o redispatch header For instance, `emqx_session_mem` will push almost all of the messages that are still in the state to `emqx_shared_sub:redispatch/1`. After this commit, the session will no longer crash during channel terminate. --- apps/emqx/src/emqx_shared_sub.erl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/emqx/src/emqx_shared_sub.erl b/apps/emqx/src/emqx_shared_sub.erl index 89a785590..0a6538282 100644 --- a/apps/emqx/src/emqx_shared_sub.erl +++ b/apps/emqx/src/emqx_shared_sub.erl @@ -242,7 +242,9 @@ with_redispatch_to(Msg, Group, Topic) -> is_redispatch_needed(#message{qos = ?QOS_0}) -> false; is_redispatch_needed(#message{headers = #{redispatch_to := ?REDISPATCH_TO(_, _)}}) -> - true. + true; +is_redispatch_needed(#message{}) -> + false. %% @doc Redispatch shared deliveries to other members in the group. redispatch(Messages0) ->