gen_leader's status.

Ulf Wiger (TN/EAB) ulf.wiger@REDACTED
Wed Aug 16 07:48:51 CEST 2006


Scott Lystig Fritchie wrote:
>
> (**) I don't know exactly what 'global' does in cases of 
> network partition, but I guess that it will register the 
> global name on each side of the partition.  (?) 

First of all global will most likely remove any registration
where the pid is from the node(s) that were lost during 
the network partition. The application may detect the 
nodedown too, and register another pid with global.

When nodes reconnect, global has a default conflict 
resolution method that is pretty draconic: whenever
two pids are found to be registered with the same 
global name, global picks one pid at random and performs
exit(P, kill) on it.

When registering a name, one may select another conflict
resolution method, using 

  global:register_name(Name, Pid, Method)

The methods provided by global are
- {global, random_exit_name} which is the default
- {global, random_notify_name}
- {global, notify_all_name}

Notes:

- Global performs no check to see whether Method
  actucally succeeded, or whether it is even a 
  callable function
- Global simply does catch Method(Name, Pid1, Pid2)
  which in the default case means 
  catch {global, random_exit_name}(Name, P1, P2)
  When providing your own method, it would be 
  more stylish to use a fun, I think.

BR,
Ulf W



More information about the erlang-questions mailing list