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

Commit

Permalink
Fix crash by backwards-rolling time by otp_release > 18
Browse files Browse the repository at this point in the history
Add define directive, which works with rebar3.

Fixes #18.
  • Loading branch information
liveforeverx committed Nov 16, 2017
1 parent cf92412 commit b3b1979
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
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

0 comments on commit b3b1979

Please sign in to comment.