Skip to content

Commit

Permalink
Merge pull request uwiger#89 from uwiger/uw-delete-global-props
Browse files Browse the repository at this point in the history
replication of prop deletes buggy
  • Loading branch information
uwiger committed Apr 20, 2015
2 parents 7655bdd + c14ceec commit 68c9e5d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 1 addition & 3 deletions src/gproc_dist.erl
Original file line number Diff line number Diff line change
Expand Up @@ -794,10 +794,8 @@ insert_globals(Globals) ->

delete_globals(Globals) ->
lists:foreach(
fun({{_,g,_},T} = K) when is_atom(T) ->
fun({{_,g,_},T} = K) when is_atom(T); is_pid(T) ->
ets:delete(?TAB, K);
({Key, Pid}) when is_pid(Pid); Pid==shared ->
ets:delete(?TAB, {Pid, Key});
({Pid, Key}) when is_pid(Pid); Pid==shared ->
ets:delete(?TAB, {Pid, Key})
end, Globals).
Expand Down
13 changes: 13 additions & 0 deletions test/gproc_dist_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ dist_test_() ->
fun() ->
?debugVal(t_shared_counter(Ns))
end,
fun() ->
?debugVal(t_prop(Ns))
end,
fun() ->
?debugVal(t_mreg(Ns))
end,
Expand Down Expand Up @@ -124,6 +127,7 @@ run_dist_tests() ->
-define(T_NAME, {n, g, {?MODULE, ?LINE, erlang:now()}}).
-define(T_KVL, [{foo, "foo"}, {bar, "bar"}]).
-define(T_COUNTER, {c, g, {?MODULE, ?LINE}}).
-define(T_PROP, {p, g, ?MODULE}).

t_simple_reg([H|_] = Ns) ->
Name = ?T_NAME,
Expand Down Expand Up @@ -222,6 +226,15 @@ t_update_counters([H1,H2|_] = Ns) ->
?assertMatch(ok, t_call(P12, die)),
?assertMatch(ok, t_call(P2, die)).

t_prop([H1,H2|_] = Ns) ->
{p, g, _} = P = ?T_PROP,
P1 = t_spawn_reg(H1, P, 1),
P2 = t_spawn_reg(H2, P, 2),
?assertMatch(ok, t_read_everywhere(P, P1, Ns, 1)),
?assertMatch(ok, t_read_everywhere(P, P2, Ns, 2)),
?assertMatch(ok, t_call(P1, die)),
?assertMatch(ok, t_read_everywhere(P, P1, Ns, badarg)),
?assertMatch(ok, t_call(P2, die)).

t_mreg([H|_] = Ns) ->
Kvl = ?T_KVL,
Expand Down

0 comments on commit 68c9e5d

Please sign in to comment.