]> granicus.if.org Git - ejabberd/commitdiff
Replace code using p1_time_compat wrapper with native functions
authorPaweł Chmielowski <pchmielowski@process-one.net>
Wed, 27 Feb 2019 08:56:20 +0000 (09:56 +0100)
committerPaweł Chmielowski <pchmielowski@process-one.net>
Wed, 27 Feb 2019 08:56:31 +0000 (09:56 +0100)
Since we now require R19, we shouldn't need that anymore.

There are still couple places where p1_time_compat:unique_timestamp() is
used as there is no direct equivalent.

44 files changed:
include/mod_mam.hrl
include/mod_muc_room.hrl
include/mod_push.hrl
src/ejabberd_bosh.erl
src/ejabberd_c2s.erl
src/ejabberd_captcha.erl
src/ejabberd_config.erl
src/ejabberd_iq.erl
src/ejabberd_redis.erl
src/ejabberd_router.erl
src/ejabberd_s2s.erl
src/ejabberd_sql.erl
src/ejabberd_web_admin.erl
src/elixir_logger_backend.erl
src/extauth.erl
src/mod_admin_extra.erl
src/mod_bosh_mnesia.erl
src/mod_client_state.erl
src/mod_fail2ban.erl
src/mod_last.erl
src/mod_mam.erl
src/mod_metrics.erl
src/mod_mix_mnesia.erl
src/mod_mqtt_session.erl
src/mod_muc.erl
src/mod_muc_admin.erl
src/mod_muc_log.erl
src/mod_muc_room.erl
src/mod_offline.erl
src/mod_offline_mnesia.erl
src/mod_pres_counter.erl
src/mod_pubsub.erl
src/mod_push.erl
src/mod_register.erl
src/mod_roster.erl
src/mod_sip_proxy.erl
src/mod_sip_registrar.erl
src/mod_stream_mgmt.erl
src/mod_time.erl
src/node_flat.erl
src/node_flat_sql.erl
src/pubsub_migrate.erl
src/pubsub_subscription.erl
src/pubsub_subscription_sql.erl

index e02b9249dc359355bc9445ed5023a707fb4d2c74..0d03014ad2de7e9a18efa0a8a75c38fd1d6c1be6 100644 (file)
@@ -21,7 +21,7 @@
 -record(archive_msg,
        {us = {<<"">>, <<"">>}                :: {binary(), binary()} | '$2',
         id = <<>>                            :: binary() | '_',
-        timestamp = p1_time_compat:timestamp() :: erlang:timestamp() | '_' | '$1',
+        timestamp = erlang:timestamp()       :: erlang:timestamp() | '_' | '$1',
         peer = {<<"">>, <<"">>, <<"">>}      :: ljid() | '_' | '$3' | undefined,
         bare_peer = {<<"">>, <<"">>, <<"">>} :: ljid() | '_' | '$3',
         packet = #xmlel{}                    :: xmlel() | message() | '_',
index 9111128c07eeef886ffa0c8d544f0a1646dd9547..efb702337a721b37249d99a39d95985c9b65b536 100644 (file)
     history                 :: lqueue(),
     subject                 = [] :: [text()],
     subject_author          = <<"">> :: binary(),
-    just_created            = p1_time_compat:os_system_time(micro_seconds) :: true | integer(),
+    just_created            = erlang:system_time(microsecond) :: true | integer(),
     activity                = treap:empty() :: treap:treap(),
     room_shaper             = none :: shaper:shaper(),
     room_queue              :: p1_queue:queue() | undefined
index 24f02a3ff4b3fe7b1d203a432d43d1e0924e3187..cdd5b0cf6f5c9f99d8a609603077fc9e7c8f4df7 100644 (file)
@@ -18,7 +18,7 @@
 %%%----------------------------------------------------------------------
 -record(push_session,
         {us = {<<"">>, <<"">>}                  :: {binary(), binary()},
-         timestamp = p1_time_compat:timestamp() :: erlang:timestamp(),
+         timestamp = erlang:timestamp()         :: erlang:timestamp(),
          service = {<<"">>, <<"">>, <<"">>}     :: ljid(),
          node = <<"">>                          :: binary(),
          xml                                    :: undefined | xmlel()}).
index cdfd59b8a0dcbad96ea984c7607d8b688d111bde..3580cfab42e5d79f87f93a0da75146459666de31 100644 (file)
@@ -325,7 +325,7 @@ wait_for_session(#body{attrs = Attrs} = Req, From,
     Type = get_attr(type, Attrs),
     Requests = Hold + 1,
     {PollTime, Polling} = if Wait == 0, Hold == 0 ->
-                                {p1_time_compat:timestamp(), [{polling, ?DEFAULT_POLLING}]};
+                                {erlang:timestamp(), [{polling, ?DEFAULT_POLLING}]};
                             true -> {undefined, []}
                          end,
     MaxPause = gen_mod:get_module_opt(State#state.host,
@@ -479,7 +479,7 @@ active1(#body{attrs = Attrs} = Req, From, State) ->
           Pause = get_attr(pause, Attrs, undefined),
           NewPoll = case State#state.prev_poll of
                       undefined -> undefined;
-                      _ -> p1_time_compat:timestamp()
+                      _ -> erlang:timestamp()
                     end,
           State5 = State4#state{prev_poll = NewPoll,
                                 prev_key = NewKey},
@@ -736,7 +736,7 @@ is_valid_key(PrevKey, Key) ->
 
 is_overactivity(undefined) -> false;
 is_overactivity(PrevPoll) ->
-    PollPeriod = timer:now_diff(p1_time_compat:timestamp(), PrevPoll) div
+    PollPeriod = timer:now_diff(erlang:timestamp(), PrevPoll) div
                   1000000,
     if PollPeriod < (?DEFAULT_POLLING) -> true;
        true -> false
index 61284e3e605b9b22bfc6e3f6b9c17b7e08942105..9ccd1009968d2eaf77e2bd9c16f1c6870337f297 100644 (file)
@@ -725,7 +725,7 @@ process_self_presence(#{lserver := LServer} = State,
     {Pres1, State1} = ejabberd_hooks:run_fold(
                        c2s_self_presence, LServer, {Pres, State}, []),
     State2 = State1#{pres_last => Pres1,
-                    pres_timestamp => p1_time_compat:timestamp()},
+                    pres_timestamp => erlang:timestamp()},
     FromUnavailable = PreviousPres == undefined,
     broadcast_presence_available(State2, Pres1, FromUnavailable);
 process_self_presence(State, _Pres) ->
@@ -888,7 +888,7 @@ bounce_message_queue() ->
 new_uniq_id() ->
     iolist_to_binary(
       [p1_rand:get_string(),
-       integer_to_binary(p1_time_compat:unique_integer([positive]))]).
+       integer_to_binary(erlang:unique_integer([positive]))]).
 
 -spec get_conn_type(state()) -> c2s | c2s_tls | c2s_compressed | websocket |
                                c2s_compressed_tls | http_bind.
index 91f0cb2da5f155f4bb42167220dba1e5470775d7..385aa07b2b822eb9f633519e32254a728b2511b8 100644 (file)
@@ -589,7 +589,7 @@ callback(_, _, _) ->
     ok.
 
 now_priority() ->
-    -p1_time_compat:system_time(micro_seconds).
+    -erlang:system_time(microsecond).
 
 -spec opt_type(atom()) -> fun((any()) -> any()) | [atom()].
 opt_type(captcha_cmd) ->
index ed52c728b597c5e7f0c5c61dff7603083c8841f0..6b0b70befecc1ca9f91adbb8cb380c0e4b0a590a 100644 (file)
@@ -73,7 +73,7 @@ start() ->
                  [named_table, public, {read_concurrency, true}]),
     case load_file(ConfigFile) of
        {ok, State1} ->
