From: Paweł Chmielowski Date: Tue, 16 Apr 2019 08:24:28 +0000 (+0200) Subject: Make misc:unique_timestamp not overflow microsecond part. X-Git-Tag: 19.05~89 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3706e35b863eccc9e86ec3db9ea1ad328f8006f6;p=ejabberd Make misc:unique_timestamp not overflow microsecond part. This should fix issue #2860 --- diff --git a/src/misc.erl b/src/misc.erl index 891269cc1..c646ed442 100644 --- a/src/misc.erl +++ b/src/misc.erl @@ -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).