… | |
… | |
33 | $self |
33 | $self |
34 | } |
34 | } |
35 | |
35 | |
36 | sub init { |
36 | sub init { |
37 | # |
37 | # |
|
|
38 | } |
|
|
39 | |
|
|
40 | #d# only needed for bad global code at the moment |
|
|
41 | sub transport_error { |
38 | } |
42 | } |
39 | |
43 | |
40 | sub send { |
44 | sub send { |
41 | &{ shift->{send} } |
45 | &{ shift->{send} } |
42 | } |
46 | } |
… | |
… | |
123 | $self->{connect_to} ||= AE::timer $monitor, 0, sub { |
127 | $self->{connect_to} ||= AE::timer $monitor, 0, sub { |
124 | $self->transport_error (transport_error => $self->{id}, "unable to connect"); |
128 | $self->transport_error (transport_error => $self->{id}, "unable to connect"); |
125 | }; |
129 | }; |
126 | |
130 | |
127 | # maybe @$addresses? |
131 | # maybe @$addresses? |
128 | my @addresses = @{ |
132 | my @addresses = @{ $AnyEvent::MP::Kernel::GLOBAL_DB{"'l"}{$self->{id}} }; |
129 | $AnyEvent::MP::Kernel::GLOBAL_ADDR->{$self->{id}} |
|
|
130 | || $AnyEvent::MP::Kernel::NODE_ADDR->{$self->{id}} |
|
|
131 | }; |
|
|
132 | |
133 | |
133 | unless (@addresses) { |
134 | unless (@addresses) { |
134 | # on global nodes, all bets are 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 |
135 | unless ($AnyEvent::MP::Kernel::GLOBAL) { |
136 | unless ($AnyEvent::MP::Kernel::GLOBAL) { |
136 | $self->{connect_w} = AnyEvent::MP::Kernel::global_req ( |
137 | $self->{connect_w} = AnyEvent::MP::Kernel::global_req (g_find => $self->{id}); |
137 | g_find => $self->{id}, |
|
|
138 | sub { |
|
|
139 | return unless $self; # just to be sure |
|
|
140 | return unless @{ $_[0] }; |
|
|
141 | |
|
|
142 | local $AnyEvent::MP::Kernel::GLOBAL_ADDR->{$self->{id}} = $_[0]; #d# UGLY |
|
|
143 | delete $self->{connect_w}; |
|
|
144 | $self->connect; |
|
|
145 | } |
|
|
146 | ); |
|
|
147 | } |
138 | } |
148 | |
|
|
149 | return; |
139 | return; |
150 | } |
140 | } |
151 | |
141 | |
152 | $self->{connect_addr} = \@addresses; # a bit weird, but efficient |
142 | $self->{connect_addr} = \@addresses; # a bit weird, but efficient |
153 | |
143 | |