-           UnixTime = p1_time_compat:system_time(seconds),
+           UnixTime = erlang:system_time(second),
            SharedKey = case erlang:get_cookie() of
                            nocookie ->
                                str:sha(p1_rand:get_string());
@@ -113,7 +113,7 @@ start(Hosts, Opts) ->
                  [named_table, public, {read_concurrency, true}]),
     catch ets:new(ejabberd_db_modules,
                  [named_table, public, {read_concurrency, true}]),
-    UnixTime = p1_time_compat:system_time(seconds),
+    UnixTime = erlang:system_time(second),
     SharedKey = case erlang:get_cookie() of
                    nocookie ->
                        str:sha(p1_rand:get_string());
index aeaffccde33de31769e53c2f026628bb7a526f0f..65902eeb929a93972e0d676aad3cf4843eaee4eb 100644 (file)
@@ -110,7 +110,7 @@ code_change(_OldVsn, State, _Extra) ->
 %%%===================================================================
 -spec current_time() -> non_neg_integer().
 current_time() ->
-    p1_time_compat:system_time(milli_seconds).
+    erlang:system_time(millisecond).
 
 -spec clean({non_neg_integer(), binary()} | '$end_of_table')
           -> non_neg_integer() | infinity.
index 3fa3f37d22af0065496f4d0b93a4be0e9824ee55..6284238a2abe545b66fd83408bf6db99d11afc6e 100644 (file)
@@ -366,7 +366,7 @@ init([I]) ->
 
 handle_call(connect, From, #state{connection = undefined,
                                  pending_q = Q} = State) ->
-    CurrTime = p1_time_compat:monotonic_time(milli_seconds),
+    CurrTime = erlang:monotonic_time(millisecond),
     Q2 = try p1_queue:in({From, CurrTime}, Q)
         catch error:full ->
                 Q1 = clean_queue(Q, CurrTime),
@@ -590,7 +590,7 @@ get_queue_type() ->
 
 -spec flush_queue(p1_queue:queue()) -> p1_queue:queue().
 flush_queue(Q) ->
-    CurrTime = p1_time_compat:monotonic_time(milli_seconds),
+    CurrTime = erlang:monotonic_time(millisecond),
     p1_queue:dropwhile(
       fun({From, Time}) ->
              if (CurrTime - Time) >= ?CALL_TIMEOUT ->
index 12baed5ee5dd226d913fa3d3f299bce3ebb6b79c..f6c6d2db26d87d2e15cdffd31349c6e2f7e59f14 100644 (file)
@@ -413,8 +413,8 @@ get_component_number(LDomain) ->
 -spec get_domain_balancing(jid(), jid(), binary()) -> any().
 get_domain_balancing(From, To, LDomain) ->
     case ejabberd_config:get_option({domain_balancing, LDomain}) of
-       undefined -> p1_time_compat:system_time();
-       random -> p1_time_compat:system_time();
+       undefined -> erlang:system_time();
+       random -> erlang:system_time();
        source -> jid:tolower(From);
        destination -> jid:tolower(To);
        bare_source -> jid:remove_resource(jid:tolower(From));
index 4b18811996b34daf91237f6397152c5580a2b859..77c511d928f19186ca647563c10903309eab57b6 100644 (file)
@@ -112,7 +112,7 @@ external_host_overloaded(Host) ->
              "seconds",
              [Host, ?S2S_OVERLOAD_BLOCK_PERIOD]),
     mnesia:transaction(fun () ->
-                               Time = p1_time_compat:monotonic_time(),
+                               Time = erlang:monotonic_time(),
                               mnesia:write(#temporarily_blocked{host = Host,
                                                                 timestamp = Time})
                       end).
