From c9d39b4d35e56d49983da27c07b8f6981d3e8c8e Mon Sep 17 00:00:00 2001 From: JianBo He Date: Fri, 29 Oct 2021 18:46:07 +0800 Subject: [PATCH] chore(channel): remove redundant logs Multiple sock_closed events may be generated, so we need to allow sock_closed events to be reentrant --- src/emqx_channel.erl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/emqx_channel.erl b/src/emqx_channel.erl index e3cbff692..7bfef472d 100644 --- a/src/emqx_channel.erl +++ b/src/emqx_channel.erl @@ -977,8 +977,11 @@ handle_info({sock_closed, Reason}, Channel = Shutdown -> Shutdown end; -handle_info({sock_closed, Reason}, Channel = #channel{conn_state = disconnected}) -> - ?LOG(error, "Unexpected sock_closed: ~p", [Reason]), +handle_info({sock_closed, _Reason}, Channel = #channel{conn_state = disconnected}) -> + %% Since sock_closed messages can be generated multiple times, + %% we can simply ignore errors of this type in the disconnected state. + %% e.g. when the socket send function returns an error, there is already + %% a tcp_closed delivered to the process mailbox {ok, Channel}; handle_info(clean_acl_cache, Channel) ->