Browse Source

wrote wrong key format

Ulf Wiger 11 years ago
parent
commit
19fd076758
2 changed files with 23 additions and 2 deletions
  1. 2 2
      src/gproc.erl
  2. 21 0
      test/gproc_tests.erl

+ 2 - 2
src/gproc.erl

@@ -2362,8 +2362,8 @@ opt_notify(Opts, {T,_,_} = Key, Pid, Value) ->
                     gproc_lib:notify(unreg, Key, Opts),
                     ok;
                 {ToPid, Ref} ->
-                    ets:insert(?TAB, [{Key, ToPid, Value},
-                                      {{ToPid, {Key,T}},
+                    ets:insert(?TAB, [{{Key,T}, ToPid, Value},
+                                      {{ToPid, Key},
                                        gproc_lib:remove_monitor(
                                          Opts, ToPid, Ref)}]),
                     _ = gproc_lib:remove_reverse_mapping(

+ 21 - 0
test/gproc_tests.erl

@@ -130,6 +130,8 @@ reg_test_() ->
       , ?_test(t_is_clean())
       , {spawn, ?_test(?debugVal(t_monitor_give_away()))}
       , ?_test(t_is_clean())
+      , {spawn, ?_test(?debugVal(t_monitor_standby()))}
+      , ?_test(t_is_clean())
       , {spawn, ?_test(?debugVal(t_subscribe()))}
       , ?_test(t_is_clean())
       , {spawn, ?_test(?debugVal(t_gproc_info()))}
@@ -728,6 +730,25 @@ t_monitor_give_away() ->
     end,
     ?assertEqual(ok, t_call(P, die)).
 
+t_monitor_standby() ->
+    Me = self(),
+    P = spawn(fun() ->
+                      gproc:reg({n,l,a}),
+                      Me ! continue,
+                      t_loop()
+              end),
+    receive continue ->
+	    ok
+    end,
+    Ref = gproc:monitor({n,l,a}, standby),
+    exit(P, kill),
+    receive
+	M ->
+	    ?assertEqual({gproc,{failover,Me},Ref,{n,l,a}}, M)
+    end,
+    gproc:unreg({n,l,a}),
+    ok.
+
 t_subscribe() ->
     Key = {n,l,a},
     ?assertEqual(ok, gproc_monitor:subscribe(Key)),