diff --git a/src/emqx_channel.erl b/src/emqx_channel.erl index c12015c4b..cb3794ef6 100644 --- a/src/emqx_channel.erl +++ b/src/emqx_channel.erl @@ -352,7 +352,7 @@ handle(info, {timeout, Timer, emit_stats}, {keep_state, NState#state{gc_state = GcState1}, hibernate}; {shutdown, Reason} -> ?LOG(error, "Shutdown exceptionally due to ~p", [Reason]), - shutdown(Reason, NState) + self() ! {shutdown, Reason} end; handle(info, {shutdown, discard, {ClientId, ByPid}}, State) -> diff --git a/src/emqx_session.erl b/src/emqx_session.erl index 201179af6..cbd204230 100644 --- a/src/emqx_session.erl +++ b/src/emqx_session.erl @@ -603,7 +603,7 @@ handle_info({timeout, Timer, emit_stats}, {noreply, NewState#state{gc_state = GcState1}, hibernate}; {shutdown, Reason} -> ?LOG(warning, "Shutdown exceptionally due to ~p", [Reason]), - shutdown(Reason, NewState) + self() ! {shutdown, Reason} end; handle_info({timeout, Timer, expired}, State = #state{expiry_timer = Timer}) -> @@ -646,6 +646,9 @@ handle_info({'EXIT', Pid, Reason}, State = #state{conn_pid = ConnPid}) -> [ConnPid, Pid, Reason]), {noreply, State}; +handle_info({shutdown, Reason}, State) -> + shutdown(Reason, State); + handle_info(Info, State) -> ?LOG(error, "Unexpected info: ~p", [Info]), {noreply, State}.