fix(emqx_retainer): Dialyzer warnings

This commit is contained in:
Zaiming Shi 2020-11-11 14:04:39 +01:00
parent 8bb8dc5363
commit 39883bdab1
1 changed files with 11 additions and 7 deletions

View File

@ -56,8 +56,9 @@
%%-------------------------------------------------------------------- %%--------------------------------------------------------------------
load(Env) -> load(Env) ->
emqx:hook('session.subscribed', fun ?MODULE:on_session_subscribed/3, []), _ = emqx:hook('session.subscribed', fun ?MODULE:on_session_subscribed/3, []),
emqx:hook('message.publish', fun ?MODULE:on_message_publish/2, [Env]). _ = emqx:hook('message.publish', fun ?MODULE:on_message_publish/2, [Env]),
ok.
unload() -> unload() ->
emqx:unhook('message.publish', fun ?MODULE:on_message_publish/2), emqx:unhook('message.publish', fun ?MODULE:on_message_publish/2),
@ -169,15 +170,17 @@ handle_info(stats, State = #state{stats_fun = StatsFun}) ->
{noreply, State, hibernate}; {noreply, State, hibernate};
handle_info(expire, State) -> handle_info(expire, State) ->
expire_messages(), ok = expire_messages(),
{noreply, State, hibernate}; {noreply, State, hibernate};
handle_info(Info, State) -> handle_info(Info, State) ->
?LOG(error, "Unexpected info: ~p", [Info]), ?LOG(error, "Unexpected info: ~p", [Info]),
{noreply, State}. {noreply, State}.
terminate(_Reason, _State = #state{stats_timer = TRef1, expiry_timer = TRef2}) -> terminate(_Reason, #state{stats_timer = TRef1, expiry_timer = TRef2} = State) ->
timer:cancel(TRef1), timer:cancel(TRef2). _ = timer:cancel(TRef1),
_ = timer:cancel(TRef2),
ok.
code_change(_OldVsn, State, _Extra) -> code_change(_OldVsn, State, _Extra) ->
{ok, State}. {ok, State}.
@ -248,11 +251,12 @@ expire_messages() ->
NowMs = erlang:system_time(millisecond), NowMs = erlang:system_time(millisecond),
MsHd = #retained{topic = '$1', msg = '_', expiry_time = '$3'}, MsHd = #retained{topic = '$1', msg = '_', expiry_time = '$3'},
Ms = [{MsHd, [{'=/=','$3',0}, {'<','$3',NowMs}], ['$1']}], Ms = [{MsHd, [{'=/=','$3',0}, {'<','$3',NowMs}], ['$1']}],
mnesia:transaction( {atomic, _} = mnesia:transaction(
fun() -> fun() ->
Keys = mnesia:select(?TAB, Ms, write), Keys = mnesia:select(?TAB, Ms, write),
lists:foreach(fun(Key) -> mnesia:delete({?TAB, Key}) end, Keys) lists:foreach(fun(Key) -> mnesia:delete({?TAB, Key}) end, Keys)
end). end),
ok.
-spec(read_messages(emqx_types:topic()) -spec(read_messages(emqx_types:topic())
-> [emqx_types:message()]). -> [emqx_types:message()]).