From 8670efbfa004fb1d79d138b167ae9606c2bbd050 Mon Sep 17 00:00:00 2001 From: Andrew Mayorov Date: Tue, 19 Sep 2023 18:01:30 +0400 Subject: [PATCH] =?UTF-8?q?chore(chan):=20rename=20`Name`=20=E2=86=92=20`T?= =?UTF-8?q?imerName`=20for=20better=20readability?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/emqx/src/emqx_channel.erl | 34 +++++++++---------- .../src/emqx_mqttsn_channel.erl | 20 +++++------ 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/apps/emqx/src/emqx_channel.erl b/apps/emqx/src/emqx_channel.erl index 73f307d43..536c9bd37 100644 --- a/apps/emqx/src/emqx_channel.erl +++ b/apps/emqx/src/emqx_channel.erl @@ -1316,48 +1316,48 @@ handle_timeout( end; handle_timeout( _TRef, - Name, + TimerName, Channel = #channel{conn_state = disconnected} -) when ?IS_COMMON_SESSION_TIMER(Name) -> +) when ?IS_COMMON_SESSION_TIMER(TimerName) -> {ok, Channel}; handle_timeout( _TRef, - Name, + TimerName, Channel = #channel{session = Session, clientinfo = ClientInfo} -) when ?IS_COMMON_SESSION_TIMER(Name) -> - % NOTE - % Responsibility for these timers is smeared across both this module and the - % `emqx_session` module: the latter holds configured timer intervals, and is - % responsible for the actual timeout logic. Yet they are managed here, since - % they are kind of common to all session implementations. - case emqx_session:handle_timeout(ClientInfo, Name, Session) of +) when ?IS_COMMON_SESSION_TIMER(TimerName) -> + %% NOTE + %% Responsibility for these timers is smeared across both this module and the + %% `emqx_session` module: the latter holds configured timer intervals, and is + %% responsible for the actual timeout logic. Yet they are managed here, since + %% they are kind of common to all session implementations. + case emqx_session:handle_timeout(ClientInfo, TimerName, Session) of {ok, Publishes, NSession} -> NChannel = Channel#channel{session = NSession}, - handle_out(publish, Publishes, clean_timer(Name, NChannel)); + handle_out(publish, Publishes, clean_timer(TimerName, NChannel)); {ok, Publishes, Timeout, NSession} -> NChannel = Channel#channel{session = NSession}, - handle_out(publish, Publishes, reset_timer(Name, Timeout, NChannel)) + handle_out(publish, Publishes, reset_timer(TimerName, Timeout, NChannel)) end; handle_timeout(_TRef, expire_session, Channel) -> shutdown(expired, Channel); handle_timeout( _TRef, - Name = will_message, + will_message = TimerName, Channel = #channel{clientinfo = ClientInfo, will_msg = WillMsg} ) -> (WillMsg =/= undefined) andalso publish_will_msg(ClientInfo, WillMsg), - {ok, clean_timer(Name, Channel#channel{will_msg = undefined})}; + {ok, clean_timer(TimerName, Channel#channel{will_msg = undefined})}; handle_timeout( _TRef, - expire_quota_limit = Name, + expire_quota_limit = TimerName, #channel{quota = Quota} = Channel ) -> case emqx_limiter_container:retry(?LIMITER_ROUTING, Quota) of {_, Intv, Quota2} -> - Channel2 = ensure_timer(Name, Intv, Channel#channel{quota = Quota2}), + Channel2 = ensure_timer(TimerName, Intv, Channel#channel{quota = Quota2}), {ok, Channel2}; {_, Quota2} -> - {ok, clean_timer(Name, Channel#channel{quota = Quota2})} + {ok, clean_timer(TimerName, Channel#channel{quota = Quota2})} end; handle_timeout(TRef, Msg, Channel) -> case emqx_hooks:run_fold('client.timeout', [TRef, Msg], []) of diff --git a/apps/emqx_gateway_mqttsn/src/emqx_mqttsn_channel.erl b/apps/emqx_gateway_mqttsn/src/emqx_mqttsn_channel.erl index 6c0163e4f..087187379 100644 --- a/apps/emqx_gateway_mqttsn/src/emqx_mqttsn_channel.erl +++ b/apps/emqx_gateway_mqttsn/src/emqx_mqttsn_channel.erl @@ -2060,35 +2060,35 @@ handle_timeout( {ok, Channel}; handle_timeout( _TRef, - retry_delivery, + retry_delivery = TimerName, Channel = #channel{conn_state = asleep} ) -> - {ok, reset_timer(retry_delivery, Channel)}; + {ok, reset_timer(TimerName, Channel)}; handle_timeout( _TRef, - _Name = expire_awaiting_rel, + expire_awaiting_rel, Channel = #channel{conn_state = disconnected} ) -> {ok, Channel}; handle_timeout( _TRef, - Name = expire_awaiting_rel, + expire_awaiting_rel = TimerName, Channel = #channel{conn_state = asleep} ) -> - {ok, reset_timer(Name, Channel)}; + {ok, reset_timer(TimerName, Channel)}; handle_timeout( _TRef, - Name, + TimerName, Channel = #channel{session = Session, clientinfo = ClientInfo} -) when Name == retry_delivery; Name == expire_awaiting_rel -> - case emqx_mqttsn_session:handle_timeout(ClientInfo, Name, Session) of +) when TimerName == retry_delivery; TimerName == expire_awaiting_rel -> + case emqx_mqttsn_session:handle_timeout(ClientInfo, TimerName, Session) of {ok, Publishes, NSession} -> NChannel = Channel#channel{session = NSession}, - handle_out(publish, Publishes, clean_timer(Name, NChannel)); + handle_out(publish, Publishes, clean_timer(TimerName, NChannel)); {ok, Publishes, Timeout, NSession} -> NChannel = Channel#channel{session = NSession}, %% XXX: These replay messages should awaiting register acked? - handle_out(publish, Publishes, reset_timer(Name, Timeout, NChannel)) + handle_out(publish, Publishes, reset_timer(TimerName, Timeout, NChannel)) end; handle_timeout( _TRef,