From 9c2584607a5fdeaf9bd5b3b3ee7df2ea883080dd Mon Sep 17 00:00:00 2001 From: turtleDeng Date: Fri, 20 Sep 2019 16:55:12 +0800 Subject: [PATCH] Optimize GC (#2917) --- src/emqx_channel.erl | 2 +- src/emqx_session.erl | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) 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}.