Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace p1_time_compat with direct OTP functions #2498

Merged
merged 5 commits into from
Oct 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions load_test/amoc_scenarios/xmpp_amqp.erl
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ send_message(Client, ToId) ->
-spec report_message_ttd(Timestamp :: binary(), role()) -> ok.
report_message_ttd(Timestamp, Role) ->
IntegerTimestamp = binary_to_integer(Timestamp),
Diff = os:system_time(micro_seconds) - IntegerTimestamp,
Diff = os:system_time(microsecond) - IntegerTimestamp,
exometer:update(?MESSAGE_TTD(Role), Diff).

%================================================
Expand Down Expand Up @@ -506,7 +506,7 @@ bind_queue_to_exchange(ChannelPid, Queue, Exchange, RoutingKey) ->

-spec make_message(binjid()) -> exml:element().
make_message(ToId) ->
Timestamp = integer_to_binary(os:system_time(micro_seconds)),
Timestamp = integer_to_binary(os:system_time(microsecond)),
Id = escalus_stanza:id(),
escalus_stanza:set_id(escalus_stanza:chat_to(ToId, Timestamp), Id).

Expand Down
6 changes: 2 additions & 4 deletions src/admin_extra/service_admin_extra_accounts.erl
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ get_sha(AccountPass) ->

-spec num_active_users(jid:server(), integer()) -> non_neg_integer().
num_active_users(Host, Days) ->
{MegaSecs, Secs, _MicroSecs} = p1_time_compat:timestamp(),
TimeStamp = MegaSecs * 1000000 + Secs,
TimeStamp = erlang:system_time(second),
TS = TimeStamp - Days * 86400,
case catch mod_last:count_active_users(Host, TS) of
{'EXIT', _Reason} ->
Expand Down Expand Up @@ -206,8 +205,7 @@ delete_old_users(Days, Users) ->
SecOlder = Days*24*60*60,

%% Get current time
{MegaSecs, Secs, _MicroSecs} = p1_time_compat:timestamp(),
TimeStampNow = MegaSecs * 1000000 + Secs,
TimeStampNow = erlang:system_time(second),

