Copy p1_time_compat:unique_timestamp() to misc and make use of it

This commit is contained in:
Paweł Chmielowski 2019-02-27 11:00:02 +01:00
parent 538f35d05a
commit 456e87e8b2
3 changed files with 10 additions and 4 deletions

View File

@ -1040,7 +1040,7 @@ kick_user(User, Server, Resource) ->
end.
make_sid() ->
{p1_time_compat:unique_timestamp(), self()}.
{misc:unique_timestamp(), self()}.
-spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
opt_type(sm_db_type) -> fun(T) -> ejabberd_config:v_db(?MODULE, T) end;

View File

@ -38,7 +38,7 @@
compile_exprs/2, join_atoms/2, try_read_file/1, get_descr/2,
css_dir/0, img_dir/0, js_dir/0, msgs_dir/0, sql_dir/0, lua_dir/0,
read_css/1, read_img/1, read_js/1, read_lua/1, try_url/1,
intersection/2, format_val/1, cancel_timer/1]).
intersection/2, format_val/1, cancel_timer/1, unique_timestamp/0]).
%% Deprecated functions
-export([decode_base64/1, encode_base64/1]).
@ -456,3 +456,9 @@ get_dir(Type) ->
Path ->
Path
end.
%% 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])}.

View File

@ -142,7 +142,7 @@ init() ->
end.
open_session(USR) ->
TS1 = p1_time_compat:unique_timestamp(),
TS1 = misc:unique_timestamp(),
P1 = self(),
F = fun() ->
case mnesia:read(mqtt_session, USR) of
@ -197,7 +197,7 @@ lookup_session(USR) ->
end.
subscribe({U, S, R} = USR, TopicFilter, SubOpts, ID) ->
T1 = p1_time_compat:unique_timestamp(),
T1 = misc:unique_timestamp(),
P1 = self(),
Key = {TopicFilter, S, U, R},
F = fun() ->