1
%% This tests the presence of possible races due to an ets:lookup/ets:insert
2
%% combination. It takes into account control flow that might exist.
4
-module(ets_insert_control_flow3).
8
Table = ets:new(table, [public]),
12
root -> ets:lookup(Table, root);
13
user -> ets:lookup(Table, user);
14
Other -> [{undefined, -1}]
17
-1 -> io:format("\nUnknown User\n", []);
21
ets:insert(Table, {User, Pass = generate_password(N) ++ generate_password(N+1)});
23
ets:insert(Table, {User, Pass = generate_password(N)})
25
io:format("\nYour new pass is ~w\n", [Pass]);
27
io:format("\nYour pass is ~w\n", [P])
30
generate_password(N) ->
31
lists:map(fun (_) -> random:uniform(90)+$\s+1 end, lists:seq(1,N)).