@@ -123,8 +123,8 @@ is_temporarly_blocked(Host) ->
     case mnesia:dirty_read(temporarily_blocked, Host) of
       [] -> false;
       [#temporarily_blocked{timestamp = T} = Entry] ->
-          Diff = p1_time_compat:monotonic_time() - T,
-         case p1_time_compat:convert_time_unit(Diff, native, micro_seconds) of
+          Diff = erlang:monotonic_time() - T,
+         case erlang:convert_time_unit(Diff, native, microsecond) of
            N when N > (?S2S_OVERLOAD_BLOCK_PERIOD) * 1000 * 1000 ->
                mnesia:dirty_delete_object(Entry), false;
            _ -> true
index 2d9c64187e8234fe7222979741fb8e8ea75948b0..d130b40ae642f0a1f37252b8201db9038576c954 100644 (file)
@@ -167,7 +167,7 @@ sql_call(Host, Msg) ->
           none -> {error, <<"Unknown Host">>};
           Pid ->
                sync_send_event(Pid,{sql_cmd, Msg,
-                                    p1_time_compat:monotonic_time(milli_seconds)},
+                                    erlang:monotonic_time(millisecond)},
                                query_timeout(Host))
           end;
       _State -> nested_op(Msg)
@@ -176,7 +176,7 @@ sql_call(Host, Msg) ->
 keep_alive(Host, PID) ->
     case sync_send_event(PID,
                    {sql_cmd, {sql_query, ?KEEPALIVE_QUERY},
-                    p1_time_compat:monotonic_time(milli_seconds)},
+                    erlang:monotonic_time(millisecond)},
                    query_timeout(Host)) of
        {selected,_,[[<<"1">>]]} ->
            ok;
