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

Comparing AnyEvent-MP/MP/Node.pm (file contents):
Revision 1.53 by root, Tue Feb 28 18:37:24 2012 UTC vs.
Revision 1.56 by root, Thu Mar 1 18:11:56 2012 UTC

33 $self 33 $self
34} 34}
35 35
36sub init { 36sub init {
37 # 37 #
38}
39
40#d# only needed for bad global code at the moment
41sub transport_error {
38} 42}
39 43
40sub send { 44sub send {
41 &{ shift->{send} } 45 &{ shift->{send} }
42} 46}
112 116
113sub connect { 117sub connect {
114 my ($self) = @_; 118 my ($self) = @_;
115 119
116 return if $self->{transport}; 120 return if $self->{transport};
121 return if $self->{connect_w};
117 122
118 Scalar::Util::weaken $self; 123 Scalar::Util::weaken $self;
119 124
120 my $monitor = $AnyEvent::MP::Kernel::CONFIG->{monitor_timeout}; 125 my $monitor = $AnyEvent::MP::Kernel::CONFIG->{monitor_timeout};
121 126
122 $self->{connect_to} ||= AE::timer $monitor, 0, sub { 127 $self->{connect_to} ||= AE::timer $monitor, 0, sub {
123 $self->transport_error (transport_error => $self->{id}, "unable to connect"); 128 $self->transport_error (transport_error => $self->{id}, "unable to connect");
124 }; 129 };
125 130
126 # maybe @$addresses? 131 # maybe @$addresses?
127 my @addresses = @{ 132 my @addresses = @{ $AnyEvent::MP::Kernel::GLOBAL_DB{"'l"}{$self->{id}} };
128 $AnyEvent::MP::Kernel::GLOBAL_ADDR->{$self->{id}}
129 || $AnyEvent::MP::Kernel::NODE_ADDR->{$self->{id}}
130 };
131 133
132 unless (@addresses) { 134 unless (@addresses) {
133 # on global nodes, all betsa re off now - we either know the node, or we don't 135 # on global nodes, all bets are off now - we either know the node, or we don't
134 unless ($AnyEvent::MP::Kernel::GLOBAL) { 136 unless ($AnyEvent::MP::Kernel::GLOBAL) {
135 $self->{connect_w} = AnyEvent::MP::Kernel::global_req ( 137 $self->{connect_w} = AnyEvent::MP::Kernel::global_req (g_find => $self->{id});
136 global_find => $self->{id},
137 sub {
138 return unless $self; # just to be sure
139 return unless @{ $_[0] };
140
141 local $AnyEvent::MP::Kernel::GLOBAL_ADDR->{$self->{id}} = $_[0]; #d# UGLY
142 $self->connect;
143 }
144 );
145 } 138 }
146
147 return; 139 return;
148 } 140 }
149 141
150 $self->{connect_addr} = \@addresses; # a bit weird, but efficient 142 $self->{connect_addr} = \@addresses; # a bit weird, but efficient
151 143
158 150
159 $interval = 0.4 if $interval < 0.4; 151 $interval = 0.4 if $interval < 0.4;
160 152
161 my @endpoints; 153 my @endpoints;
162 154
163 $self->{connect_w} = AE::timer 0.050 * rand, $interval * (0.9 + 0.1 * rand), sub { 155 $self->{connect_w} = AE::timer 0, $interval * (0.9 + 0.1 * rand), sub {
164 @endpoints = @addresses 156 @endpoints = @addresses
165 unless @endpoints; 157 unless @endpoints;
166 158
167 my $endpoint = shift @endpoints; 159 my $endpoint = shift @endpoints;
168 160

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines