aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ejabberd_sm.erl2
-rw-r--r--src/misc.erl8
-rw-r--r--src/mod_mqtt_mnesia.erl4
3 files changed, 10 insertions, 4 deletions
diff --git a/src/ejabberd_sm.erl b/src/ejabberd_sm.erl
index 165a750db..d60daca63 100644
--- a/src/ejabberd_sm.erl
+++ b/src/ejabberd_sm.erl
@@ -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;
diff --git a/src/misc.erl b/src/misc.erl
index 3c5407cd0..d2f0a5784 100644
--- a/src/misc.erl
+++ b/src/misc.erl
@@ -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])}.
diff --git a/src/mod_mqtt_mnesia.erl b/src/mod_mqtt_mnesia.erl
index 19ad36cde..b1b8b9dbd 100644
--- a/src/mod_mqtt_mnesia.erl
+++ b/src/mod_mqtt_mnesia.erl
@@ -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() ->