Branch Coverage

blib/lib/Net/SIP/SocketPool.pm
Criterion Covered Total %
branch 124 248 50.0


line true false branch
42 0 0 unless my $ref = $m{$_[$i]}
71 38 105 if ($proto eq 'tls') { }
95 0 0 $verify_client == 1 ? :
0 0 $verify_client == -1 ? :
38 0 !$verify_client ? :
105 38 0 if ($SSL_REUSE_CTX)
107 0 76 if $self->{'tls'}{$_}{'SSL_reuse_ctx'}
119 143 0 unless ($connected)
123 0 143 $peer ? :
134 0 134 if ($self->{'loop'})
152 53 59 if ($self->{'loop'})
156 25 28 if ($self->{'timeout_timer'})
161 59 53 if ($self->{'loop'} = $loop)
176 0 0 unless @fo
177 0 0 if @fo > 1
192 0 194 if ($self->{'dst'}) { }
0 194 elsif (not ref $dst) { }
203 67 127 if (@$fos > 1)
206 37 30 if ($packet->is_response and my $fo = $self->{'tids'}{$packet->tid})
207 37 0 if (my(@s) = grep({$_ == $fo;} @$fos))
212 30 37 if (@$fos > 1)
214 30 0 if (my(@s) = grep({$_->{'peer'}{'port'} == $dst->{'port'} if $_->{'peer'} and $_->{'peer'}{'addr'} eq $dst->{'addr'};} @$fos))
218 30 30 if $_->{'peer'} and $_->{'peer'}{'addr'} eq $dst->{'addr'}
223 0 67 unless ($match)
231 112 82 if ($self->{'ipproto'} eq 'udp')
232 0 112 if ($fo->{'peer'}) { }
235 0 0 unless defined $rv
240 0 112 unless defined $rv
245 82 0 if ($self->{'ipproto'} eq 'tcp')
246 67 15 if ($fo->{'peer'})
249 0 67 if $Net::SIP::SocketPool::DEBUG
252 67 0 unless $fo->{'inside_connect'}
257 0 15 if $Net::SIP::SocketPool::DEBUG
286 5 163 if $self->{'loop'} and not $fo->{'inside_connect'}
287 25 143 if not $self->{'timeout_timer'} and $fo->{'didit'}
294 0 2 if @_
295 2 0 if $self->{'loop'}
297 2 0 if ($fo->{'tids'})
306 0 30 if keys %$fds <= 1
307 0 30 unless $self->{'loop'}
316 0 30 if ($tdiff > $expire) { }
0 30 elsif ($_->{'inside_connect'} and $tdiff > $CONNECT_TIMEOUT) { }
324 30 0 if ($need_timer)
325 5 25 if $self->{'timeout_timer'}
344 0 0 if @_
377 25 59 $fo->{'peer'} ? :
387 0 0 unless my $dst = $self->{'dst'}
389 0 0 if ($ip ne $dst->{'addr'} or $port ne $dst->{'port'})
390 0 0 if $Net::SIP::SocketPool::DEBUG
403 0 123 unless my $fo = $self->{'fds'}{fileno $fd}
404 0 123 unless my $from = recv($fd, my $buf, 65536, 0)
408 0 123 if (length $buf < 13)
414 0 123 if shift() and not _check_from($self, $from)
416 0 123 unless my $pkt = eval { do { 'Net::SIP::Packet'->new_from_string($buf) } }
436 0 10 unless my $srvfo = $self->{'fds'}{fileno $srvfd}
437 0 10 unless my $from = accept(my $clfd, $srvfd)
438 0 10 if $self->{'dst'} and not _check_from($self, $from)
447 5 5 if $self->{'tls'}
457 0 88 unless my $fo = $self->{'fds'}{fileno $fd}
460 0 88 if $Net::SIP::SocketPool::DEBUG and $fo->{'rbuf'} ne ''
467 34 54 $self->{'tls'} ? :
468 0 88 unless (defined $n)
469 0 0 if $!{'EINTR'}
470 0 0 if $!{'EAGAIN'} or $!{'EWOULDBLOCK'}
475 2 86 unless ($n)
482 0 86 if ($fo->{'rbuf'} =~ s/\A((?:\r\n)+)//)
483 0 0 if $Net::SIP::SocketPool::DEBUG
488 0 86 if ($hdrpos < 0 and length $fo->{'rbuf'} > $MAX_SIP_HEADER or $hdrpos > $MAX_SIP_HEADER)
494 0 86 if ($hdrpos < 0)
495 0 0 if $Net::SIP::SocketPool::DEBUG
501 0 86 unless (%clen)
506 0 86 if (keys %clen > 1)
512 0 86 if ($clen > $MAX_SIP_BODY)
517 0 86 if ($hdrpos + $clen > length $fo->{'rbuf'})
519 0 0 if $Net::SIP::SocketPool::DEBUG
523 0 86 unless my $pkt = eval { do { 'Net::SIP::Packet'->new_from_string(substr($fo->{'rbuf'}, 0, $hdrpos + $clen, '')) } }
529 30 56 if ($pkt->is_request)
540 86 0 if $self->{'loop'}
543 33 53 $self->{'tls'} ? :
548 0 86 if $fo->{'rbuf'} ne ''
559 0 15 if $Net::SIP::SocketPool::DEBUG
560 0 15 if ($rv)
562 0 0 if $self->{'tls'}
566 0 15 if $!{'EINTR'}
567 15 0 if ($!{'EALREADY'} or $!{'EINPROGRESS'})
569 0 15 if $Net::SIP::SocketPool::DEBUG
582 15 0 if ($xxfd)
586 15 0 $err ? :
587 0 15 if ($err)
598 5 10 if $self->{'tls'}
605 10 0 if $fo->{'wbuf'} ne ''
616 82 0 if (my $n = syswrite($fo->{'fd'}, $fo->{'wbuf'}))
621 0 0 if $!{'EINTR'}
622 0 0 if ($!{'EAGAIN'} or $!{'EWOULDBLOCK'})
623 0 0 if $xxfd
638 0 82 if $Net::SIP::SocketPool::DEBUG
639 0 82 if $xxfd
648 5 8 unless ($xxfd)
649 0 5 if $Net::SIP::SocketPool::DEBUG
651 0 5 unless 'IO::Socket::SSL'->start_SSL($fo->{'fd'}, %{$$self{'tls'}{'m'};}, 'SSL_startHandshake', 0)
656 5 8 if ($fo->{'fd'}->accept_SSL)
657 0 5 if ($Net::SIP::SocketPool::DEBUG)
659 0 0 $peer_cert ? :
664 4 1 if $xxfd
669 8 0 if ($SSL_ERROR == $SSL_WANT_READ) { }
0 0 elsif ($SSL_ERROR == $SSL_WANT_WRITE) { }
670 0 8 if $Net::SIP::SocketPool::DEBUG
671 4 4 if $xxfd
674 0 0 if $Net::SIP::SocketPool::DEBUG
675 0 0 if $xxfd
689 5 10 unless ($xxfd)
690 0 5 if $Net::SIP::SocketPool::DEBUG
696 0 5 unless 'IO::Socket::SSL'->start_SSL($fo->{'fd'}, %{$$self{'tls'}{'c'};}, 'SSL_startHandshake', 0, 'SSL_verifycn_name', $fo->{'peer'}{'host'}, 'SSL_hostname', $fo->{'peer'}{'host'})
699 5 10 if ($fo->{'fd'}->connect_SSL)
701 0 5 if $Net::SIP::SocketPool::DEBUG
703 5 0 if $xxfd
705 5 0 if $fo->{'wbuf'} ne ''
710 10 0 if ($SSL_ERROR == $SSL_WANT_READ) { }
0 0 elsif ($SSL_ERROR == $SSL_WANT_WRITE) { }
711 0 10 if $Net::SIP::SocketPool::DEBUG
712 5 5 if $xxfd
716 0 0 if $Net::SIP::SocketPool::DEBUG
717 0 0 if $xxfd
729 0 0 unless my $cert = shift()