]> granicus.if.org Git - ejabberd/commitdiff
Make misc:unique_timestamp not overflow microsecond part.
authorPaweł Chmielowski <pchmielowski@process-one.net>
Tue, 16 Apr 2019 08:24:28 +0000 (10:24 +0200)
committerPaweł Chmielowski <pchmielowski@process-one.net>
Tue, 16 Apr 2019 08:24:28 +0000 (10:24 +0200)
This should fix issue #2860

src/misc.erl

index 891269cc1d236f1da81500e57460dda891e718e6..c646ed4423b313bdbd22831d8497f03299de1c30 100644 (file)
@@ -483,5 +483,6 @@ get_dir(Type) ->
 %% Generates erlang:timestamp() that is guaranteed to unique
 -spec unique_timestamp() -> erlang:timestamp().
 unique_timestamp() ->
-    {MS, S, _} = erlang:timestamp(),
-    {MS, S, erlang:unique_integer([positive, monotonic])}.
+    Time = erlang:system_time(microsecond),
+    UI = erlang:unique_integer([positive, monotonic]),
+    usec_to_now(Time + UI).