ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/AnyEvent-MP/MP/Global.pm
(Generate patch)

Comparing AnyEvent-MP/MP/Global.pm (file contents):
Revision 1.30 by root, Fri Sep 11 21:27:09 2009 UTC vs.
Revision 1.31 by root, Sat Sep 12 04:46:21 2009 UTC

43 grp_get 43 grp_get
44 grp_mon 44 grp_mon
45); 45);
46 46
47our $VERSION = $AnyEvent::MP::VERSION; 47our $VERSION = $AnyEvent::MP::VERSION;
48
49our $GLOBAL_VERSION = 0;
48 50
49our %addr; # port ID => [address...] mapping 51our %addr; # port ID => [address...] mapping
50 52
51our %port; # our rendezvous port on the other side 53our %port; # our rendezvous port on the other side
52our %lreg; # local registry, name => [pid...] 54our %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
311sub connect { 313sub 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;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines