… | |
… | |
120 | unless ($self->{connect_w}) { |
120 | unless ($self->{connect_w}) { |
121 | my @endpoints; |
121 | my @endpoints; |
122 | my %trial; |
122 | my %trial; |
123 | |
123 | |
124 | $self->{connect_w} = AE::timer |
124 | $self->{connect_w} = AE::timer |
125 | 0, |
125 | rand, |
126 | $AnyEvent::MP::Config::CFG{connect_interval} || $AnyEvent::MP::Kernel::CONNECT_INTERVAL, |
126 | $AnyEvent::MP::Config::CFG{connect_interval} || $AnyEvent::MP::Kernel::CONNECT_INTERVAL, |
127 | sub { |
127 | sub { |
128 | @endpoints = split /,/, $self->{noderef} |
128 | @endpoints = split /,/, $self->{noderef} |
129 | unless @endpoints; |
129 | unless @endpoints; |
130 | |
130 | |
131 | my $endpoint = shift @endpoints; |
131 | my $endpoint = shift @endpoints; |
132 | |
132 | |
133 | $trial{$endpoint} ||= do { |
133 | $trial{$endpoint} ||= do { |
134 | my ($host, $port) = AnyEvent::Socket::parse_hostport $endpoint |
134 | my ($host, $port) = AnyEvent::Socket::parse_hostport $endpoint |
135 | or return $AnyEvent::MP::Kernel::WARN->("$self->{noderef}: not a resolved node reference."); |
135 | or return $AnyEvent::MP::Kernel::WARN->(1, "$self->{noderef}: not a resolved node reference."); |
136 | |
136 | |
137 | AnyEvent::MP::Transport::mp_connect |
137 | AnyEvent::MP::Transport::mp_connect |
138 | $host, $port, |
138 | $host, $port, |
139 | sub { delete $trial{$endpoint} } |
139 | sub { delete $trial{$endpoint} } |
140 | ; |
140 | ; |
… | |
… | |
154 | my ($self, $portid, $cb) = @_; |
154 | my ($self, $portid, $cb) = @_; |
155 | |
155 | |
156 | my $list = $self->{lmon}{$portid} ||= []; |
156 | my $list = $self->{lmon}{$portid} ||= []; |
157 | |
157 | |
158 | $self->send (["", mon1 => $portid]) |
158 | $self->send (["", mon1 => $portid]) |
159 | unless @$list; |
159 | unless @$list || !length $portid; |
160 | |
160 | |
161 | push @$list, $cb; |
161 | push @$list, $cb; |
162 | } |
162 | } |
163 | |
163 | |
164 | sub unmonitor { |
164 | sub unmonitor { |
… | |
… | |
206 | |
206 | |
207 | # slave nodes are so cool - we can always send to them :) |
207 | # slave nodes are so cool - we can always send to them :) |
208 | |
208 | |
209 | $self->{send} = sub { |
209 | $self->{send} = sub { |
210 | $self->connect; |
210 | $self->connect; |
211 | snd $master, relay => $noderef, @_; |
211 | snd $master, snd => $noderef, @_; |
212 | }; |
212 | }; |
213 | } |
213 | } |
214 | } |
214 | } |
215 | |
215 | |
216 | sub connect { |
216 | sub connect { |
… | |
… | |
246 | delete $AnyEvent::MP::Kernel::PORT{$port}; |
246 | delete $AnyEvent::MP::Kernel::PORT{$port}; |
247 | delete $AnyEvent::MP::Kernel::PORT_DATA{$port}; |
247 | delete $AnyEvent::MP::Kernel::PORT_DATA{$port}; |
248 | |
248 | |
249 | my $mon = delete $AnyEvent::MP::Kernel::LMON{$port} |
249 | my $mon = delete $AnyEvent::MP::Kernel::LMON{$port} |
250 | or !@reason |
250 | or !@reason |
251 | or $AnyEvent::MP::Kernel::WARN->("unmonitored local port $port died with reason: @reason"); |
251 | or $AnyEvent::MP::Kernel::WARN->(2, "unmonitored local port $port died with reason: @reason"); |
252 | |
252 | |
253 | $_->(@reason) for values %$mon; |
253 | $_->(@reason) for values %$mon; |
254 | } |
254 | } |
255 | |
255 | |
256 | sub monitor { |
256 | sub monitor { |