Skip to content
This repository has been archived by the owner on Dec 16, 2024. It is now read-only.

Fix crash by backwards-rolling time by otp_release > 18 #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,7 @@
]}.

{ct_use_short_names, true}.

{erl_opts, [
{platform_define, "^(18|19|2)+", support_new_time_api}
]}.
8 changes: 8 additions & 0 deletions src/locker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,13 @@ notify_release_waiter(Key, Value, AllWaiters) ->
lists:foreach(Reply, KeyWaiters),
OtherWaiters.

-ifdef(support_new_time_api).
now_to_seconds() ->
erlang:monotonic_time(second).

now_to_ms() ->
erlang:monotonic_time(millisecond).
-else.
now_to_seconds() ->
now_to_seconds(os:timestamp()).

Expand All @@ -650,6 +657,7 @@ now_to_ms() ->

now_to_ms({MegaSecs,Secs,MicroSecs}) ->
(MegaSecs * 1000000 + Secs) * 1000 + MicroSecs div 1000.
-endif.

ok_responses(Replies) ->
lists:partition(fun ({_, ok}) -> true;
Expand Down