fix(emqx_retainer): fix timer message error (#6156)
* fix(emqx_retainer): fix timer message error
This commit is contained in:
parent
d305111929
commit
87a2667e35
|
@ -1,6 +1,6 @@
|
||||||
{application, emqx_retainer,
|
{application, emqx_retainer,
|
||||||
[{description, "EMQ X Retainer"},
|
[{description, "EMQ X Retainer"},
|
||||||
{vsn, "4.4.1"}, % strict semver, bump manually!
|
{vsn, "4.4.0"}, % strict semver, bump manually!
|
||||||
{modules, []},
|
{modules, []},
|
||||||
{registered, [emqx_retainer_sup]},
|
{registered, [emqx_retainer_sup]},
|
||||||
{applications, [kernel,stdlib]},
|
{applications, [kernel,stdlib]},
|
||||||
|
|
|
@ -156,7 +156,7 @@ start_expire_timer(0, State) ->
|
||||||
start_expire_timer(undefined, State) ->
|
start_expire_timer(undefined, State) ->
|
||||||
State;
|
State;
|
||||||
start_expire_timer(Ms, State) ->
|
start_expire_timer(Ms, State) ->
|
||||||
Timer = erlang:send_after(Ms, self(), stats),
|
Timer = erlang:send_after(Ms, self(), {expire, Ms}),
|
||||||
State#state{expiry_timer = Timer}.
|
State#state{expiry_timer = Timer}.
|
||||||
|
|
||||||
handle_call(Req, _From, State) ->
|
handle_call(Req, _From, State) ->
|
||||||
|
@ -168,12 +168,14 @@ handle_cast(Msg, State) ->
|
||||||
{noreply, State}.
|
{noreply, State}.
|
||||||
|
|
||||||
handle_info(stats, State = #state{stats_fun = StatsFun}) ->
|
handle_info(stats, State = #state{stats_fun = StatsFun}) ->
|
||||||
|
StatsTimer = erlang:send_after(timer:seconds(1), self(), stats),
|
||||||
StatsFun(retained_count()),
|
StatsFun(retained_count()),
|
||||||
{noreply, State, hibernate};
|
{noreply, State#state{stats_timer = StatsTimer}, hibernate};
|
||||||
|
|
||||||
handle_info(expire, State) ->
|
handle_info({expire, Ms} = Expire, State) ->
|
||||||
|
Timer = erlang:send_after(Ms, self(), Expire),
|
||||||
ok = expire_messages(),
|
ok = expire_messages(),
|
||||||
{noreply, State, hibernate};
|
{noreply, State#state{expiry_timer = Timer}, hibernate};
|
||||||
|
|
||||||
handle_info(Info, State) ->
|
handle_info(Info, State) ->
|
||||||
?LOG(error, "Unexpected info: ~p", [Info]),
|
?LOG(error, "Unexpected info: ~p", [Info]),
|
||||||
|
|
Loading…
Reference in New Issue