@@ -450,7 +450,7 @@ print_state(State) -> State.
 
 run_sql_cmd(Command, From, State, Timestamp) ->
     QueryTimeout = query_timeout(State#state.host),
-    case p1_time_compat:monotonic_time(milli_seconds) - Timestamp of
+    case erlang:monotonic_time(millisecond) - Timestamp of
       Age when Age < QueryTimeout ->
          put(?NESTING_KEY, ?TOP_LEVEL_TXN),
          put(?STATE_KEY, State),
index 4c4501436407b4f81368a36f9d5c034da3cd4c5a..a112eac35f71111da0ea9b1b21b0cf0e07c8e382 100644 (file)
@@ -1463,7 +1463,7 @@ user_parse_query1(Action, User, Server, Query) ->
     end.
 
 list_last_activity(Host, Lang, Integral, Period) ->
-    TimeStamp = p1_time_compat:system_time(seconds),
+    TimeStamp = erlang:system_time(second),
     case Period of
       <<"all">> -> TS = 0, Days = infinity;
       <<"year">> -> TS = TimeStamp - 366 * 86400, Days = 366;
index 16d7f954cd08bef4b6c0a473cd26d542a0afaf97..2bb8889afe16ae337477ee5cd1c33ada57a5b43c 100644 (file)
@@ -103,7 +103,7 @@ normalize_pid(Metadata) ->
 
 %% Return timestamp with milliseconds
 timestamp(Time, UTCLog) ->
-    {_, _, Micro} = p1_time_compat:timestamp(),
+    {_, _, Micro} = erlang:timestamp(),
     {Date, {Hours, Minutes, Seconds}} =
         case UTCLog of
             true  -> calendar:now_to_universal_time(Time);
index ace340f725d1567802061f552696c0e9f5789026..c617e6c2687d0dd50a03a2a3ca5ee1ba600948a1 100644 (file)
@@ -171,7 +171,7 @@ code_change(_OldVsn, State, _Extra) ->
 %%%===================================================================
 -spec curr_time() -> non_neg_integer().
 curr_time() ->
-    p1_time_compat:monotonic_time(milli_seconds).
+    erlang:monotonic_time(millisecond).
 
 -spec start_port(string()) -> {port(), integer() | undefined}.
 start_port(Path) ->
@@ -188,7 +188,7 @@ call_port(Server, Args) ->
     call_port(Server, Args, ?CALL_TIMEOUT).
 
 call_port(Server, Args, Timeout) ->
-    StartTime = p1_time_compat:monotonic_time(milli_seconds),
+    StartTime = erlang:monotonic_time(millisecond),
     Pool = pool_name(Server),
     PoolSize = pool_size(Server),
     I = p1_rand:round_robin(PoolSize),
index 4655ac22696f07b8a6314e8e97ad67bc5b024b5a..68fc6e81f52bafec1a195c199ecd1136752c938c 100644 (file)
@@ -858,7 +858,7 @@ delete_old_users_vhost(Host, Days) ->
 
 delete_old_users(Days, Users) ->
     SecOlder = Days*24*60*60,
-    TimeStamp_now = p1_time_compat:system_time(seconds),
+    TimeStamp_now = erlang:system_time(second),
     TimeStamp_oldest = TimeStamp_now - SecOlder,
     F = fun({LUser, LServer}) ->
            case catch delete_or_not(LUser, LServer, TimeStamp_oldest) of
@@ -1360,12 +1360,12 @@ get_last(User, Server) ->
         [] ->
             case mod_last:get_last_info(User, Server) of
                 not_found ->
-                   {p1_time_compat:timestamp(), "NOT FOUND"};
+                   {erlang:timestamp(), "NOT FOUND"};
                 {ok, Shift, Status1} ->
                     {{Shift div 1000000, Shift rem 1000000, 0}, Status1}
             end;
         _ ->
-           {p1_time_compat:timestamp(), "ONLINE"}
+           {erlang:timestamp(), "ONLINE"}
     end,
     {xmpp_util:encode_timestamp(Now), Status}.
 
index a0da1867f1207b8da36d32c773ca4a0c82fb3be4..4547d58bd9f312874f0a051bdb0d6d0489dac3a8 100644 (file)
@@ -35,7 +35,7 @@
 -include("logger.hrl").
 
 -record(bosh, {sid = <<"">>      :: binary() | '_',
-               timestamp = p1_time_compat:timestamp() :: erlang:timestamp() | '_',
+               timestamp = erlang:timestamp() :: erlang:timestamp() | '_',
                pid = self()      :: pid() | '$1'}).
 
 -record(state, {}).
@@ -60,7 +60,7 @@ use_cache() ->
     false.
 
 open_session(SID, Pid) ->
-    Session = #bosh{sid = SID, timestamp = p1_time_compat:timestamp(), pid = Pid},
+    Session = #bosh{sid = SID, timestamp = erlang:timestamp(), pid = Pid},
     lists:foreach(
       fun(Node) when Node == node() ->
              gen_server:call(?MODULE, {write, Session});
index 162d47aa2b9cb2e6033b43d724c448889376c83b..e87a2635bea7779ac89c0d6c2f1f9a9d908384d7 100644 (file)
@@ -379,7 +379,7 @@ queue_new() ->
 -spec queue_in(csi_key(), stanza(), csi_queue()) -> csi_queue().
 queue_in(Key, Stanza, {Seq, Q}) ->
     Seq1 = Seq + 1,
-    Time = {Seq1, p1_time_compat:timestamp()},
+    Time = {Seq1, erlang:timestamp()},
     Q1 = maps:put(Key, {Time, Stanza}, Q),
     {Seq1, Q1}.
 
index 141462566b417411c365ff252f0d496a083847ef..3e3d7c578694014ae3487cd92f6473199e5c6244 100644 (file)
@@ -62,7 +62,7 @@ c2s_auth_result(#{ip := {Addr, _}, lserver := LServer} = State, false, _User) ->
                            LServer, ?MODULE, c2s_auth_ban_lifetime),
            MaxFailures = gen_mod:get_module_opt(
                            LServer, ?MODULE, c2s_max_auth_failures),
-           UnbanTS = p1_time_compat:system_time(seconds) + BanLifetime,
+           UnbanTS = erlang:system_time(second) + BanLifetime,
            Attempts = case ets:lookup(failed_auth, Addr) of
                [{Addr, N, _, _}] ->
                               ets:insert(failed_auth,
@@ -88,7 +88,7 @@ c2s_auth_result(#{ip := {Addr, _}} = State, true, _User) ->
 c2s_stream_started(#{ip := {Addr, _}} = State, _) ->
     case ets:lookup(failed_auth, Addr) of
        [{Addr, N, TS, MaxFailures}] when N >= MaxFailures ->
-           case TS > p1_time_compat:system_time(seconds) of
+           case TS > erlang:system_time(second) of
                true ->
                    log_and_disconnect(State, N, TS);
                false ->
@@ -143,7 +143,7 @@ handle_cast(_Msg, State) ->
 
 handle_info(clean, State) ->
     ?DEBUG("cleaning ~p ETS table", [failed_auth]),
-    Now = p1_time_compat:system_time(seconds),
+    Now = erlang:system_time(second),
     ets:select_delete(
       failed_auth,
       ets:fun2ms(fun({_, _, UnbanTS, _}) -> UnbanTS =< Now end)),
index dcae1c27e905104fe30e61e12645ae546ab26114..1cb7470607d89f14713deb2bb0dafd568cddad32 100644 (file)
@@ -117,7 +117,7 @@ get_node_uptime() ->
         undefined ->
             trunc(element(1, erlang:statistics(wall_clock)) / 1000);
         Now ->
-            p1_time_compat:system_time(seconds) - Now
+            erlang:system_time(second) - Now
     end.
 
 %%%
@@ -209,7 +209,7 @@ get_last_iq(#iq{lang = Lang} = IQ, LUser, LServer) ->
                Txt = <<"No info about last activity found">>,
                xmpp:make_error(IQ, xmpp:err_service_unavailable(Txt, Lang));
            {ok, TimeStamp, Status} ->
-               TimeStamp2 = p1_time_compat:system_time(seconds),
+               TimeStamp2 = erlang:system_time(second),
                Sec = TimeStamp2 - TimeStamp,
                xmpp:make_iq_result(IQ, #last{seconds = Sec, status = Status})
          end;
@@ -227,7 +227,7 @@ register_user(User, Server) ->
 
 -spec on_presence_update(binary(), binary(), binary(), binary()) -> any().
 on_presence_update(User, Server, _Resource, Status) ->
-    TimeStamp = p1_time_compat:system_time(seconds),
+    TimeStamp = erlang:system_time(second),
     store_last_info(User, Server, TimeStamp, Status).
 
 -spec store_last_info(binary(), binary(), non_neg_integer(), binary()) -> any().
index ee38f5011348412e5a69bf71cf7751e20f09bf1a..e066f6d0e9709c447f46ba6ef0f80ec868e16566 100644 (file)
@@ -440,7 +440,7 @@ muc_filter_message(Acc, _MUCState, _FromNick) ->
 
 -spec make_id() -> binary().
 make_id() ->
-    p1_time_compat:system_time(micro_seconds).
+    erlang:system_time(microsecond).
 
 -spec get_stanza_id(stanza()) -> integer().
 get_stanza_id(#message{meta = #{stanza_id := ID}}) ->
index a84d92b9cb1c469b49818e4749587b5bd66ab360..070f927e232ed9c9099656c7b14e799d1c0ce8b6 100644 (file)
@@ -138,7 +138,7 @@ send_metrics(Host, Probe, Peer, Port) ->
     [_, FQDN] = binary:split(misc:atom_to_binary(node()), <<"@">>),
     [Node|_] = binary:split(FQDN, <<".">>),
     BaseId = <<Host/binary, "/", Node/binary, ".">>,
-    TS = integer_to_binary(p1_time_compat:system_time(seconds)),
+    TS = integer_to_binary(erlang:system_time(second)),
     case get_socket(?SOCKET_REGISTER_RETRIES) of
        {ok, Socket} ->
            case Probe of
index 19b2c39832e625366f9f450d7a7cb03072239d81..38c03d7610d877243a0876b43d0b06a75b73266d 100644 (file)
@@ -87,7 +87,7 @@ set_channel(_LServer, Channel, Service, CreatorJID, Hidden, Key) ->
                   creator = jid:remove_resource(CreatorJID),
                   hidden = Hidden,
                   hmac_key = Key,
-                  created_at = p1_time_compat:timestamp()}).
+                  created_at = erlang:timestamp()}).
 
 get_channels(_LServer, Service) ->
     Ret = mnesia:dirty_index_read(mix_channel, Service, #mix_channel.service),
@@ -127,7 +127,7 @@ set_participant(_LServer, Channel, Service, JID, ID, Nick) ->
         jid = jid:remove_resource(JID),
         id = ID,
         nick = Nick,
-        created_at = p1_time_compat:timestamp()}).
+        created_at = erlang:timestamp()}).
 
 get_participant(_LServer, Channel, Service, JID) ->
     {User, Domain, _} = jid:tolower(JID),
index 3df36b8fbbfcd09a4a7a2db769d564882e095d68..abb5917bf12b04acb77dafbf6397431907f9d6e8 100644 (file)
@@ -1061,11 +1061,11 @@ topic_alias_maximum(Host) ->
 %%%===================================================================
 -spec current_time() -> milli_seconds().
 current_time() ->
-    p1_time_compat:monotonic_time(milli_seconds).
+    erlang:monotonic_time(millisecond).
 
 -spec unix_time() -> seconds().
 unix_time() ->
-    p1_time_compat:system_time(seconds).
+    erlang:system_time(second).
 
 -spec set_keep_alive(state(), seconds()) -> state().
 set_keep_alive(State, 0) ->
index ae3c6f9f767403c1aa0a0824ca4ace5036605f51..9d53b89749ccbf9d0d7998feb811f8089bb4a057 100644 (file)
@@ -584,7 +584,7 @@ process_muc_unique(#iq{type = set, lang = Lang} = IQ) ->
     xmpp:make_error(IQ, xmpp:err_not_allowed(Txt, Lang));
 process_muc_unique(#iq{from = From, type = get,
                       sub_els = [#muc_unique{}]} = IQ) ->
-    Name = str:sha(term_to_binary([From, p1_time_compat:timestamp(),
+    Name = str:sha(term_to_binary([From, erlang:timestamp(),
                                      p1_rand:get_string()])),
     xmpp:make_iq_result(IQ, #muc_unique{name = Name}).
 
index b3840bc4831f226f2c3f1e858eadc30b0d0a1d06..f033ce1655bde8923a89fe497fc171ef06fc9aef 100644 (file)
@@ -819,7 +819,7 @@ decide_room(unused, {_Room_name, _Host, Room_pid}, ServerHost, Last_allowed) ->
                           true when (HistorySize == 0) or (JustCreated == true) ->
                               {false, 0};
                           true ->
-                              Ts_diff = (p1_time_compat:os_system_time(micro_seconds)
+                              Ts_diff = (erlang:system_time(microsecond)
                                    - S#state.just_created) div 1000000,
                               {false, Ts_diff};
                           false ->
index 42a9cc0a51ea806694edc8f1d2a2d6fca58e2d7f..3e4f672476975a2028f66264e8e4ccdac2918948 100644 (file)
@@ -309,7 +309,7 @@ add_message_to_log(Nick1, Message, RoomJID, Opts,
     Room = get_room_info(RoomJID, Opts),
     Nick = htmlize(Nick1, FileFormat),
     Nick2 = htmlize_nick(Nick1, 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)
@@ -625,7 +625,7 @@ put_header_script(F) ->
 put_room_config(_F, _RoomConfig, _Lang, plaintext) ->
     ok;
 put_room_config(F, RoomConfig, Lang, _FileFormat) ->
-    {_, Now2, _} = p1_time_compat:timestamp(),
+    {_, Now2, _} = erlang:timestamp(),
     fw(F, <<"<div class=\"rc\">">>),
     fw(F,
        <<"<div class=\"rct\" onclick=\"sh('a~p');return "
@@ -642,7 +642,7 @@ put_room_occupants(_F, _RoomOccupants, _Lang,
     ok;
 put_room_occupants(F, RoomOccupants, Lang,
                   _FileFormat) ->
-    {_, Now2, _} = p1_time_compat:timestamp(),
+    {_, Now2, _} = erlang:timestamp(),
 %% htmlize
 %% The default behaviour is to ignore the nofollow spam prevention on links
 %% (NoFollow=false)
index ec1222855228ca35c462592092a66398f6b87e91..8c567a6c40fb462a8a5a05f08886c85a983d7853 100644 (file)
@@ -162,7 +162,7 @@ normal_state({route, <<"">>,
        is_user_allowed_message_nonparticipant(From, StateData) of
        true when Type == groupchat ->
            Activity = get_user_activity(From, StateData),
-           Now = p1_time_compat:system_time(micro_seconds),
+           Now = erlang:system_time(microsecond),
            MinMessageInterval = trunc(gen_mod:get_module_opt(
                                         StateData#state.server_host,
                                         mod_muc, min_message_interval)
@@ -344,7 +344,7 @@ normal_state({route, <<"">>, #iq{} = IQ}, StateData) ->
     end;
 normal_state({route, Nick, #presence{from = From} = Packet}, StateData) ->
     Activity = get_user_activity(From, StateData),
-    Now = p1_time_compat:system_time(micro_seconds),
+    Now = erlang:system_time(microsecond),
     MinPresenceInterval =
        trunc(gen_mod:get_module_opt(StateData#state.server_host,
                                     mod_muc, min_presence_interval)
@@ -903,7 +903,7 @@ process_voice_request(From, Pkt, StateData) ->
        true ->
            MinInterval = (StateData#state.config)#config.voice_request_min_interval,
            BareFrom = jid:remove_resource(jid:tolower(From)),
-           NowPriority = -p1_time_compat:system_time(micro_seconds),
+           NowPriority = -erlang:system_time(microsecond),
            CleanPriority = NowPriority + MinInterval * 1000000,
            Times = clean_treap(StateData#state.last_voice_request_time,
                                CleanPriority),
@@ -1572,7 +1572,7 @@ store_user_activity(JID, UserActivity, StateData) ->
                                     mod_muc, min_presence_interval)
              * 1000),
     Key = jid:tolower(JID),
-    Now = p1_time_compat:system_time(micro_seconds),
+    Now = erlang:system_time(microsecond),
     Activity1 = clean_treap(StateData#state.activity,
                            {1, -Now}),
     Activity = case treap:lookup(Key, Activity1) of
@@ -1960,7 +1960,7 @@ add_new_user(From, Nick, Packet, StateData) ->
                  ResultState =
                      case NewStateData#state.just_created of
                          true ->
-                             NewStateData#state{just_created = p1_time_compat:os_system_time(micro_seconds)};
+                             NewStateData#state{just_created = erlang:system_time(microsecond)};
                          _ ->
                              Robots = maps:remove(From, StateData#state.robots),
                              NewStateData#state{robots = Robots}
@@ -2103,7 +2103,7 @@ extract_password(#iq{} = IQ) ->
 get_history(Nick, Packet, #state{history = History}) ->
     case xmpp:get_subtag(Packet, #muc{}) of
        #muc{history = #muc_history{} = MUCHistory} ->
-           Now = p1_time_compat:timestamp(),
+           Now = erlang:timestamp(),
            Q = History#lqueue.queue,
            filter_history(Q, Now, Nick, MUCHistory);
        _ ->
@@ -2518,7 +2518,7 @@ add_message_to_history(FromNick, FromJID, Packet, StateData) ->
     add_to_log(text, {FromNick, Packet}, StateData),
     case check_subject(Packet) of
        [] ->
-           TimeStamp = p1_time_compat:timestamp(),
+           TimeStamp = erlang:timestamp(),
            AddrPacket = case (StateData#state.config)#config.anonymous of
                             true -> Packet;
                             false ->
index 2582a7c98481b84ece8b9434b113cb435bb7a88d..7150d29727c63f58d5567239be60474c68bb3a49 100644 (file)
@@ -413,7 +413,7 @@ store_packet({_Action, #message{from = From, to = To} = Packet} = Acc) ->
                        drop ->
                            Acc;
                        NewPacket ->
-                           TimeStamp = p1_time_compat:timestamp(),
+                           TimeStamp = erlang:timestamp(),
                            Expire = find_x_expire(TimeStamp, NewPacket),
                            OffMsg = #offline_msg{us = {LUser, LServer},
                                                  timestamp = TimeStamp,
@@ -538,7 +538,7 @@ route_offline_message(#{lserver := LServer} = State,
 
 -spec is_message_expired(erlang:timestamp() | never, message()) -> boolean().
 is_message_expired(Expire, Msg) ->
-    TS = p1_time_compat:timestamp(),
+    TS = erlang:timestamp(),
     Expire1 = case Expire of
                  undefined -> find_x_expire(TS, Msg);
                  _ -> Expire
@@ -807,7 +807,7 @@ count_offline_messages(User, Server) ->
                     undefined | erlang:timestamp()) -> message().
 add_delay_info(Packet, LServer, TS) ->
     NewTS = case TS of
-               undefined -> p1_time_compat:timestamp();
+               undefined -> erlang:timestamp();
                _ -> TS
            end,
     Packet1 = xmpp:put_meta(Packet, from_offline, true),
@@ -840,7 +840,7 @@ import(LServer, {sql, _}, DBType, <<"spool">>,
             #delay{stamp = {MegaSecs, Secs, _}} ->
                 {MegaSecs, Secs, 0};
             false ->
-                p1_time_compat:timestamp()
+                erlang:timestamp()
         end,
     US = {LUser, LServer},
     Expire = find_x_expire(TS, Msg),
index 77c5b2e4447935ce80322cdbf35f5aaa2dd020db..2356bbf034ad0c15b29667774a8a081c1b6f3bb9 100644 (file)
@@ -63,7 +63,7 @@ pop_messages(LUser, LServer) ->
     end.
 
 remove_expired_messages(_LServer) ->
-    TimeStamp = p1_time_compat:timestamp(),
+    TimeStamp = erlang:timestamp(),
     F = fun () ->
                mnesia:write_lock_table(offline_msg),
                mnesia:foldl(fun (Rec, _Acc) ->
@@ -81,7 +81,7 @@ remove_expired_messages(_LServer) ->
     mnesia:transaction(F).
 
 remove_old_messages(Days, _LServer) ->
-    S = p1_time_compat:system_time(seconds) - 60 * 60 * 24 * Days,
+    S = erlang:system_time(second) - 60 * 60 * 24 * Days,
     MegaSecs1 = S div 1000000,
     Secs1 = S rem 1000000,
     TimeStamp = {MegaSecs1, Secs1, 0},
index c1473e344d454b1bc10046590e82842d9e2c3f76..6c12904694551f8093d256e14d511362a389087b 100644 (file)
@@ -80,7 +80,7 @@ check_packet(Acc, _, _, _) ->
 update(Server, JID, Dir) ->
     StormCount = gen_mod:get_module_opt(Server, ?MODULE, count),
     TimeInterval = gen_mod:get_module_opt(Server, ?MODULE, interval),
-    TimeStamp = p1_time_compat:system_time(seconds),
+    TimeStamp = erlang:system_time(second),
     case read(Dir) of
       undefined ->
          write(Dir,
index b332dd3212034640e51558a36b1d04afc87a91a7..1f220f3c69c9cbe1e322daa8134ca37c5311a915 100644 (file)
@@ -2571,7 +2571,7 @@ sub_option_can_deliver(nodes, _, {subscription_type, items}) -> false;
 sub_option_can_deliver(_, _, {subscription_depth, all}) -> true;
 sub_option_can_deliver(_, Depth, {subscription_depth, D}) -> Depth =< D;
 sub_option_can_deliver(_, _, {deliver, false}) -> false;
-sub_option_can_deliver(_, _, {expire, When}) -> p1_time_compat:timestamp() < When;
+sub_option_can_deliver(_, _, {expire, When}) -> erlang:timestamp() < When;
 sub_option_can_deliver(_, _, _) -> true.
 
 -spec presence_can_deliver(ljid(), boolean()) -> boolean().
@@ -3371,7 +3371,7 @@ set_cached_item({_, ServerHost, _}, Nidx, ItemId, Publisher, Payload) ->
 set_cached_item(Host, Nidx, ItemId, Publisher, Payload) ->
     case is_last_item_cache_enabled(Host) of
        true ->
-           Stamp = {p1_time_compat:timestamp(), jid:tolower(jid:remove_resource(Publisher))},
+           Stamp = {erlang:timestamp(), jid:tolower(jid:remove_resource(Publisher))},
            Item = #pubsub_last_item{nodeid = {Host, Nidx},
                                     itemid = ItemId,
                                     creation = Stamp,
@@ -3748,7 +3748,7 @@ err_unsupported_access_model() ->
 
 -spec uniqid() -> mod_pubsub:itemId().
 uniqid() ->
-    {T1, T2, T3} = p1_time_compat:timestamp(),
+    {T1, T2, T3} = erlang:timestamp(),
     (str:format("~.16B~.16B~.16B", [T1, T2, T3])).
 
 -spec add_message_type(message(), message_type()) -> message().
index 1a12f60292b0ce29fcca04ce7039bbd6ab4895b5..a6e8713757d2f2300e81f41a03b637796e55af35 100644 (file)
@@ -163,7 +163,7 @@ get_commands_spec() ->
 
 -spec delete_old_sessions(non_neg_integer()) -> ok | any().
 delete_old_sessions(Days) ->
-    CurrentTime = p1_time_compat:system_time(micro_seconds),
+    CurrentTime = erlang:system_time(microsecond),
     Diff = Days * 24 * 60 * 60 * 1000000,
     TimeStamp = misc:usec_to_now(CurrentTime - Diff),
     DBTypes = lists:usort(
index 841053a43f46918b59433ae4b342f47b36137a84..594800b15352f8ed403da64edae85751eb560309 100644 (file)
@@ -422,7 +422,7 @@ check_timeout(undefined) -> true;
 check_timeout(Source) ->
     Timeout = ejabberd_config:get_option(registration_timeout, 600),
     if is_integer(Timeout) ->
-          Priority = -p1_time_compat:system_time(seconds),
+          Priority = -erlang:system_time(second),
           CleanPriority = Priority + Timeout,
           F = fun () ->
                       Treap = case mnesia:read(mod_register_ip, treap, write)
index c67f5bb327b9a8c1002a1b45d43bbe6b31017841..da619c57c155a54e4f7249b57890430cbb300c4a 100644 (file)
@@ -251,7 +251,7 @@ write_roster_version_t(LUser, LServer) ->
     write_roster_version(LUser, LServer, true).
 
 write_roster_version(LUser, LServer, InTransaction) ->
-    Ver = str:sha(term_to_binary(p1_time_compat:unique_integer())),
+    Ver = str:sha(term_to_binary(erlang:unique_integer())),
     Mod = gen_mod:db_mod(LServer, ?MODULE),
     Mod:write_roster_version(LUser, LServer, InTransaction, Ver),
     if InTransaction -> ok;
index 5efc238e06874a11b7626325aa16ae46c933d0ce..b2d9543ebf5123ca1568902b549923f61d5f7faa 100644 (file)
@@ -302,7 +302,7 @@ add_record_route_and_set_uri(URI, LServer, #sip{hdrs = Hdrs} = Req) ->
            case need_record_route(LServer) of
                true ->
                    RR_URI = get_configured_record_route(LServer),
-                   TS = (integer_to_binary(p1_time_compat:system_time(seconds))),
+                   TS = (integer_to_binary(erlang:system_time(second))),
                    Sign = make_sign(TS, Hdrs),
                    User = <<TS/binary, $-, Sign/binary>>,
                    NewRR_URI = RR_URI#uri{user = User},
@@ -339,7 +339,7 @@ is_signed_by_me(TS_Sign, Hdrs) ->
     try
        [TSBin, Sign] = str:tokens(TS_Sign, <<"-">>),
        TS = (binary_to_integer(TSBin)),
-       NowTS = p1_time_compat:system_time(seconds),
+       NowTS = erlang:system_time(second),
        true = (NowTS - TS) =< ?SIGN_LIFETIME,
        Sign == make_sign(TSBin, Hdrs)
     catch _:_ ->
index 787ec0cb82a3617beadf7960e656d71152096732..4805e788f8570ed9d20702265d5b83d154aa4094 100644 (file)
@@ -50,7 +50,7 @@
                      socket = #sip_socket{} :: #sip_socket{},
                      call_id = <<"">> :: binary(),
                      cseq = 0 :: non_neg_integer(),
-                     timestamp = p1_time_compat:timestamp() :: erlang:timestamp(),
+                     timestamp = erlang:timestamp() :: erlang:timestamp(),
                      contact :: {binary(), #uri{}, [{binary(), binary()}]},
                      flow_tref :: reference() | undefined,
                      reg_tref = make_ref() :: reference(),
@@ -243,7 +243,7 @@ register_session(US, SIPSocket, CallID, CSeq, IsOutboundSupported,
                                      socket = SIPSocket,
                                      call_id = CallID,
                                      cseq = CSeq,
-                                     timestamp = p1_time_compat:timestamp(),
+                                     timestamp = erlang:timestamp(),
                                      contact = Contact,
                                      expires = Expires}
                 end, ContactsWithExpires),
index 4c38b87af42df94914b062c6ca6ea25b0f7fb2ee..1a4308c58cb992dc6c5ea52ce9b66ea53045042b 100644 (file)
@@ -523,7 +523,7 @@ mgmt_queue_add(#{mgmt_stanzas_out := NumStanzasOut,
                 4294967295 -> 0;
                 Num -> Num + 1
             end,
-    Queue1 = p1_queue:in({NewNum, p1_time_compat:timestamp(), Pkt}, Queue),
+    Queue1 = p1_queue:in({NewNum, erlang:timestamp(), Pkt}, Queue),
     State1 = State#{mgmt_queue => Queue1, mgmt_stanzas_out => NewNum},
     check_queue_length(State1).
 
index 6c4a0bae5d2ce5d49740f8a5227d88478c85b229..1db3abe13c84f0eef2974206134a30fc47c763d9 100644 (file)
@@ -54,7 +54,7 @@ process_local_iq(#iq{type = set, lang = Lang} = IQ) ->
     Txt = <<"Value 'set' of 'type' attribute is not allowed">>,
     xmpp:make_error(IQ, xmpp:err_not_allowed(Txt, Lang));
 process_local_iq(#iq{type = get} = IQ) ->
-    Now = p1_time_compat:timestamp(),
+    Now = erlang:timestamp(),
     Now_universal = calendar:now_to_universal_time(Now),
     Now_local = calendar:universal_time_to_local_time(Now_universal),
     Seconds_diff =
index 2c0d7869abe9d8bd1374c1f5ca0c0c52293f157b..e7c61aac18a5ba8a675228e289128062ec959f18 100644 (file)
@@ -376,7 +376,7 @@ publish_item(Nidx, Publisher, PublishModel, MaxItems, ItemId, Payload,
            {error, xmpp:err_forbidden()};
        true ->
            if MaxItems > 0 ->
-                   Now = p1_time_compat:timestamp(),
+                   Now = erlang:timestamp(),
                    case get_item(Nidx, ItemId) of
                        {result, #pubsub_item{creation = {_, GenKey}} = OldItem} ->
                            set_item(OldItem#pubsub_item{
index cdf7fe3a97736fb9bc5a90654849bc73db3affb0..adb7d59c63b2a9751ae2579efb114e4e559baf71 100644 (file)
@@ -247,7 +247,7 @@ publish_item(Nidx, Publisher, PublishModel, MaxItems, ItemId, Payload,
            {error, xmpp:err_forbidden()};
        true ->
            if MaxItems > 0 ->
-                   Now = p1_time_compat:timestamp(),
+                   Now = erlang:timestamp(),
                    case get_item(Nidx, ItemId) of
                        {result, #pubsub_item{creation = {_, GenKey}} = OldItem} ->
                            set_item(OldItem#pubsub_item{
index da7d5b997bcbb7de512f8f12113a1ba6ec0d8531..e3587df5333cd1abdf8313f119027e79c0fd6275 100644 (file)
@@ -59,7 +59,7 @@ update_node_database(Host, ServerHost) ->
                                                                                        {unknown,
                                                                                         Publisher},
                                                                                    M =
-                                                                                       {p1_time_compat:timestamp(),
+                                                                                       {erlang:timestamp(),
                                                                                         Publisher},
                                                                                    mnesia:write(#pubsub_item{itemid
                                                                                                                  =
index 88a19c3c68ba035027e11dc0fc03b08bb5a5db91..1ce1dc73f131b7c0e01f8f00becc93a8905c607d 100644 (file)
@@ -169,7 +169,7 @@ write_subscription(_JID, _NodeId, SubID, Options) ->
 
 -spec make_subid() -> SubId::mod_pubsub:subId().
 make_subid() ->
-    {T1, T2, T3} = p1_time_compat:timestamp(),
+    {T1, T2, T3} = erlang:timestamp(),
     (str:format("~.16B~.16B~.16B", [T1, T2, T3])).
 
 %%
index 194b2676a1f92a7743aefdccf273506a2f755597..2b60ad0b3c27e70a13d791abe0c1534c8e7d1b08 100644 (file)
@@ -134,7 +134,7 @@ create_table() -> ok.
 
 -spec make_subid() -> mod_pubsub:subId().
 make_subid() ->
-    {T1, T2, T3} = p1_time_compat:timestamp(),
+    {T1, T2, T3} = erlang:timestamp(),
     (str:format("~.16B~.16B~.16B", [T1, T2, T3])).
 
 %%