… | |
… | |
92 | delete $self->{trial}; |
92 | delete $self->{trial}; |
93 | |
93 | |
94 | $self->transport_error (transport_error => "switched connections") |
94 | $self->transport_error (transport_error => "switched connections") |
95 | if $self->{transport}; |
95 | if $self->{transport}; |
96 | |
96 | |
|
|
97 | delete $self->{connect_addr}; |
97 | delete $self->{connect_w}; |
98 | delete $self->{connect_w}; |
98 | delete $self->{connect_to}; |
99 | delete $self->{connect_to}; |
99 | |
100 | |
100 | $self->{transport} = $transport; |
101 | $self->{transport} = $transport; |
101 | |
102 | |
… | |
… | |
123 | $self->{connect_to} ||= AE::timer $monitor, 0, sub { |
124 | $self->{connect_to} ||= AE::timer $monitor, 0, sub { |
124 | $self->transport_error (transport_error => $self->{id}, "unable to connect"); |
125 | $self->transport_error (transport_error => $self->{id}, "unable to connect"); |
125 | }; |
126 | }; |
126 | |
127 | |
127 | return unless @addresses; |
128 | return unless @addresses; |
|
|
129 | |
128 | return if $self->{connect_w}; |
130 | if ($self->{connect_w}) { |
|
|
131 | # sometimes we get told about new addresses after we started to connect |
|
|
132 | unshift @{$self->{connect_addr}}, @addresses; |
|
|
133 | return; |
|
|
134 | } |
|
|
135 | |
|
|
136 | $self->{connect_addr} = \@addresses; # a bit weird, but efficient |
129 | |
137 | |
130 | $AnyEvent::MP::Kernel::WARN->(9, "connecting to $self->{id} with [@addresses]"); |
138 | $AnyEvent::MP::Kernel::WARN->(9, "connecting to $self->{id} with [@addresses]"); |
131 | |
139 | |
132 | my $interval = $AnyEvent::MP::Kernel::CONFIG->{connect_interval}; |
140 | my $interval = $AnyEvent::MP::Kernel::CONFIG->{connect_interval}; |
133 | |
141 | |
… | |
… | |
222 | $self->{send} = sub { |
230 | $self->{send} = sub { |
223 | if ($DELAY++ >= 0) { |
231 | if ($DELAY++ >= 0) { |
224 | my $msg = $_[0]; |
232 | my $msg = $_[0]; |
225 | push @DELAY, sub { AnyEvent::MP::Kernel::_inject (@$msg) }; |
233 | push @DELAY, sub { AnyEvent::MP::Kernel::_inject (@$msg) }; |
226 | $DELAY_W ||= AE::timer 0, 0, \&_send_delayed; |
234 | $DELAY_W ||= AE::timer 0, 0, \&_send_delayed; |
227 | } else { |
235 | return; |
228 | local $AnyEvent::MP::Kernel::SRCNODE = $self; |
|
|
229 | AnyEvent::MP::Kernel::_inject (@{ $_[0] }); |
|
|
230 | } |
236 | } |
|
|
237 | |
|
|
238 | local $AnyEvent::MP::Kernel::SRCNODE = $self; |
|
|
239 | AnyEvent::MP::Kernel::_inject (@{ $_[0] }); |
231 | }; |
240 | }; |
232 | } |
241 | } |
233 | |
242 | |
234 | sub transport_connect { |
243 | sub transport_connect { |
235 | my ($self, $tp) = @_; |
244 | my ($self, $tp) = @_; |