From 1fa7e7008187f6f85d78f08889efe8d6c2e5d1e0 Mon Sep 17 00:00:00 2001 From: Thales Macedo Garitezi Date: Fri, 5 Nov 2021 13:51:47 -0300 Subject: [PATCH] chore(emqx_cm): rm periodic count refresh after review This will be done in another PR, if needed. --- src/emqx_cm.erl | 26 ++------------------------ 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/src/emqx_cm.erl b/src/emqx_cm.erl index 063bbf324..397b3b7af 100644 --- a/src/emqx_cm.erl +++ b/src/emqx_cm.erl @@ -450,11 +450,8 @@ init([]) -> CRef = counters:new(1, [write_concurrency]), ok = persistent_term:put({?MODULE, ?CONN_CLIENT_CTR}, CRef), ok = emqx_stats:update_interval(chan_stats, fun ?MODULE:stats_fun/0), - RefreshPeriod = application:get_env(emqx, connected_client_count_refresh_period, 60000), - State = #{ chan_pmon => emqx_pmon:new() - , connected_client_refresh_period => RefreshPeriod - }, - {ok, ensure_refresh_timer(State)}. + State = #{chan_pmon => emqx_pmon:new()}, + {ok, State}. handle_call(Req, _From, State) -> ?LOG(error, "Unexpected call: ~p", [Req]), @@ -483,17 +480,6 @@ handle_info({'DOWN', _MRef, process, Pid, _Reason}, State = #{chan_pmon := PMon} Items), ok = emqx_pool:async_submit(fun lists:foreach/2, [fun ?MODULE:clean_down/1, Items]), {noreply, State#{chan_pmon := PMon1}}; -handle_info({timeout, TRef, refresh_connected_client_count}, - State0 = #{connected_client_refresh_timer := TRef}) -> - CCCount = refresh_connected_client_count(), - ?tp(emqx_cm_refresh_connected_client_count, - #{ new_count => CCCount - , old_count => get_connected_client_count() - }), - CRef = persistent_term:get({?MODULE, ?CONN_CLIENT_CTR}), - ok = counters:put(CRef, ?CONN_CLIENT_CTR_IDX, CCCount), - State = ensure_refresh_timer(State0), - {noreply, State}; handle_info(Info, State) -> ?LOG(error, "Unexpected info: ~p", [Info]), {noreply, State}. @@ -549,11 +535,3 @@ decrement_connected_client_count() -> get_connected_client_count() -> CRef = persistent_term:get({?MODULE, ?CONN_CLIENT_CTR}), max(0, counters:get(CRef, ?CONN_CLIENT_CTR_IDX)). - -ensure_refresh_timer(State = #{connected_client_refresh_period := RefreshPeriod}) -> - TRef = emqx_misc:start_timer(RefreshPeriod, refresh_connected_client_count), - State#{connected_client_refresh_timer => TRef}. - -refresh_connected_client_count() -> - Spec = [{{'_', #{conn_state => connected}, '_'}, [], [true]}], - ets:select_count(?CHAN_INFO_TAB, Spec).