… | |
… | |
43 | grp_get |
43 | grp_get |
44 | grp_mon |
44 | grp_mon |
45 | ); |
45 | ); |
46 | |
46 | |
47 | our $VERSION = $AnyEvent::MP::VERSION; |
47 | our $VERSION = $AnyEvent::MP::VERSION; |
|
|
48 | |
|
|
49 | our $GLOBAL_VERSION = 0; |
48 | |
50 | |
49 | our %addr; # port ID => [address...] mapping |
51 | our %addr; # port ID => [address...] mapping |
50 | |
52 | |
51 | our %port; # our rendezvous port on the other side |
53 | our %port; # our rendezvous port on the other side |
52 | our %lreg; # local registry, name => [pid...] |
54 | our %lreg; # local registry, name => [pid...] |
… | |
… | |
293 | |
295 | |
294 | return if exists $port{$node}; |
296 | return if exists $port{$node}; |
295 | return if $node eq $NODE; # do not connect to ourselves |
297 | return if $node eq $NODE; # do not connect to ourselves |
296 | |
298 | |
297 | # establish connection |
299 | # establish connection |
298 | my $port = $port{$node} = spawn $node, "AnyEvent::MP::Global::connect", 0, $NODE; |
300 | my $port = $port{$node} = spawn $node, "AnyEvent::MP::Global::connect", $GLOBAL_VERSION, $NODE; |
299 | |
301 | |
300 | mon $port, sub { |
302 | mon $port, sub { |
301 | unreg_groups $node; |
303 | unreg_groups $node; |
302 | delete $port{$node}; |
304 | delete $port{$node}; |
303 | }; |
305 | }; |
… | |
… | |
308 | } |
310 | } |
309 | |
311 | |
310 | # other nodes connect via this |
312 | # other nodes connect via this |
311 | sub connect { |
313 | sub connect { |
312 | my ($version, $node) = @_; |
314 | my ($version, $node) = @_; |
|
|
315 | |
|
|
316 | (int $version) == (int $GLOBAL_VERSION) |
|
|
317 | or die "node version mismatch (requested $version; we have $GLOBAL_VERSION)"; |
313 | |
318 | |
314 | # monitor them, silently die |
319 | # monitor them, silently die |
315 | mon $node, psub { |
320 | mon $node, psub { |
316 | delete $SEEDME{$node}; |
321 | delete $SEEDME{$node}; |
317 | kil $SELF; |
322 | kil $SELF; |