aboutsummaryrefslogtreecommitdiffstats
path: root/lib/diameter/src/base
diff options
context:
space:
mode:
Diffstat (limited to 'lib/diameter/src/base')
-rw-r--r--lib/diameter/src/base/diameter_config.erl3
-rw-r--r--lib/diameter/src/base/diameter_lib.erl73
-rw-r--r--lib/diameter/src/base/diameter_peer.erl3
-rw-r--r--lib/diameter/src/base/diameter_reg.erl3
-rw-r--r--lib/diameter/src/base/diameter_service.erl5
-rw-r--r--lib/diameter/src/base/diameter_session.erl4
-rw-r--r--lib/diameter/src/base/diameter_stats.erl3
-rw-r--r--lib/diameter/src/base/diameter_sync.erl3
-rw-r--r--lib/diameter/src/base/diameter_watchdog.erl7
9 files changed, 11 insertions, 93 deletions
diff --git a/lib/diameter/src/base/diameter_config.erl b/lib/diameter/src/base/diameter_config.erl
index 8ac3b9d6ca..89b26707ad 100644
--- a/lib/diameter/src/base/diameter_config.erl
+++ b/lib/diameter/src/base/diameter_config.erl
@@ -37,8 +37,7 @@
-module(diameter_config).
-behaviour(gen_server).
--compile({no_auto_import, [monitor/2, now/0]}).
--import(diameter_lib, [now/0]).
+-compile({no_auto_import, [monitor/2]}).
-export([start_service/2,
stop_service/1,
diff --git a/lib/diameter/src/base/diameter_lib.erl b/lib/diameter/src/base/diameter_lib.erl
index 6a94e32b0e..e8009c6a14 100644
--- a/lib/diameter/src/base/diameter_lib.erl
+++ b/lib/diameter/src/base/diameter_lib.erl
@@ -18,18 +18,12 @@
%%
-module(diameter_lib).
--compile({no_auto_import, [now/0]}).
-export([info_report/2,
error_report/2,
warning_report/2,
- now/0,
- timestamp/1,
now_diff/1,
- micro_diff/1,
- micro_diff/2,
time/1,
- seed/0,
eval/1,
eval_name/1,
get_stacktrace/0,
@@ -98,36 +92,10 @@ fmt(T) ->
end.
%% ---------------------------------------------------------------------------
-%% # now/0
-%% ---------------------------------------------------------------------------
-
--type timestamp() :: {non_neg_integer(), 0..999999, 0..999999}.
--type now() :: timestamp().
-
--spec now()
- -> now().
-
-%% Use monotonic time if it exists, fall back to erlang:now()
-%% otherwise.
-
-now() ->
- erlang:now().
-
-%% ---------------------------------------------------------------------------
-%% # timestamp/1
-%% ---------------------------------------------------------------------------
-
--spec timestamp(NowT :: now())
- -> timestamp().
-
-timestamp({_,_,_} = T) -> %% erlang:now()
- T.
-
-%% ---------------------------------------------------------------------------
%% # now_diff/1
%% ---------------------------------------------------------------------------
--spec now_diff(NowT :: now())
+-spec now_diff(NowT :: erlang:timestamp())
-> {Hours, Mins, Secs, MicroSecs}
when Hours :: non_neg_integer(),
Mins :: 0..59,
@@ -138,29 +106,7 @@ timestamp({_,_,_} = T) -> %% erlang:now()
%% instead of as integer microseconds.
now_diff(Time) ->
- time(micro_diff(Time)).
-
-%% ---------------------------------------------------------------------------
-%% # micro_diff/1
-%% ---------------------------------------------------------------------------
-
--spec micro_diff(NowT :: now())
- -> MicroSecs
- when MicroSecs :: non_neg_integer().
-
-micro_diff({_,_,_} = T0) ->
- timer:now_diff(erlang:now(), T0).
-
-%% ---------------------------------------------------------------------------
-%% # micro_diff/2
-%% ---------------------------------------------------------------------------
-
--spec micro_diff(T1 :: now(), T0 :: now())
- -> MicroSecs
- when MicroSecs :: non_neg_integer().
-
-micro_diff(T1, T0) -> %% at least one erlang:now()
- timer:now_diff(T1, T0).
+ time(timer:now_diff(now(), Time)).
%% ---------------------------------------------------------------------------
%% # time/1
@@ -170,7 +116,7 @@ micro_diff(T1, T0) -> %% at least one erlang:now()
-spec time(NowT | Diff)
-> {Hours, Mins, Secs, MicroSecs}
- when NowT :: timestamp(),
+ when NowT :: erlang:timestamp(),
Diff :: non_neg_integer(),
Hours :: non_neg_integer(),
Mins :: 0..59,
@@ -189,19 +135,6 @@ time(Micro) -> %% elapsed time
{H, M, S, Micro rem 1000000}.
%% ---------------------------------------------------------------------------
-%% # seed/0
-%% ---------------------------------------------------------------------------
-
--spec seed()
- -> {timestamp(), {integer(), integer(), integer()}}.
-
-%% Return an argument for random:seed/1.
-
-seed() ->
- T = now(),
- {T, T}.
-
-%% ---------------------------------------------------------------------------
%% # eval/1
%%
%% Evaluate a function in various forms.
diff --git a/lib/diameter/src/base/diameter_peer.erl b/lib/diameter/src/base/diameter_peer.erl
index 89b63c8a92..356383dbab 100644
--- a/lib/diameter/src/base/diameter_peer.erl
+++ b/lib/diameter/src/base/diameter_peer.erl
@@ -20,9 +20,6 @@
-module(diameter_peer).
-behaviour(gen_server).
--compile({no_auto_import, [now/0]}).
--import(diameter_lib, [now/0]).
-
%% Interface towards transport modules ...
-export([recv/2,
up/1,
diff --git a/lib/diameter/src/base/diameter_reg.erl b/lib/diameter/src/base/diameter_reg.erl
index f785777874..6bb4710e63 100644
--- a/lib/diameter/src/base/diameter_reg.erl
+++ b/lib/diameter/src/base/diameter_reg.erl
@@ -24,8 +24,7 @@
-module(diameter_reg).
-behaviour(gen_server).
--compile({no_auto_import, [monitor/2, now/0]}).
--import(diameter_lib, [now/0]).
+-compile({no_auto_import, [monitor/2]}).
-export([add/1,
add_new/1,
diff --git a/lib/diameter/src/base/diameter_service.erl b/lib/diameter/src/base/diameter_service.erl
index 86e744dfbe..a31cef2c8c 100644
--- a/lib/diameter/src/base/diameter_service.erl
+++ b/lib/diameter/src/base/diameter_service.erl
@@ -24,9 +24,6 @@
-module(diameter_service).
-behaviour(gen_server).
--compile({no_auto_import, [now/0]}).
--import(diameter_lib, [now/0]).
-
%% towards diameter_service_sup
-export([start_link/1]).
@@ -1218,7 +1215,7 @@ connect_timer(Opts, Def0) ->
%% continuous restarted in case of faulty config or other problems.
tc(Time, Tc) ->
choose(Tc > ?RESTART_TC
- orelse diameter_lib:micro_diff(Time) > 1000*?RESTART_TC,
+ orelse timer:now_diff(now(), Time) > 1000*?RESTART_TC,
Tc,
?RESTART_TC).
diff --git a/lib/diameter/src/base/diameter_session.erl b/lib/diameter/src/base/diameter_session.erl
index c5ea0428b5..3b236f109a 100644
--- a/lib/diameter/src/base/diameter_session.erl
+++ b/lib/diameter/src/base/diameter_session.erl
@@ -157,8 +157,8 @@ session_id(Host) ->
%% ---------------------------------------------------------------------------
init() ->
- {Now, Seed} = diameter_lib:seed(),
- random:seed(Seed),
+ Now = now(),
+ random:seed(Now),
Time = time32(Now),
Seq = (?INT32 band (Time bsl 20)) bor (random:uniform(1 bsl 20) - 1),
ets:insert(diameter_sequence, [{origin_state_id, Time},
diff --git a/lib/diameter/src/base/diameter_stats.erl b/lib/diameter/src/base/diameter_stats.erl
index d2c760317a..5eb8fa1cba 100644
--- a/lib/diameter/src/base/diameter_stats.erl
+++ b/lib/diameter/src/base/diameter_stats.erl
@@ -24,9 +24,6 @@
-module(diameter_stats).
-behaviour(gen_server).
--compile({no_auto_import, [now/0]}).
--import(diameter_lib, [now/0]).
-
-export([reg/2, reg/1,
incr/3, incr/1,
read/1,
diff --git a/lib/diameter/src/base/diameter_sync.erl b/lib/diameter/src/base/diameter_sync.erl
index 90eabece3d..cee06b9e96 100644
--- a/lib/diameter/src/base/diameter_sync.erl
+++ b/lib/diameter/src/base/diameter_sync.erl
@@ -27,9 +27,6 @@
-module(diameter_sync).
-behaviour(gen_server).
--compile({no_auto_import, [now/0]}).
--import(diameter_lib, [now/0]).
-
-export([call/4, call/5,
cast/4, cast/5,
carp/1, carp/2]).
diff --git a/lib/diameter/src/base/diameter_watchdog.erl b/lib/diameter/src/base/diameter_watchdog.erl
index 66781d7b06..009a766e43 100644
--- a/lib/diameter/src/base/diameter_watchdog.erl
+++ b/lib/diameter/src/base/diameter_watchdog.erl
@@ -124,8 +124,7 @@ i({Ack, T, Pid, {RecvData,
= Svc}}) ->
monitor(process, Pid),
wait(Ack, Pid),
- {_, Seed} = diameter_lib:seed(),
- random:seed(Seed),
+ random:seed(now()),
putr(restart, {T, Opts, Svc, SvcOpts}), %% save seeing it in trace
putr(dwr, dwr(Caps)), %%
{_,_} = Mask = proplists:get_value(sequence, SvcOpts),
@@ -453,7 +452,7 @@ transition({timeout, TRef, tw}, #watchdog{tref = TRef} = S) ->
%% Message has arrived since the timer was started: subtract time
%% already elapsed from new timer.
transition({timeout, _, tw}, #watchdog{tref = T0} = S) ->
- set_watchdog(diameter_lib:micro_diff(T0) div 1000, S);
+ set_watchdog(timer:now_diff(now(), T0) div 1000, S);
%% State query.
transition({state, Pid}, #watchdog{status = S}) ->
@@ -535,7 +534,7 @@ set_watchdog(#watchdog{tref = undefined} = S) ->
%% Timer already set: start at new one only at expiry.
set_watchdog(#watchdog{} = S) ->
- S#watchdog{tref = diameter_lib:now()};
+ S#watchdog{tref = now()};
set_watchdog(stop = No) ->
No.