aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorPéter Gömöri <[email protected]>2018-02-07 09:20:11 +0100
committerJohn Högberg <[email protected]>2018-02-13 09:45:58 +0100
commitdfa4d62c263cd3f11338aba891179b08704d9287 (patch)
treead4e30de5cc0b2372f39235cd47ccbf5be36cbcd /lib
parent6328a1345783d13684407fc6dcbe9ea473c12cdd (diff)
downloadotp-dfa4d62c263cd3f11338aba891179b08704d9287.tar.gz
otp-dfa4d62c263cd3f11338aba891179b08704d9287.tar.bz2
otp-dfa4d62c263cd3f11338aba891179b08704d9287.zip
Don't crash lcnt server if information/0 is called before collect/0
Diffstat (limited to 'lib')
-rw-r--r--lib/tools/src/lcnt.erl2
-rw-r--r--lib/tools/test/lcnt_SUITE.erl7
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/tools/src/lcnt.erl b/lib/tools/src/lcnt.erl
index 139b3d8a4a..e306979dea 100644
--- a/lib/tools/src/lcnt.erl
+++ b/lib/tools/src/lcnt.erl
@@ -943,7 +943,7 @@ print_state_information(#state{locks = Locks} = State) ->
print(kv("#tries", s(Stats#stats.tries))),
print(kv("#colls", s(Stats#stats.colls))),
print(kv("wait time", s(Stats#stats.time) ++ " us" ++ " ( " ++ s(Stats#stats.time/1000000) ++ " s)")),
- print(kv("percent of duration", s(Stats#stats.time/State#state.duration*100) ++ " %")),
+ print(kv("percent of duration", s(percent(Stats#stats.time, State#state.duration)) ++ " %")),
ok.
diff --git a/lib/tools/test/lcnt_SUITE.erl b/lib/tools/test/lcnt_SUITE.erl
index 146c915087..f0c36dedd9 100644
--- a/lib/tools/test/lcnt_SUITE.erl
+++ b/lib/tools/test/lcnt_SUITE.erl
@@ -30,6 +30,7 @@
t_conflicts/1,
t_locations/1,
t_swap_keys/1,
+ t_crash_before_collect/1,
smoke_lcnt/1]).
init_per_testcase(_Case, Config) ->
@@ -44,7 +45,7 @@ suite() ->
{timetrap,{minutes,4}}].
all() ->
- [t_load, t_conflicts, t_locations, t_swap_keys,
+ [t_load, t_conflicts, t_locations, t_swap_keys, t_crash_before_collect,
smoke_lcnt].
%%----------------------------------------------------------------------
@@ -149,6 +150,10 @@ t_swap_keys_file([File|Files]) ->
ok = lcnt:stop(),
t_swap_keys_file(Files).
+t_crash_before_collect(Config) when is_list(Config) ->
+ {ok, _} = lcnt:start(),
+ ok = lcnt:information().
+
%% Simple smoke test of actual lock-counting, if running on
%% a run-time with lock-counting enabled.
smoke_lcnt(Config) ->