%% Apply the remove function to every user in the list
UsersRemoved = lists:filter(fun(User) ->
Expand Down
3 changes: 1 addition & 2 deletions src/auth/ejabberd_auth_external.erl
Original file line number Diff line number Diff line change
Expand Up @@ -358,8 +358,7 @@ set_password_internal(LUser, LServer, Password) ->
-spec is_fresh_enough(TimeLast :: integer(),
CacheTime :: integer()) -> boolean().
is_fresh_enough(TimeStampLast, CacheTime) ->
{MegaSecs, Secs, _MicroSecs} = p1_time_compat:timestamp(),
Now = MegaSecs * 1000000 + Secs,
Now = erlang:system_time(second),
(TimeStampLast + CacheTime > Now).


Expand Down
7 changes: 1 addition & 6 deletions src/auth/ejabberd_auth_riak.erl
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ try_register_if_does_not_exist(LUser, LServer, PasswordIn) ->
end.

try_register_with_password(LUser, LServer, Password) ->
Now = integer_to_binary(now_to_seconds(os:timestamp())),
Now = integer_to_binary(os:system_time(second)),
Ops = [{{<<"created">>, register},
fun(R) -> riakc_register:set(Now, R) end},
set_password_map_op(Password)],
Expand Down Expand Up @@ -259,8 +259,3 @@ maybe_extract_scram_password({ok, ScramSerialised}) ->
end;
maybe_extract_scram_password(_) ->
false.

-spec now_to_seconds(erlang:timestamp()) -> non_neg_integer().
now_to_seconds({MegaSecs, Secs, _MicroSecs}) ->
MegaSecs * 1000000 + Secs.

6 changes: 3 additions & 3 deletions src/ejabberd_c2s.erl
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ do_open_session_common(Acc, JID, #state{user = U, server = S, resource = R} = Ne
Fs1 = [LJID | Fs],
Ts1 = [LJID | Ts],
PrivList = ejabberd_hooks:run_fold(privacy_get_user_list, S, #userlist{}, [U, S]),
SID = {p1_time_compat:timestamp(), self()},
SID = {erlang:timestamp(), self()},
Conn = get_conn_type(NewStateData0),
Info = [{ip, NewStateData0#state.ip}, {conn, Conn},
{auth_module, NewStateData0#state.auth_module}],
Expand Down Expand Up @@ -2784,7 +2784,7 @@ maybe_enable_stream_mgmt(NextState, El, StateData) ->
enable_stream_resumption(SD) ->
SMID = mod_stream_management:make_smid(),
SID = case SD#state.sid of
undefined -> {p1_time_compat:timestamp(), self()};
undefined -> {erlang:timestamp(), self()};
RSID -> RSID
end,
ok = mod_stream_management:register_smid(SMID, SID),
Expand Down Expand Up @@ -3035,7 +3035,7 @@ maybe_resume_session(NextState, El, StateData) ->
do_resume_session(SMID, El, {sid, {_, Pid}}, #state{server = Server} = StateData) ->
try
{ok, OldState} = p1_fsm_old:sync_send_event(Pid, resume),
SID = {p1_time_compat:timestamp(), self()},
SID = {erlang:timestamp(), self()},
Conn = get_conn_type(StateData),
MergedState = merge_state(OldState,
StateData#state{sid = SID, conn = Conn}),
Expand Down
2 changes: 1 addition & 1 deletion src/ejabberd_config.erl
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ start() ->
Config = get_ejabberd_config_path(),
ejabberd_config:load_file(Config),
%% This start time is used by mod_last:
add_local_option(node_start, p1_time_compat:timestamp()),
add_local_option(node_start, erlang:timestamp()),
ok.


Expand Down
2 changes: 1 addition & 1 deletion src/ejabberd_s2s_out.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,7 @@ wait_before_reconnect(StateData) ->
undefined_delay ->
%% The initial delay is random between 1 and 15 seconds
%% Return a random integer between 1000 and 15000
{_, _, MicroSecs} = p1_time_compat:timestamp(),
MicroSecs = erlang:system_time(microsecond),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taking into account the comment above, current implementation is less random as far as I can reason about it. Also since we want a random number, maybe there is a better way than calculate it from a timestamp?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this makes much of a difference, it's not a place were cryptographically safe randomization makes any difference. We just want to wait some random amount of time between 1 an 15 seconds. The fact that this function might run at unpredictable times makes it sufficiently random for our purposes I think 🙁
An option would be to do X = rand:uniform(14000), X+1000, but the performance is pretty much the same (I've just measure it on my laptop with timer:tc over a 10M repeats), and rand is saving seeds into the process dictionary. If you prefer that I can quickly change it, but I don't think it matters much 🤷‍♂️

(MicroSecs rem 14000) + 1000;
D1 ->
%% Duplicate the delay with each successive failed
Expand Down
2 changes: 1 addition & 1 deletion src/gen_iq_handler.erl
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ handle(Host, Module, Function, Opts, From, To, Acc, IQ) ->
Pid ! {process_iq, From, To, Acc, IQ},
Acc;
{queues, Pids} ->
Pid = lists:nth(erlang:phash(p1_time_compat:unique_integer(), length(Pids)), Pids),
Pid = lists:nth(erlang:phash(erlang:unique_integer(), length(Pids)), Pids),
Pid ! {process_iq, From, To, Acc, IQ},
Acc;
parallel ->
Expand Down
8 changes: 4 additions & 4 deletions src/global_distrib/mod_global_distrib_bounce.erl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
-spec start(Host :: jid:lserver(), Opts :: proplists:proplist()) -> any().
start(Host, Opts0) ->
ResendAfterMs = proplists:get_value(resend_after_ms, Opts0, 200),
ResendAfter = p1_time_compat:convert_time_unit(ResendAfterMs, milli_seconds, native),
ResendAfter = erlang:convert_time_unit(ResendAfterMs, millisecond, native),
Opts = [{resend_after, ResendAfter}, {max_retries, 4} | Opts0],
mod_global_distrib_utils:start(?MODULE, Host, Opts, fun start/0).

Expand All @@ -61,7 +61,7 @@ init(_) ->

handle_info(resend, State) ->
erlang:send_after(100, self(), resend),
Now = p1_time_compat:monotonic_time(),
Now = erlang:monotonic_time(),
resend_messages(Now),
{noreply, State}.

Expand Down Expand Up @@ -103,10 +103,10 @@ maybe_store_message({From, To, Acc0, Packet} = FPacket) ->
?DEBUG("Storing global message id=~s from=~s to=~s to "
"resend after ~B ms (bounce_ttl=~B)",
[ID, jid:to_binary(From), jid:to_binary(To),
p1_time_compat:convert_time_unit(opt(resend_after), native, milli_seconds),
erlang:convert_time_unit(opt(resend_after), native, millisecond),
OldTTL]),
Acc = mod_global_distrib:put_metadata(Acc0, {bounce_ttl, LocalHost}, OldTTL - 1),
ResendAt = p1_time_compat:monotonic_time() + opt(resend_after),
ResendAt = erlang:monotonic_time() + opt(resend_after),
do_insert_in_store(ResendAt, {From, To, Acc, Packet}),
drop
end.
Expand Down
6 changes: 3 additions & 3 deletions src/global_distrib/mod_global_distrib_connection.erl
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ handle_call(Msg, From, State) ->
handle_cast(Msg, State).

handle_cast({data, Stamp, Data}, #state{socket = Socket, host = ToHost} = State) ->
QueueTimeNative = p1_time_compat:monotonic_time() - Stamp,
QueueTimeUS = p1_time_compat:convert_time_unit(QueueTimeNative, native, micro_seconds),
QueueTimeNative = erlang:monotonic_time() - Stamp,
QueueTimeUS = erlang:convert_time_unit(QueueTimeNative, native, microsecond),
mongoose_metrics:update(global, ?GLOBAL_DISTRIB_SEND_QUEUE_TIME(ToHost), QueueTimeUS),
ClockTime = p1_time_compat:system_time(micro_seconds),
ClockTime = erlang:system_time(microsecond),
Annotated = <<(byte_size(Data) + 8):32, ClockTime:64, Data/binary>>,
case mod_global_distrib_transport:send(Socket, Annotated) of
ok ->
Expand Down
2 changes: 1 addition & 1 deletion src/global_distrib/mod_global_distrib_mapping_redis.erl
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ get_hosts() ->
-spec refresh_nodes() -> any().
refresh_nodes() ->
NodesKey = nodes_key(),
Now = p1_time_compat:system_time(seconds),
Now = erlang:system_time(second),
case get_expired_nodes(Now) of
[] -> ok;
ExpiredNodes -> q([<<"HDEL">>, NodesKey | ExpiredNodes])
Expand Down
2 changes: 1 addition & 1 deletion src/global_distrib/mod_global_distrib_receiver.erl
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ handle_data(BinHost, State = #state{host = undefined}) ->
State#state{host = Host};
handle_data(Data, State = #state{host = Host}) ->
<<ClockTime:64, BinFromSize:16, _/binary>> = Data,
TransferTime = p1_time_compat:system_time(micro_seconds) - ClockTime,
TransferTime = erlang:system_time(microsecond) - ClockTime,
<<_:80, BinFrom:BinFromSize/binary, BinTerm/binary>> = Data,
Worker = mod_global_distrib_worker_sup:get_worker(BinFrom),
Stamp = erlang:monotonic_time(),
Expand Down
4 changes: 2 additions & 2 deletions src/global_distrib/mod_global_distrib_worker.erl
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ handle_cast({route, {From, To, Acc, Packet}}, State) ->
ejabberd_router:route(From, To, Acc, Packet),
{noreply, State, ?TIMEOUT};
handle_cast({data, Host, TransferTime, Stamp, Data}, State) ->
QueueTimeNative = p1_time_compat:monotonic_time() - Stamp,
QueueTimeUS = p1_time_compat:convert_time_unit(QueueTimeNative, native, micro_seconds),
QueueTimeNative = erlang:monotonic_time() - Stamp,
QueueTimeUS = erlang:convert_time_unit(QueueTimeNative, native, microsecond),
mongoose_metrics:update(global, ?GLOBAL_DISTRIB_RECV_QUEUE_TIME, QueueTimeUS),
mongoose_metrics:update(global, ?GLOBAL_DISTRIB_TRANSFER_TIME(Host), TransferTime),
mongoose_metrics:update(global, ?GLOBAL_DISTRIB_MESSAGES_RECEIVED(Host), 1),
Expand Down
4 changes: 2 additions & 2 deletions src/jingle_sip/mod_jingle_sip_backend.erl
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ set_incoming_request_tr(CallID, ReqID, From, To, JingleEl) ->
from = jid:to_lus(From),
to = Owner,
owner = Owner,
now = os:system_time(micro_seconds),
now = os:system_time(microsecond),
meta = Meta},
mnesia:write(Session)
end.
Expand All @@ -103,7 +103,7 @@ set_outgoing_request_tr(CallID, ReqID, From, To) ->
from = Owner,
to = jid:to_lus(To),
owner = Owner,
now = os:system_time(micro_seconds),
now = os:system_time(microsecond),
meta = #{}},
mnesia:write(Session)
end.
Expand Down
2 changes: 1 addition & 1 deletion src/mam/mam_iq.erl
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ form_to_lookup_params(#iq{sub_el = QueryEl} = IQ, MaxResultLimit, DefaultResultL
common_lookup_params(QueryEl, MaxResultLimit, DefaultResultLimit) ->
RSM = fix_rsm(jlib:rsm_decode(QueryEl)),
Limit = elem_to_limit(QueryEl),
#{now => p1_time_compat:system_time(micro_seconds),
#{now => erlang:system_time(microsecond),
rsm => RSM,
max_result_limit => MaxResultLimit,
page_size => min(MaxResultLimit,
Expand Down
2 changes: 1 addition & 1 deletion src/mam/mod_mam_utils.erl
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ microseconds_to_datetime(MicroSeconds) when is_integer(MicroSeconds) ->
-spec generate_message_id() -> integer().
generate_message_id() ->
{ok, NodeId} = ejabberd_node_id:node_id(),
CandidateStamp = p1_time_compat:os_system_time(micro_seconds),
CandidateStamp = erlang:system_time(microsecond),
UniqueStamp = mongoose_mam_id:next_unique(CandidateStamp),
encode_compact_uuid(UniqueStamp, NodeId).

Expand Down
4 changes: 2 additions & 2 deletions src/mod_bosh_socket.erl
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ schedule_report(Ack, #state{sent = Sent} = S) ->
ReportRid = Ack + 1,
try
{ReportRid, TimeSent, _} = lists:keyfind(ReportRid, 1, Sent),
ElapsedTimeMillis = p1_time_compat:monotonic_time(milli_seconds) - TimeSent,
ElapsedTimeMillis = erlang:monotonic_time(millisecond) - TimeSent,
Report = {ReportRid, ElapsedTimeMillis},
case S#state.report of
false ->
Expand Down Expand Up @@ -670,7 +670,7 @@ send_to_handler({_, Pid}, #xmlel{name = <<"body">>} = Wrapped, State) ->
send_wrapped_to_handler(Pid, Wrapped, State);
send_to_handler({Rid, Pid}, Data, State) ->
{Wrapped, NS} = bosh_wrap(Data, Rid, State),
NS2 = cache_response({Rid, p1_time_compat:monotonic_time(milli_seconds), Wrapped}, NS),
NS2 = cache_response({Rid, erlang:monotonic_time(millisecond), Wrapped}, NS),
send_wrapped_to_handler(Pid, Wrapped, NS2).


Expand Down
2 changes: 1 addition & 1 deletion src/mod_commands.erl
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ lookup_recent_messages(ArcJID, WithJID, Before, Limit) ->
rsm => #rsm_in{direction = before, id = undefined}, % last msgs
start_ts => undefined,
end_ts => Before * 1000000,
now => p1_time_compat:os_system_time(micro_seconds),
now => os:system_time(microsecond),
with_jid => WithJID,
search_text => undefined,
page_size => Limit,
Expand Down
6 changes: 3 additions & 3 deletions src/mod_last.erl
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ process_local_iq(_From, _To, Acc,
get_node_uptime() ->
case ejabberd_config:get_local_option(node_start) of
{_, _, _} = StartNow ->
now_to_seconds(p1_time_compat:timestamp()) - now_to_seconds(StartNow);
erlang:system_time(second) - now_to_seconds(StartNow);
_Undefined ->
trunc(element(1, erlang:statistics(wall_clock))/1000)
end.
Expand Down Expand Up @@ -185,7 +185,7 @@ make_response(IQ, SubEl, LUser, LServer, allow) ->
IQ#iq{type = error,
sub_el = [SubEl, mongoose_xmpp_errors:service_unavailable()]};
{ok, TimeStamp, Status} ->
TimeStamp2 = now_to_seconds(p1_time_compat:timestamp()),
TimeStamp2 = erlang:system_time(second),
Sec = TimeStamp2 - TimeStamp,
IQ#iq{type = result,
sub_el =
Expand Down Expand Up @@ -216,7 +216,7 @@ count_active_users(LServer, Timestamp) ->
-spec on_presence_update(map(), jid:user(), jid:server(), jid:resource(),
Status :: binary()) -> map() | {error, term()}.
on_presence_update(Acc, LUser, LServer, _Resource, Status) ->
TimeStamp = now_to_seconds(p1_time_compat:timestamp()),
TimeStamp = erlang:system_time(second),
case store_last_info(LUser, LServer, TimeStamp, Status) of
ok -> Acc;
E -> E
Expand Down
2 changes: 1 addition & 1 deletion src/mod_muc.erl
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ xfield(Type, Label, Var, Val, Lang) ->
%% http://xmpp.org/extensions/xep-0045.html#createroom-unique
-spec iq_get_unique(jid:jid()) -> jlib:xmlcdata().
iq_get_unique(From) ->
#xmlcdata{content = sha:sha1_hex(term_to_binary([From, p1_time_compat:unique_integer(),
#xmlcdata{content = sha:sha1_hex(term_to_binary([From, erlang:unique_integer(),
mongoose_bin:gen_from_crypto()]))}.


Expand Down
8 changes: 4 additions & 4 deletions src/mod_muc_log.erl
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ add_message_to_log(Nick1, Message, RoomJID, Opts, State) ->
Room = get_room_info(RoomJID, Opts),
Nick = htmlize(Nick1, FileFormat),
Nick2 = htmlize(<<"<", Nick1/binary, ">">>, FileFormat),
Now = p1_time_compat:timestamp(),
Now = erlang:timestamp(),
TimeStamp = case Timezone of
local -> calendar:now_to_local_time(Now);
universal -> calendar:now_to_universal_time(Now)
Expand Down Expand Up @@ -874,7 +874,7 @@ put_header_script(F) ->
put_room_config(_F, _RoomConfig, _Lang, plaintext) ->
ok;
put_room_config(F, RoomConfig, Lang, _FileFormat) ->
{Now1, Now2, Now3} = p1_time_compat:timestamp(),
{Now1, Now2, Now3} = erlang:timestamp(),
NowBin = list_to_binary(lists:flatten(io_lib:format("~p~p~p", [Now1, Now2, Now3]))),
fw(F, <<"<div class=\"rc\">">>),
fw(F, <<"<div class=\"rct\" onclick=\"sh('a", NowBin/binary, "');return false;\">",
Expand All @@ -889,7 +889,7 @@ put_room_config(F, RoomConfig, Lang, _FileFormat) ->
put_room_occupants(_F, _RoomOccupants, _Lang, plaintext) ->
ok;
put_room_occupants(F, RoomOccupants, Lang, _FileFormat) ->
{Now1, Now2, Now3} = p1_time_compat:timestamp(),
{Now1, Now2, Now3} = erlang:timestamp(),
NowBin = list_to_binary(lists:flatten(io_lib:format("~p~p~p", [Now1, Now2, Now3]))),
fw(F, <<"<div class=\"rc\">">>),
fw(F, <<"<div class=\"rct\" onclick=\"sh('o", NowBin/binary, "');return false;\">",
Expand Down Expand Up @@ -1094,7 +1094,7 @@ get_proc_name(Host) -> gen_mod:get_module_proc(Host, ?PROCNAME).

-spec calc_hour_offset(calendar:datetime()) -> integer().
calc_hour_offset(TimeHere) ->
TimeZero = calendar:now_to_universal_time(p1_time_compat:timestamp()),
TimeZero = calendar:now_to_universal_time(erlang:timestamp()),
TimeHereHour = calendar:datetime_to_gregorian_seconds(TimeHere) div 3600,
TimeZeroHour = calendar:datetime_to_gregorian_seconds(TimeZero) div 3600,
TimeHereHour - TimeZeroHour.
4 changes: 2 additions & 2 deletions src/mod_offline.erl
Original file line number Diff line number Diff line change
Expand Up @@ -392,11 +392,11 @@ store_packet(Acc, From, To = #jid{luser = LUser, lserver = LServer},
TimeStamp =
case exml_query:subelement(Packet, <<"delay">>) of
undefined ->
p1_time_compat:timestamp();
erlang:timestamp();
#xmlel{name = <<"delay">>} = DelayEl ->
case exml_query:attr(DelayEl, <<"stamp">>, <<>>) of
<<"">> ->
p1_time_compat:timestamp();
erlang:timestamp();
Stamp ->
jlib:datetime_binary_to_timestamp(Stamp)
end
Expand Down
2 changes: 1 addition & 1 deletion src/mod_offline_mnesia.erl
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ remove_user(LUser, LServer) ->
-spec remove_expired_messages(jid:lserver()) -> {error, term()} | {ok, HowManyRemoved} when
HowManyRemoved :: integer().
remove_expired_messages(_Host) ->
TimeStamp = p1_time_compat:timestamp(),
TimeStamp = erlang:timestamp(),
F = fun() ->
mnesia:write_lock_table(offline_msg),
mnesia:foldl(
Expand Down
6 changes: 3 additions & 3 deletions src/mod_offline_rdbms.erl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pop_messages(LUser, LServer) ->
To = jid:make(LUser, LServer, <<>>),
SUser = mongoose_rdbms:escape_string(LUser),
SServer = mongoose_rdbms:escape_string(LServer),
TimeStamp = p1_time_compat:timestamp(),
TimeStamp = erlang:timestamp(),
STimeStamp = encode_timestamp(TimeStamp),
case rdbms_queries:pop_offline_messages(LServer, SUser, SServer, STimeStamp) of
{atomic, {selected, Rows}} ->
Expand All @@ -65,7 +65,7 @@ fetch_messages(User, Server) ->
LServer = jid:nodeprep(Server),
US = {LUser, LServer},
To = jid:make(User, LServer, <<>>),
TimeStamp = p1_time_compat:timestamp(),
TimeStamp = erlang:timestamp(),
SUser = mongoose_rdbms:escape_string(LUser),
SServer = mongoose_rdbms:escape_string(LServer),
STimeStamp = encode_timestamp(TimeStamp),
Expand Down Expand Up @@ -128,7 +128,7 @@ remove_user(LUser, LServer) ->
-spec remove_expired_messages(jid:lserver()) -> {error, term()} | {ok, HowManyRemoved} when
HowManyRemoved :: integer().
remove_expired_messages(LServer) ->
TimeStamp = p1_time_compat:timestamp(),
TimeStamp = erlang:timestamp(),
STimeStamp = encode_timestamp(TimeStamp),
Result = rdbms_queries:remove_expired_offline_messages(LServer, STimeStamp),
case Result of
Expand Down
3 changes: 1 addition & 2 deletions src/mod_register.erl
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,7 @@ check_timeout(Source) ->
end,
case is_integer(Timeout) of
true ->
{MSec, Sec, _USec} = p1_time_compat:timestamp(),
Priority = -(MSec * 1000000 + Sec),
Priority = -(erlang:system_time(second)),
CleanPriority = Priority + Timeout,
F = fun() -> check_and_store_ip_entry(Source, Priority, CleanPriority) end,

Expand Down
2 changes: 1 addition & 1 deletion src/mod_time.erl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ process_local_iq(_From, _To, Acc, #iq{type = get} = IQ) ->

%% Internals
calculate_time() ->
Now = p1_time_compat:timestamp(),
Now = erlang:timestamp(),
NowUniversal = calendar:now_to_universal_time(Now),
NowLocal = calendar:now_to_local_time(Now),
{UTCTime, UTCDiff} = jlib:timestamp_to_iso(NowUniversal, utc),
Expand Down
Loading