Skip to content

Commit

Permalink
Don't crash lcnt server if information/0 is called before collect/0
Browse files Browse the repository at this point in the history
  • Loading branch information
gomoripeti authored and jhogberg committed Feb 13, 2018
1 parent 6328a13 commit dfa4d62
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/tools/src/lcnt.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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.


Expand Down
7 changes: 6 additions & 1 deletion lib/tools/test/lcnt_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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) ->
Expand All @@ -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].

%%----------------------------------------------------------------------
Expand Down Expand Up @@ -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) ->
Expand Down

0 comments on commit dfa4d62

Please sign in to comment.