AMQP/TCP.pm

filter: Statementstmt 16.1% 29 / 180 Branchbran 0.0% 0 / 112 Conditioncond 0.0% 0 / 18 MC/DCmcdc 0.0% 0 / 11 Subroutinesub 28.1% 9 / 32 Podpod 0.0% 0 / 2 totaltotal 10.7% 38 / 355 CC 65 SCAR 59.8
CC
65
Cov
9%
new
1122.0
__ANON__
56.0
__ANON__
30.0
CRAP 396.9
↑ Summary AMQP/Channel.pm »
1 package POE::Component::Client::AMQP::TCP;
2  
3 =head1 NAME
4  
5 POE::Component::Client::AMQP::TCP - A modified copy of L<POE::Component::Client::TCP> to support SSL
6  
7 =head1 SEE ALSO
8  
9 L<POE::Component::Client::AMQP>
10  
11 =head1 AUTHORS & COPYRIGHTS
12  
13 POE::Component::Client::TCP is Copyright 2001-2009 by Rocco Caputo.
14 All rights are reserved. POE::Component::Client::TCP is free
15 software, and it may be redistributed and/or modified under the same
16 terms as Perl itself.
17  
18 POE::Component::Client::TCP is based on code, used with permission,
19 from Ann Barcomb E<lt>kudra@domaintje.comE<gt>.
20  
21 POE::Component::Client::TCP is based on code, used with permission,
22 from Jos Boumans E<lt>kane@cpan.orgE<gt>.
23  
24 =cut
25  
26 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
27  
28 1 ▶use vars qw($VERSION);
Subroutine BEGIN: called CC=1 SCAR=0.0
29 1 $VERSION = 0.03;
30  
31 1 ▶use Carp qw(carp croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
32 1 ▶use Errno qw(ETIMEDOUT ECONNRESET EAGAIN);
Subroutine BEGIN: called CC=1 SCAR=0.0
33  
34 # Explicit use to import the parameter constants;
35 1 ▶use POE::Session;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 1 ▶use POE::Driver::SysRW;
Subroutine BEGIN: called CC=1 SCAR=0.0
37 1 ▶use POE::Filter::Line;
Subroutine BEGIN: called CC=1 SCAR=0.0
38 1 ▶use POE::Wheel::ReadWrite;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 1 ▶use POE::Wheel::SocketFactory;
Subroutine BEGIN: called CC=1 SCAR=0.0
40  
41 # Create the client. This is just a handy way to encapsulate
42 # POE::Session->create(). Because the states are so small, it uses
43 # real inline coderefs.
44  
45 0 ▶sub new {
Subroutine new: not called CC=33 SCAR=70.2
Pod undocumented
46 0 my $type = shift;
47  
48 # Helper so we don't have to type it all day. $mi is a name I call
49 # myself.
50 0 my $mi = $type . '->new()';
51  
52 # If they give us lemons, tell them to make their own damn
53 # lemonade.
54 0 ▶ croak "$mi requires an even number of parameters" if (@_ & 1);
Branch: 1 branch
BranchTrueFalseTotal
if @_ & 1 0 0 0
55 0 my %param = @_;
56  
57 # Validate what we're given.
58 croak "$mi needs a RemoteAddress parameter"
59 0 ▶ unless exists $param{RemoteAddress};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $param{"RemoteAddress"} 0 0 0
60 croak "$mi needs a RemotePort parameter"
61 0 ▶ unless exists $param{RemotePort};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $param{"RemotePort"} 0 0 0
62  
63 # Extract parameters.
64 0 my $alias = delete $param{Alias};
65 0 my $address = delete $param{RemoteAddress};
66 0 my $port = delete $param{RemotePort};
67 0 my $domain = delete $param{Domain};
68 0 my $bind_address = delete $param{BindAddress};
69 0 my $bind_port = delete $param{BindPort};
70 0 my $ctimeout = delete $param{ConnectTimeout};
71 0 my $args = delete $param{Args};
72 0 my $session_type = delete $param{SessionType};
73 0 my $session_params = delete $param{SessionParams};
74 0 my $ssl = delete $param{SSL};
75  
76 0 ▶ if ($ssl) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ssl) 0 0 0
77 0 require IO::Socket::SSL;
78 }
79  
80 0 ▶ $args = [] unless defined $args;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $args 0 0 0
81 0 ▶ croak "Args must be an array reference" unless ref($args) eq "ARRAY";
Branch: 1 branch
BranchTrueFalseTotal
unless ref $args eq "ARRAY" 0 0 0
82  
83 0 foreach (
84 qw( Connected ConnectError Disconnected ServerInput
85 ServerError ServerFlushed Started
86 ServerHigh ServerLow
87 )
88 ) {
89 croak "$_ must be a coderef" if(
90 0 ▶ defined($param{$_}) and ref($param{$_}) ne 'CODE'
Branch: 1 branch
BranchTrueFalseTotal
if defined $param{$_} and ref $param{$_} ne "CODE" 0 0 0
Condition0%0/3
defined $param{$_} and ref $param{$_} ne "CODE"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $param{$_} and ref $param{$_} ne "CODE"
defined $param{$_} ref $param{$_} ne "CODE"
Truth table0%0/3
A and B
A= defined $param{$_}B= ref $param{$_} ne "CODE"
ABresult
0X0
100
111
91 );
92 }
93  
94 0 my $high_mark_level = delete $param{HighMark};
95 0 my $low_mark_level = delete $param{LowMark};
96 0 my $high_event = delete $param{ServerHigh};
97 0 my $low_event = delete $param{ServerLow};
98  
99 # this is ugly, but now its elegant :) grep++
100 0 my $using_watermarks = grep { defined $_ }
101 ($high_mark_level, $low_mark_level, $high_event, $low_event);
102 0 ▶ if ($using_watermarks > 0 and $using_watermarks != 4) {
Branch: 1 branch
BranchTrueFalseTotal
if ($using_watermarks > 0 and $using_watermarks != 4) 0 0 0
Condition0%0/3
$using_watermarks > 0 and $using_watermarks != 4
!ll&&!rl&&r
000
MC/DC0%0/2
$using_watermarks > 0 and $using_watermarks != 4
$using_watermarks > 0 $using_watermarks != 4
Truth table0%0/3
A and B
A= $using_watermarks > 0B= $using_watermarks != 4
ABresult
0X0
100
111
103 0 croak "If you use the Mark settings, you must define all four";
104 }
105  
106 0 ▶ $high_event = sub { } unless defined $high_event;
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
unless defined $high_event 0 0 0
107 0 ▶ $low_event = sub { } unless defined $low_event;
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
unless defined $low_event 0 0 0
108  
109 0 my $conn_callback = delete $param{Connected};
110 0 my $conn_error_callback = delete $param{ConnectError};
111 0 my $disc_callback = delete $param{Disconnected};
112 0 my $input_callback = delete $param{ServerInput};
113 0 my $error_callback = delete $param{ServerError};
114 0 my $flush_callback = delete $param{ServerFlushed};
115 0 my $start_callback = delete $param{Started};
116 0 my $filter = delete $param{Filter};
117  
118 # Extra states.
119  
120 0 my $inline_states = delete $param{InlineStates};
121 0 ▶ $inline_states = {} unless defined $inline_states;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $inline_states 0 0 0
122  
123 0 my $package_states = delete $param{PackageStates};
124 0 ▶ $package_states = [] unless defined $package_states;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $package_states 0 0 0
125  
126 0 my $object_states = delete $param{ObjectStates};
127 0 ▶ $object_states = [] unless defined $object_states;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $object_states 0 0 0
128  
129 0 ▶ croak "InlineStates must be a hash reference"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $inline_states eq "HASH" 0 0 0
130 unless ref($inline_states) eq 'HASH';
131  
132 0 ▶ croak "PackageStates must be a list or array reference"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $package_states eq "ARRAY" 0 0 0
133 unless ref($package_states) eq 'ARRAY';
134  
135 0 ▶ croak "ObjectStates must be a list or array reference"
Branch: 1 branch
BranchTrueFalseTotal
unless ref $object_states eq "ARRAY" 0 0 0
136 unless ref($object_states) eq 'ARRAY';
137  
138 # Errors.
139  
140 0 ▶ croak "$mi requires a ServerInput parameter" unless defined $input_callback;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $input_callback 0 0 0
141  
142 0 foreach (sort keys %param) {
143 0 carp "$mi doesn't recognize \"$_\" as a parameter";
144 }
145  
146 # Defaults.
147  
148 0 ▶ $session_type = 'POE::Session' unless defined $session_type;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $session_type 0 0 0
149 0 ▶ if (defined($session_params) && ref($session_params)) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $session_params and ref $session_params) { } 0 0 0
Condition0%0/3
defined $session_params and ref $session_params
!ll&&!rl&&r
000
MC/DC0%0/2
defined $session_params and ref $session_params
defined $session_params ref $session_params
Truth table0%0/3
A and B
A= defined $session_paramsB= ref $session_params
ABresult
0X0
100
111
150 0 ▶ if (ref($session_params) ne 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $session_params ne "ARRAY") 0 0 0
151 0 croak "SessionParams must be an array reference";
152 }
153 } else {
154 0 $session_params = [ ];
155 }
156  
157 0 ▶ $address = '127.0.0.1' unless defined $address;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $address 0 0 0
158  
159 0 ▶ $conn_error_callback = \&_default_error unless defined $conn_error_callback;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $conn_error_callback 0 0 0
160 0 ▶ $error_callback = \&_default_io_error unless defined $error_callback;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $error_callback 0 0 0
161  
162 0 ▶ $disc_callback = sub {} unless defined $disc_callback;
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
unless defined $disc_callback 0 0 0
163 0 ▶ $conn_callback = sub {} unless defined $conn_callback;
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
unless defined $conn_callback 0 0 0
164 0 ▶ $flush_callback = sub {} unless defined $flush_callback;
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
unless defined $flush_callback 0 0 0
165 0 ▶ $start_callback = sub {} unless defined $start_callback;
Subroutine __ANON__: not called CC=1 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
unless defined $start_callback 0 0 0
166  
167 # Spawn the session that makes the connection and then interacts
168 # with what was connected to.
169  
170 return $session_type->create
171 ( @$session_params,
172 inline_states =>
173 0 ▶ { _start => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
174 0 my ($kernel, $heap) = @_[KERNEL, HEAP];
175 0 $heap->{shutdown_on_error} = 1;
176 0 ▶ $kernel->alias_set( $alias ) if defined $alias;
Branch: 1 branch
BranchTrueFalseTotal
if defined $alias 0 0 0
177 0 $kernel->yield( 'reconnect' );
178 0 $start_callback->(@_);
179 },
180  
181 # To quiet ASSERT_STATES.
182 0 ▶ _stop => sub { },
Subroutine __ANON__: not called CC=1 SCAR=0.0
183 0 ▶ _child => sub { },
Subroutine __ANON__: not called CC=1 SCAR=0.0
184  
185 0 ▶ reconnect => sub {
Subroutine __ANON__: not called CC=4 SCAR=30.0
186 0 my ($kernel, $heap) = @_[KERNEL, HEAP];
187  
188 0 $heap->{shutdown} = 0;
189 0 $heap->{connected} = 0;
190  
191 # Tentative patch to re-establish the alias upon reconnect.
192 # Necessary because otherwise the alias goes away for good.
193 # Unfortunately, there is a gap where the alias may not be
194 # set, and any events dispatched then will be dropped.
195 0 ▶ $kernel->alias_set( $alias ) if defined $alias;
Branch: 1 branch
BranchTrueFalseTotal
if defined $alias 0 0 0
196  
197 0 $heap->{server} = POE::Wheel::SocketFactory->new
198 ( RemoteAddress => $address,
199 RemotePort => $port,
200 SocketDomain => $domain,
201 BindAddress => $bind_address,
202 BindPort => $bind_port,
203 SuccessEvent => 'got_connect_success',
204 FailureEvent => 'got_connect_error',
205 );
206 $_[KERNEL]->alarm_remove( delete $heap->{ctimeout_id} )
207 0 ▶ if exists $heap->{ctimeout_id};
Branch: 1 branch
BranchTrueFalseTotal
if exists $heap->{"ctimeout_id"} 0 0 0
208 0 ▶ $heap->{ctimeout_id} = $_[KERNEL]->alarm_set
Branch: 1 branch
BranchTrueFalseTotal
if defined $ctimeout 0 0 0
209 ( got_connect_timeout => time + $ctimeout
210 ) if defined $ctimeout;
211 },
212  
213 0 ▶ connect => sub {
Subroutine __ANON__: not called CC=3 SCAR=24.8
214 0 my ($new_address, $new_port) = @_[ARG0, ARG1];
215 0 ▶ $address = $new_address if defined $new_address;
Branch: 1 branch
BranchTrueFalseTotal
if defined $new_address 0 0 0
216 0 ▶ $port = $new_port if defined $new_port;
Branch: 1 branch
BranchTrueFalseTotal
if defined $new_port 0 0 0
217 0 $_[KERNEL]->yield("reconnect");
218 },
219  
220 0 ▶ got_connect_success => sub {
Subroutine __ANON__: not called CC=5 SCAR=34.0
221 0 my ($kernel, $heap, $socket) = @_[KERNEL, HEAP, ARG0];
222  
223 0 ▶ if ($ssl) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ssl) 0 0 0
224 0 ▶ return unless sslify_socket(@_);
Branch: 1 branch
BranchTrueFalseTotal
unless sslify_socket(@_) 0 0 0
225 }
226  
227 $kernel->alarm_remove( delete $heap->{ctimeout_id} )
228 0 ▶ if exists $heap->{ctimeout_id};
Branch: 1 branch
BranchTrueFalseTotal
if exists $heap->{"ctimeout_id"} 0 0 0
229  
230 # Ok to overwrite like this as of 0.13.
231 $_[HEAP]->{server} = POE::Wheel::ReadWrite->new
232 ( Handle => $socket,
233 Driver => POE::Driver::SysRW->new(),
234 Filter => _get_filter($filter),
235 InputEvent => 'got_server_input',
236 ErrorEvent => 'got_server_error',
237 FlushedEvent => 'got_server_flush',
238 0 do {
239 0 ▶ $using_watermarks ? return (
Branch: 1 branch
BranchTrueFalseTotal
$using_watermarks ? : 0 0 0
240 HighMark => $high_mark_level,
241 HighEvent => 'got_high',
242 LowMark => $low_mark_level,
243 LowEvent => 'got_low',
244 ) : ();
245 },
246 );
247  
248 0 $heap->{connected} = 1;
249 0 $conn_callback->(@_);
250 },
251 got_high => $high_event,
252 got_low => $low_event,
253  
254 0 ▶ got_connect_error => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
255 0 my $heap = $_[HEAP];
256 $_[KERNEL]->alarm_remove( delete $heap->{ctimeout_id} )
257 0 ▶ if exists $heap->{ctimeout_id};
Branch: 1 branch
BranchTrueFalseTotal
if exists $heap->{"ctimeout_id"} 0 0 0
258 0 $heap->{connected} = 0;
259 0 $conn_error_callback->(@_);
260 0 delete $heap->{server};
261 },
262  
263 0 ▶ got_connect_timeout => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
264 0 my $heap = $_[HEAP];
265 0 $heap->{connected} = 0;
266 $_[KERNEL]->alarm_remove( delete $heap->{ctimeout_id} )
267 0 ▶ if exists $heap->{ctimeout_id};
Branch: 1 branch
BranchTrueFalseTotal
if exists $heap->{"ctimeout_id"} 0 0 0
268 0 $! = ETIMEDOUT;
269 0 @_[ARG0,ARG1,ARG2] = ('connect', $!+0, $!);
270 0 $conn_error_callback->(@_);
271 0 delete $heap->{server};
272 },
273  
274 0 ▶ got_server_error => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
275 0 $error_callback->(@_);
276 0 ▶ if ($_[HEAP]->{shutdown_on_error}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_[3]{"shutdown_on_error"}) 0 0 0
277 0 $_[KERNEL]->yield("shutdown");
278 0 $_[HEAP]->{got_an_error} = 1;
279 }
280 },
281  
282 0 ▶ got_server_input => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
283 0 my $heap = $_[HEAP];
284 0 ▶ return if $heap->{shutdown};
Branch: 1 branch
BranchTrueFalseTotal
if $heap->{"shutdown"} 0 0 0
285 0 $input_callback->(@_);
286 },
287  
288 0 ▶ got_server_flush => sub {
Subroutine __ANON__: not called CC=2 SCAR=17.9
289 0 my $heap = $_[HEAP];
290 0 $flush_callback->(@_);
291 0 ▶ if ($heap->{shutdown}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($heap->{"shutdown"}) 0 0 0
292 0 delete $heap->{server};
293 0 $disc_callback->(@_);
294 }
295 },
296  
297 0 ▶ shutdown => sub {
Subroutine __ANON__: not called CC=7 SCAR=40.3
298 0 my ($kernel, $heap) = @_[KERNEL, HEAP];
299 0 $heap->{shutdown} = 1;
300  
301 $kernel->alarm_remove( delete $heap->{ctimeout_id} )
302 0 ▶ if exists $heap->{ctimeout_id};
Branch: 1 branch
BranchTrueFalseTotal
if exists $heap->{"ctimeout_id"} 0 0 0
303  
304 0 ▶ if ($heap->{connected}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($heap->{'connected'}) { } 0 0 0
305 0 $heap->{connected} = 0;
306 0 ▶ if (defined $heap->{server}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $heap->{"server"}) 0 0 0
307 0 ▶ if (
Branch: 1 branch
BranchTrueFalseTotal
if ($heap->{"got_an_error"} or not $heap->{"server"}->get_driver_out_octets) 0 0 0
Condition0%0/3
$heap->{"got_an_error"} or not $heap->{"server"}->get_driver_out_octets
l!l&&r!l&&!r
000
MC/DC0%0/2
$heap->{"got_an_error"} or not $heap->{"server"}->get_driver_out_octets
$heap->{"got_an_error"} not $heap->{"server"}->get_driver_out_octets
Truth table0%0/3
A or not(B)
A= $heap->{"got_an_error"}B= not $heap->{"server"}->get_driver_out_octets
ABresult
1X1
011
000
308 $heap->{got_an_error} or
309 not $heap->{server}->get_driver_out_octets()
310 ) {
311 0 delete $heap->{server};
312 0 $disc_callback->(@_);
313 }
314 }
315 }
316 else {
317 0 delete $heap->{server};
318 }
319  
320 0 ▶ $kernel->alias_remove($alias) if defined $alias;
Branch: 1 branch
BranchTrueFalseTotal
if defined $alias 0 0 0
321 },
322  
323 # User supplied states.
324 0 %$inline_states,
325 },
326  
327 # User arguments.
328 args => $args,
329  
330 # User supplied states.
331 package_states => $package_states,
332 object_states => $object_states,
333 )->ID;
334 }
335  
336 0 ▶sub _get_filter {
Subroutine _get_filter: not called CC=4 SCAR=30.0
337 0 my $filter = shift;
338 0 ▶ if (ref $filter eq 'ARRAY') {
Branch: 3 branches
BranchTrueFalseTotal
if (ref $filter eq 'ARRAY') { } 0 0 0
elsif (ref $filter) { } 0 0 0
elsif (not defined $filter) { } 0 0 0
339 0 my @filter_args = @$filter;
340 0 $filter = shift @filter_args;
341 0 return $filter->new(@filter_args);
342 } elsif (ref $filter) {
343 0 return $filter->clone();
344 } elsif (!defined($filter)) {
345 0 return POE::Filter::Line->new();
346 } else {
347 0 return $filter->new();
348 }
349 }
350  
351 # The default error handler logs to STDERR and shuts down the socket.
352  
353 0 ▶sub _default_error {
Subroutine _default_error: not called CC=4 SCAR=30.0
354 0 ▶ unless ($_[ARG0] eq "read" and ($_[ARG1] == 0 or $_[ARG1] == ECONNRESET)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($_[10] eq "read" and $_[11] == 0 || $_[11] == 104) 0 0 0
Condition0%0/6
$_[10] eq "read" and $_[11] == 0 || $_[11] == 104
!ll&&!rl&&r
000
$_[11] == 0 or $_[11] == 104
l!l&&r!l&&!r
000
MC/DC0%0/3
$_[10] eq "read" and $_[11] == 0 || $_[11] == 104
$_[10] eq "read" $_[11] == 0 $_[11] == 104
Truth table0%0/4
A and B or C
A= $_[10] eq "read"B= $_[11] == 0C= $_[11] == 104
ABCresult
0XX0
1000
11X1
1011
355 0 warn(
356 'Client ', $_[SESSION]->ID, " got $_[ARG0] error $_[ARG1] ($_[ARG2])\n"
357 );
358 }
359 0 delete $_[HEAP]->{server};
360 }
361  
362 0 ▶sub _default_io_error {
Subroutine _default_io_error: not called CC=2 SCAR=17.9
363 0 my ($syscall, $errno, $error) = @_[ARG0..ARG2];
364 0 ▶ $error = "Normal disconnection" unless $errno;
Branch: 1 branch
BranchTrueFalseTotal
unless $errno 0 0 0
365 0 warn('Client ', $_[SESSION]->ID, " got $syscall error $errno ($error)\n");
366 0 $_[KERNEL]->yield("shutdown");
367 }
368  
369 ## sslify_socket (@_)
370 #
371 # Attempt to SSLify the passed socket. Not to be
372 # called as a state, this is a utility function that will return bool of
373 # success. It supports non-blocking SSLification so it will come back to the
374 # calling state over and over again while waiting for the peer.
375  
376 0 ▶sub sslify_socket {
Subroutine sslify_socket: not called CC=5 SCAR=34.0
Pod undocumented
377 0 my ($heap, $kernel, $session, $state, $socket) = @_[HEAP, KERNEL, SESSION, STATE, ARG0];
378
379 # Start SSL on the socket if this hasn't yet been done
380 0 ▶ if (ref $socket eq 'GLOB') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $socket eq "GLOB") 0 0 0
381 0 $socket = IO::Socket::SSL->start_SSL($socket, SSL_startHandshake => 0);
382 # Make sure the previous operation succeeded
383 0 ▶ if (! $socket->isa('IO::Socket::SSL')) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($socket->isa("IO::Socket::SSL")) 0 0 0
384 0 die "start_SSL did not succeed; destroying socket";
385 }
386 0 $socket->blocking(0);
387 }
388  
389 #print STDERR "connect_SSL()\n";
390 # Do the connect_SSL (possibly many times)
391 0 ▶ if ($socket->connect_SSL) {
Branch: 2 branches
BranchTrueFalseTotal
if ($socket->connect_SSL) { } 0 0 0
elsif ($! != 11) { } 0 0 0
392 #print STDERR $session->ID . ": client connected SSL\n";
393 0 return 1;
394 }
395 elsif ($! != EAGAIN) {
396 0 die $session->ID . ": client SSL failed";
397 }
398 else {
399 # As a non-blocking SSL setup, we may not be ready to accept. If that's
400 # the case, give it time and come back in a minute.
401 0 $kernel->yield($state, $socket);
402 0 return 0;
403 }
404 }
405  
406 1 1;
407  
↑ Summary AMQP/Channel.pm »