25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

More now() removal

This commit is contained in:
Paweł Chmielowski 2015-12-06 15:58:46 +01:00
parent 5c329a7699
commit 0a846d03bf
4 changed files with 10 additions and 12 deletions

View File

@ -69,8 +69,7 @@ start() ->
State0 = read_file(Config), State0 = read_file(Config),
State = validate_opts(State0), State = validate_opts(State0),
%% This start time is used by mod_last: %% This start time is used by mod_last:
{MegaSecs, Secs, _} = now(), UnixTime = p1_time_compat:system_time(seconds),
UnixTime = MegaSecs*1000000 + Secs,
SharedKey = case erlang:get_cookie() of SharedKey = case erlang:get_cookie() of
nocookie -> nocookie ->
p1_sha:sha(randoms:get_string()); p1_sha:sha(randoms:get_string());

View File

@ -102,7 +102,7 @@ get_pids(Host) ->
get_random_pid(Host) -> get_random_pid(Host) ->
case get_pids(Host) of case get_pids(Host) of
[] -> none; [] -> none;
Pids -> lists:nth(erlang:phash(now(), length(Pids)), Pids) Pids -> lists:nth(erlang:phash(p1_time_compat:unique_integer(), length(Pids)), Pids)
end. end.
add_pid(Host, Pid) -> add_pid(Host, Pid) ->

View File

@ -648,7 +648,7 @@ gb_trees_fold_iter(F, Acc, Iter) ->
end. end.
now_ts() -> now_ts() ->
{MegaSecs, Secs, _} = now(), MegaSecs * 1000000 + Secs. {MegaSecs, Secs, _} = p1_time_compat:system_time(seconds).
is_valid_node(Node) -> is_valid_node(Node) ->
case str:tokens(Node, <<"#">>) of case str:tokens(Node, <<"#">>) of

View File

@ -309,7 +309,7 @@ store_packet(From, To, Packet) ->
case check_event(From, To, Packet) of case check_event(From, To, Packet) of
true -> true ->
#jid{luser = LUser, lserver = LServer} = To, #jid{luser = LUser, lserver = LServer} = To,
TimeStamp = now(), TimeStamp = p1_time_compat:timestamp(),
#xmlel{children = Els} = Packet, #xmlel{children = Els} = Packet,
Expire = find_x_expire(TimeStamp, Els), Expire = find_x_expire(TimeStamp, Els),
gen_mod:get_module_proc(To#jid.lserver, ?PROCNAME) ! gen_mod:get_module_proc(To#jid.lserver, ?PROCNAME) !
@ -441,7 +441,7 @@ pop_offline_messages(Ls, LUser, LServer, mnesia) ->
end, end,
case mnesia:transaction(F) of case mnesia:transaction(F) of
{atomic, Rs} -> {atomic, Rs} ->
TS = now(), TS = p1_time_compat:timestamp(),
Ls ++ Ls ++
lists:map(fun (R) -> lists:map(fun (R) ->
offline_msg_to_route(LServer, R) offline_msg_to_route(LServer, R)
@ -487,7 +487,7 @@ pop_offline_messages(Ls, LUser, LServer, riak) ->
fun(#offline_msg{timestamp = T}) -> fun(#offline_msg{timestamp = T}) ->
ok = ejabberd_riak:delete(offline_msg, T) ok = ejabberd_riak:delete(offline_msg, T)
end, Rs), end, Rs),
TS = now(), TS = p1_time_compat:timestamp(),
Ls ++ lists:map( Ls ++ lists:map(
fun (R) -> fun (R) ->
offline_msg_to_route(LServer, R) offline_msg_to_route(LServer, R)
@ -513,7 +513,7 @@ remove_expired_messages(Server) ->
gen_mod:db_type(LServer, ?MODULE)). gen_mod:db_type(LServer, ?MODULE)).
remove_expired_messages(_LServer, mnesia) -> remove_expired_messages(_LServer, mnesia) ->
TimeStamp = now(), TimeStamp = p1_time_compat:timestamp(),
F = fun () -> F = fun () ->
mnesia:write_lock_table(offline_msg), mnesia:write_lock_table(offline_msg),
mnesia:foldl(fun (Rec, _Acc) -> mnesia:foldl(fun (Rec, _Acc) ->
@ -538,8 +538,7 @@ remove_old_messages(Days, Server) ->
gen_mod:db_type(LServer, ?MODULE)). gen_mod:db_type(LServer, ?MODULE)).
remove_old_messages(Days, _LServer, mnesia) -> remove_old_messages(Days, _LServer, mnesia) ->
{MegaSecs, Secs, _MicroSecs} = now(), S = p1_time_compat:system_time(seconds) - 60 * 60 * 24 * Days,
S = MegaSecs * 1000000 + Secs - 60 * 60 * 24 * Days,
MegaSecs1 = S div 1000000, MegaSecs1 = S div 1000000,
Secs1 = S rem 1000000, Secs1 = S rem 1000000,
TimeStamp = {MegaSecs1, Secs1, 0}, TimeStamp = {MegaSecs1, Secs1, 0},
@ -949,7 +948,7 @@ get_messages_subset2(Max, Length, MsgsAll, DBType)
MsgsLastN = lists:nthtail(Length - FirstN - FirstN, MsgsLastN = lists:nthtail(Length - FirstN - FirstN,
Msgs2), Msgs2),
NoJID = jid:make(<<"...">>, <<"...">>, <<"">>), NoJID = jid:make(<<"...">>, <<"...">>, <<"">>),
IntermediateMsg = #offline_msg{timestamp = now(), IntermediateMsg = #offline_msg{timestamp = p1_time_compat:timestamp(),
from = NoJID, to = NoJID, from = NoJID, to = NoJID,
packet = packet =
#xmlel{name = <<"...">>, attrs = [], #xmlel{name = <<"...">>, attrs = [],
@ -1113,7 +1112,7 @@ import(LServer) ->
{_, _, _} = Now -> {_, _, _} = Now ->
Now; Now;
undefined -> undefined ->
now() p1_time_compat:timestamp()
end, end,
Expire = find_x_expire(TS, El#xmlel.children), Expire = find_x_expire(TS, El#xmlel.children),
#offline_msg{us = {LUser, LServer}, #offline_msg{us = {LUser, LServer},