Permalink
Browse files

do not remember multiple monitors for the same node

  • Loading branch information...
1 parent db49b7a commit ab7a7c65f214796a9a1c2e93918b6fd9baecf65a @garret-smith committed Jan 28, 2011
Showing with 16 additions and 4 deletions.
  1. +16 −4 src/gen_leader.erl
View
@@ -1403,11 +1403,23 @@ mon_nodes(E,Nodes,Server) ->
mon_node(El, Pid, Server)
end,E1,Nodes -- [node()]).
-%% Star monitoring one Process
-mon_node(E,Proc,Server) ->
- {Ref,Node} = do_monitor(Proc, Server),
- E#election{monitored = [{Ref,Node} | E#election.monitored]}.
+%% Start monitoring one Process
+mon_node(E,{_RegName, NodeName} = Proc,Server) ->
+ case lists:keymember(NodeName, 2, E#election.monitored) of
+ true -> E;
+ false ->
+ {Ref,Node} = do_monitor(Proc, Server),
+ E#election{monitored = [{Ref,Node} | E#election.monitored]}
+ end;
+mon_node(E,Proc,Server) when is_pid(Proc) ->
+ case lists:keymember(node(Proc), 2, E#election.monitored) of
+ true -> E;
+ false ->
+ {Ref,Node} = do_monitor(Proc, Server),
+ E#election{monitored = [{Ref,Node} | E#election.monitored]}
+ end
+ .
spawn_monitor_proc() ->
Parent = self(),

0 comments on commit ab7a7c6

Please sign in to comment.