]> granicus.if.org Git - ejabberd/commitdiff
Copy p1_time_compat:unique_timestamp() to misc and make use of it
authorPaweł Chmielowski <pchmielowski@process-one.net>
Wed, 27 Feb 2019 10:00:02 +0000 (11:00 +0100)
committerPaweł Chmielowski <pchmielowski@process-one.net>
Wed, 27 Feb 2019 10:00:02 +0000 (11:00 +0100)
src/ejabberd_sm.erl
src/misc.erl
src/mod_mqtt_mnesia.erl

index 165a750db2f8b48d20fe199e8e88a7e39eaa8fbc..d60daca63d3dc7e5b9444bbe8e9e1e32aeb8d931 100644 (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;
index 3c5407cd03686385e2630b57b90d2a7c276c474e..d2f0a57841e5a3b9022f51a8c0760426c68deefd 100644 (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])}.
index 19ad36cdeeab46f9a4612e06bd56cca4946edc8f..b1b8b9dbd46a4cb729f78c077201361a87c36141 100644 (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() ->