fix(time): replace os:system_time with erlang:system_time
Avoid the problem of inaccurate timers caused by mixing erlang:system_time/0-1 and os:system_time/0-1
This commit is contained in:
parent
659b65b328
commit
8521d8dac5
|
@ -399,7 +399,7 @@ do_verify(JWT, [JWK | More], VerifyClaims) ->
|
|||
end.
|
||||
|
||||
verify_claims(Claims, VerifyClaims0) ->
|
||||
Now = os:system_time(seconds),
|
||||
Now = erlang:system_time(seconds),
|
||||
VerifyClaims =
|
||||
[
|
||||
{<<"exp">>, fun(ExpireTime) ->
|
||||
|
|
|
@ -296,7 +296,7 @@ handle_cast(Msg, State) ->
|
|||
|
||||
%% Do Publish...
|
||||
handle_info({timeout, TRef, do_publish}, State = #{publish_timer := TRef}) ->
|
||||
DeletedKeys = do_publish(mnesia:dirty_first(?TAB), os:system_time(seconds)),
|
||||
DeletedKeys = do_publish(mnesia:dirty_first(?TAB), erlang:system_time(seconds)),
|
||||
lists:foreach(fun(Key) -> mria:dirty_delete(?TAB, Key) end, DeletedKeys),
|
||||
{noreply, ensure_publish_timer(State#{publish_timer := undefined, publish_at := 0})};
|
||||
handle_info(stats, State = #{stats_fun := StatsFun}) ->
|
||||
|
@ -347,12 +347,12 @@ ensure_publish_timer(State) ->
|
|||
ensure_publish_timer('$end_of_table', State) ->
|
||||
State#{publish_timer := undefined, publish_at := 0};
|
||||
ensure_publish_timer({Ts, _Id}, State = #{publish_timer := undefined}) ->
|
||||
ensure_publish_timer(Ts, os:system_time(seconds), State);
|
||||
ensure_publish_timer(Ts, erlang:system_time(seconds), State);
|
||||
ensure_publish_timer({Ts, _Id}, State = #{publish_timer := TRef, publish_at := PubAt}) when
|
||||
Ts < PubAt
|
||||
->
|
||||
ok = emqx_misc:cancel_timer(TRef),
|
||||
ensure_publish_timer(Ts, os:system_time(seconds), State);
|
||||
ensure_publish_timer(Ts, erlang:system_time(seconds), State);
|
||||
ensure_publish_timer(_Key, State) ->
|
||||
State.
|
||||
|
||||
|
|
Loading…
Reference in New Issue