| 1 | package Linux::Event::_Socket::Dgram; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 11 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 11 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 11 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 11 | ▶ | use parent 'Linux::Event::_Socket'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 11 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 11 | ▶ | use Config (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 11 | ▶ | use Errno (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 11 | ▶ | use Fcntl qw(F_GETFD F_GETFL F_SETFD F_SETFL FD_CLOEXEC O_NONBLOCK); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 11 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 11 | ▶ | use Socket qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | AF_INET AF_INET6 AF_UNIX AI_PASSIVE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | IPPROTO_IPV6 IPV6_V6ONLY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | SOCK_DGRAM SOCK_NONBLOCK SOCK_CLOEXEC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | SOL_SOCKET SO_BROADCAST SO_ERROR SO_REUSEADDR SO_REUSEPORT SO_TYPE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | getaddrinfo inet_pton pack_sockaddr_in pack_sockaddr_in6 pack_sockaddr_un | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 11 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 11 | ▶ | use utf8 (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 11 | ▶ | use Linux::Event::Address; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 11 | ▶ | use Linux::Event::Error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 11 | ▶ | use Linux::Event::_SocketConfig (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 11 | ▶ | use Linux::Event::_Resolver (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 11 | require Linux::Event::Kernel::Timer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 11 | require XSLoader; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 11 | XSLoader::load(__PACKAGE__); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 11 | my %CLASS_DESCRIPTOR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 11 | my @APPLICATION_CALLBACK = qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | on_datagram on_drain on_ready on_error on_close | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 11 | ▶ | my $MAX_INTEGER = $Config::Config{ivsize} >= 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | ? '9223372036854775807' : '2147483647'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 362 | ▶ | sub _integer ($target, $name, $value, $minimum, $maximum = undef) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_integer: called CC=10 SCAR=23.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 362 | ▶ | croak "$target $name must be an integer" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
not defined $value or ref $value or not $value =~ /\A\d+\z/u
not defined $value or ref $value
MC/DC33%1/3
not defined $value or ref $value or not $value =~ /\A\d+\z/u
not defined $value
ref $value
not $value =~ /\A\d+\z/u
Truth table50%2/4
not(A) or B or not(C)
A= not defined $valueB= ref $valueC= not $value =~ /\A\d+\z/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | if !defined($value) || ref($value) || $value !~ /\A\d+\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 361 | ▶ | $maximum //= $MAX_INTEGER; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$maximum //= $MAX_INTEGER
MC/DC0%0/2
$maximum //= $MAX_INTEGER
$maximum
$MAX_INTEGER
Truth table66%2/3
A //= B
A= $maximumB= $MAX_INTEGER
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 361 | my $digits = "$value"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 361 | $digits =~ s/\A0+(?=\d)//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 361 | ▶ | croak "$target $name must be at most $maximum" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
length $digits > length "$maximum" or length $digits == length "$maximum" and $digits gt "$maximum"
length $digits == length "$maximum" and $digits gt "$maximum"
MC/DC33%1/3
length $digits > length "$maximum" or length $digits == length "$maximum" and $digits gt "$maximum"
length $digits > length "$maximum"
length $digits == length "$maximum"
$digits gt "$maximum"
Truth table75%3/4
A or B and C
A= length $digits > length "$maximum"B= length $digits == length "$maximum"C= $digits gt "$maximum"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | if length($digits) > length("$maximum") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | || (length($digits) == length("$maximum") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | && $digits gt "$maximum"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 360 | $value = 0 + $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 360 | ▶ | croak "$target $name must be at least $minimum" if $value < $minimum; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 360 | return $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 229 | ▶ | sub _boolean ($target, $name, $value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_boolean: called CC=5 SCAR=19.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 229 | ▶ | croak "$target $name must be zero or one" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not defined $value or ref $value or not $value =~ /\A[01]\z/u
not defined $value or ref $value
MC/DC0%0/3
not defined $value or ref $value or not $value =~ /\A[01]\z/u
not defined $value
ref $value
not $value =~ /\A[01]\z/u
Truth table25%1/4
not(A) or B or not(C)
A= not defined $valueB= ref $valueC= not $value =~ /\A[01]\z/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | if !defined($value) || ref($value) || $value !~ /\A[01]\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 229 | ▶ | return $value ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 45 | ▶ | sub _descriptor_for ($class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_descriptor_for: called CC=17 SCAR=30.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 45 | ▶ | return $CLASS_DESCRIPTOR{$class} if exists $CLASS_DESCRIPTOR{$class}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 15 | ▶ | croak 'Linux::Event::_Socket::Dgram is an abstract base class' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | if $class eq __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 15 | ▶ | croak "$class is not a Linux::Event::_Socket::Dgram subclass" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | if !$class->isa(__PACKAGE__); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 15 | my %callback = map { $_ => scalar $class->can($_) } qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | on_datagram on_drain on_ready on_error on_close configure_socket | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 15 | my %option = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | max_datagram_size => 65_535, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | max_datagrams_per_tick => 256, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | edge_triggered => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | high_watermark => 1_048_576, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | low_watermark => 262_144, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | max_pending_bytes => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | max_pending_datagrams => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | reuseaddr => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | reuseport => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | broadcast => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | v6only => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | send_buffer => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | receive_buffer => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 15 | ▶ | if (my $configure = $class->can('datagram_options')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 2 | my @configured = $configure->($class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 2 | my %configured; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 2 | ▶ | if (@configured == 1 && ref($configured[0]) eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@configured == 1 and ref $configured[0] eq "HASH"
MC/DC0%0/2
@configured == 1 and ref $configured[0] eq "HASH"
@configured == 1
ref $configured[0] eq "HASH"
Truth table33%1/3
A and B
A= @configured == 1B= ref $configured[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | %configured = %{ $configured[0] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 2 | ▶ | croak "$class datagram_options() returned an odd option list" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | if @configured % 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 2 | %configured = @configured; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 2 | my @unknown = grep { !exists $option{$_} } keys %configured; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 2 | ▶ | croak "$class datagram_options() returned unknown options: " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | . join(', ', sort @unknown) if @unknown; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 2 | @option{keys %configured} = values %configured; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | $option{max_datagram_size} = _integer( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 15 | $class, 'max_datagram_size', $option{max_datagram_size}, 1, 16_777_216, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | $option{max_datagrams_per_tick} = _integer( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | $class, 'max_datagrams_per_tick', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 15 | $option{max_datagrams_per_tick}, 0, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 15 | for my $name (qw(high_watermark low_watermark max_pending_bytes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | max_pending_datagrams)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 60 | $option{$name} = _integer($class, $name, $option{$name}, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | croak "$class low_watermark must be <= high_watermark" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 15 | ▶ | if $option{low_watermark} > $option{high_watermark}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 15 | for my $name (qw(edge_triggered reuseaddr reuseport broadcast)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 60 | $option{$name} = _boolean($class, $name, $option{$name}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | $option{v6only} = _boolean($class, 'v6only', $option{v6only}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 15 | ▶ | if defined $option{v6only}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 15 | for my $name (qw(send_buffer receive_buffer)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | $option{$name} = Linux::Event::_SocketConfig::normalize( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | $class, $name, $option{$name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 30 | ▶ | ) if defined $option{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | croak "$class edge_triggered requires max_datagrams_per_tick => 0" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 15 | ▶ | if $option{edge_triggered} && $option{max_datagrams_per_tick}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$option{"edge_triggered"} and $option{"max_datagrams_per_tick"}
MC/DC0%0/2
$option{"edge_triggered"} and $option{"max_datagrams_per_tick"}
$option{"edge_triggered"}
$option{"max_datagrams_per_tick"}
Truth table33%1/3
A and B
A= $option{"edge_triggered"}B= $option{"max_datagrams_per_tick"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 15 | return $CLASS_DESCRIPTOR{$class} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | class => $class, callbacks => \%callback, options => \%option, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 45 | ▶ | sub _effective_descriptor ($class, $method, $option) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_effective_descriptor: called CC=6 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 45 | my $descriptor = _descriptor_for($class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 45 | my %override; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 45 | for my $name (@APPLICATION_CALLBACK) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 221 | ▶ | next if !exists $option->{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 4 | my $callback = delete $option->{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 4 | ▶ | croak "$method(): $name must be a coderef" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | if ref($callback) ne 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 3 | $override{$name} = $callback; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 44 | my %callback = (%{ $descriptor->{callbacks} }, %override); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | croak "$method(): on_datagram callback is required" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 44 | ▶ | if !$callback{on_datagram}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 42 | ▶ | return $descriptor if !%override; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 2 | return { %$descriptor, callbacks => \%callback }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 29 | ▶ | sub new ($class, %option) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 29 | return $class->_construct(0, %option); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 16 | ▶ | sub connect ($class, %option) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
connect: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 16 | return $class->_construct(1, %option); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 45 | ▶ | sub _construct ($class, $connect, %option) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_construct: called CC=147 SCAR=69.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 45 | ▶ | croak(($connect ? 'connect' : 'new') . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | '(): must be called as a class method') if ref $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 45 | ▶ | my $method = $connect ? 'connect' : 'new'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 45 | my $descriptor = _effective_descriptor($class, $method, \%option); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 42 | my %known = map { $_ => 1 } qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | loop data bind_device | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | max_datagram_size max_datagrams_per_tick edge_triggered | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | high_watermark low_watermark max_pending_bytes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | max_pending_datagrams reuseaddr reuseport broadcast v6only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | send_buffer receive_buffer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | unlink unlink_on_close permissions owns_socket | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | fh host port unix local_host local_port local_unix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 42 | my @unknown = sort grep { !$known{$_} } keys %option; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 42 | ▶ | croak "$method(): unknown options: " . join(', ', @unknown) if @unknown; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 41 | my %supplied = map { $_ => 1 } keys %option; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 41 | my $loop = delete $option{loop}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 41 | ▶ | croak "$method(): loop must be an object implementing add() and watch()" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition44%4/9
defined $loop and not ref $loop && $loop->can("add") && $loop->can("watch")
ref $loop && $loop->can('add') && $loop->can('watch')
ref $loop and $loop->can("add")
MC/DC0%0/4
defined $loop and not ref $loop && $loop->can("add") && $loop->can("watch")
defined $loop
ref $loop
$loop->can("add")
$loop->can('watch')
Truth table40%2/5
A and not(B and C && D)
A= defined $loopB= ref $loopC= $loop->can("add")D= $loop->can('watch')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | if defined($loop) && (!ref($loop) || !$loop->can('add') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | || !$loop->can('watch')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 41 | my $data = delete $option{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 41 | my $bind_device = delete $option{bind_device}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 41 | ▶ | croak "$method(): bind_device must be a non-empty interface name" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition11%1/9
defined $bind_device and ref $bind_device || $bind_device eq "" || $bind_device =~ /\0/u
ref $bind_device or $bind_device eq "" or $bind_device =~ /\0/u
ref $bind_device or $bind_device eq ""
MC/DC0%0/4
defined $bind_device and ref $bind_device || $bind_device eq "" || $bind_device =~ /\0/u
defined $bind_device
ref $bind_device
$bind_device eq ""
$bind_device =~ /\0/u
Truth table20%1/5
A and B or C or D
A= defined $bind_deviceB= ref $bind_deviceC= $bind_device eq ""D= $bind_device =~ /\0/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | if defined($bind_device) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | && (ref($bind_device) || $bind_device eq '' || $bind_device =~ /\0/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 41 | my %effective = %{ $descriptor->{options} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 41 | for my $name (keys %effective) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 533 | ▶ | next if !exists $option{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 6 | $effective{$name} = delete $option{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | $effective{max_datagram_size} = _integer( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | "$method():", 'max_datagram_size', $effective{max_datagram_size}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 41 | 1, 16_777_216, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | $effective{max_datagrams_per_tick} = _integer( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | "$method():", 'max_datagrams_per_tick', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 41 | $effective{max_datagrams_per_tick}, 0, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 41 | for my $name (qw(high_watermark low_watermark max_pending_bytes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | max_pending_datagrams)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | $effective{$name} = _integer( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 163 | "$method():", $name, $effective{$name}, 0, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | croak "$method(): low_watermark must be <= high_watermark" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 40 | ▶ | if $effective{low_watermark} > $effective{high_watermark}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 40 | for my $name (qw(edge_triggered reuseaddr reuseport broadcast)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | $effective{$name} = _boolean( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 160 | "$method():", $name, $effective{$name}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | $effective{v6only} = _boolean( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | "$method():", 'v6only', $effective{v6only}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 40 | ▶ | ) if defined $effective{v6only}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 40 | for my $name (qw(send_buffer receive_buffer)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | $effective{$name} = Linux::Event::_SocketConfig::normalize( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | $method, $name, $effective{$name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 79 | ▶ | ) if defined $effective{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | croak "$method(): edge_triggered requires max_datagrams_per_tick => 0" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 39 | ▶ | if $effective{edge_triggered} && $effective{max_datagrams_per_tick}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$effective{"edge_triggered"} and $effective{"max_datagrams_per_tick"}
MC/DC50%1/2
$effective{"edge_triggered"} and $effective{"max_datagrams_per_tick"}
$effective{"edge_triggered"}
$effective{"max_datagrams_per_tick"}
Truth table66%2/3
A and B
A= $effective{"edge_triggered"}B= $effective{"max_datagrams_per_tick"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | croak "$method(): broadcast and v6only cannot be combined" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 38 | ▶ | if $effective{broadcast} && defined $effective{v6only}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$effective{"broadcast"} and defined $effective{"v6only"}
MC/DC0%0/2
$effective{"broadcast"} and defined $effective{"v6only"}
$effective{"broadcast"}
defined $effective{"v6only"}
Truth table33%1/3
A and B
A= $effective{"broadcast"}B= defined $effective{"v6only"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | my $unlink_existing = exists($option{unlink}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 38 | ▶ | ? _boolean("$method():", 'unlink', delete $option{unlink}) : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | my $unlink_on_close = exists($option{unlink_on_close}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | ? _boolean("$method():", 'unlink_on_close', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 38 | ▶ | delete $option{unlink_on_close}) : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 38 | my $permissions = delete $option{permissions}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 38 | ▶ | $permissions = _integer("$method():", 'permissions', $permissions, 0, 07777) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | if defined $permissions; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 38 | my $owns_socket_supplied = exists $option{owns_socket}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | my $owns_socket = $owns_socket_supplied | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | ? _boolean("$method():", 'owns_socket', delete $option{owns_socket}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 38 | ▶ | : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 38 | my ($fh, $family, $local, $peer, $path, $local_path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 38 | my $adopted = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | 38 | my ($host, $port, $local_host, $local_port, $needs_resolution, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | $local_bind, $required_family, $required_family_option); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 38 | ▶ | if (!$connect && exists $option{fh}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 5 branches
Condition100%3/3
not $connect and exists $option{"fh"}
MC/DC100%2/2
not $connect and exists $option{"fh"}
not $connect
exists $option{"fh"}
Truth table100%3/3
not(A) and B
A= not $connectB= exists $option{"fh"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 4 | $adopted = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 4 | $fh = delete $option{fh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 4 | ▶ | croak 'new(): fh must be a datagram socket filehandle' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $fh and defined fileno $fh
MC/DC0%0/2
defined $fh and defined fileno $fh
defined $fh
defined fileno $fh
Truth table33%1/3
A and B
A= defined $fhB= defined fileno $fh
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | if !defined($fh) || !defined(fileno($fh)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | croak 'new(): address options are not valid with fh' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 4 | ▶ | if grep { exists $option{$_} } qw(host port unix local_host | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | local_port local_unix); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 4 | my $type = getsockopt($fh, SOL_SOCKET, SO_TYPE); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 4 | ▶ | croak 'new(): fh must be a datagram socket' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not defined $type or length $type < 4 or unpack("i", $type) != 2
not defined $type or length $type < 4
MC/DC0%0/3
not defined $type or length $type < 4 or unpack("i", $type) != 2
not defined $type
length $type < 4
unpack("i", $type) != 2
Truth table25%1/4
not(A) or B or C
A= not defined $typeB= length $type < 4C= unpack("i", $type) != 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | if !defined($type) || length($type) < 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | || unpack('i', $type) != SOCK_DGRAM; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 4 | $local = Linux::Event::Address->new(getsockname($fh)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 4 | $family = $local->family_number; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 4 | ▶ | croak 'new(): fh must use an IPv4, IPv6, or Unix address family' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition55%5/9
not defined $family or $family != 2 and $family != 10 and $family != 1
$family != 2 and $family != 10 and $family != 1
$family != 2 and $family != 10
MC/DC0%0/4
not defined $family or $family != 2 and $family != 10 and $family != 1
not defined $family
$family != 2
$family != 10
$family != 1
Truth table40%2/5
not(A) or B and C and D
A= not defined $familyB= $family != 2C= $family != 10D= $family != 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | if !defined($family) || ($family != AF_INET | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | && $family != AF_INET6 && $family != AF_UNIX); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 4 | my @invalid = grep { $supplied{$_} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | qw(unlink unlink_on_close permissions); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 4 | ▶ | if ($family == AF_UNIX) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 1 | push @invalid, grep { $supplied{$_} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | qw(bind_device v6only broadcast reuseaddr reuseport); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | push @invalid, 'broadcast' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 1 | ▶ | if $effective{broadcast} && !$supplied{broadcast}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$effective{"broadcast"} and not $supplied{"broadcast"}
MC/DC0%0/2
$effective{"broadcast"} and not $supplied{"broadcast"}
$effective{"broadcast"}
not $supplied{"broadcast"}
Truth table33%1/3
A and not(B)
A= $effective{"broadcast"}B= not $supplied{"broadcast"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | push @invalid, 'reuseaddr' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 1 | ▶ | if $effective{reuseaddr} && !$supplied{reuseaddr}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$effective{"reuseaddr"} and not $supplied{"reuseaddr"}
MC/DC0%0/2
$effective{"reuseaddr"} and not $supplied{"reuseaddr"}
$effective{"reuseaddr"}
not $supplied{"reuseaddr"}
Truth table33%1/3
A and not(B)
A= $effective{"reuseaddr"}B= not $supplied{"reuseaddr"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | push @invalid, 'reuseport' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 1 | ▶ | if $effective{reuseport} && !$supplied{reuseport}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$effective{"reuseport"} and not $supplied{"reuseport"}
MC/DC0%0/2
$effective{"reuseport"} and not $supplied{"reuseport"}
$effective{"reuseport"}
not $supplied{"reuseport"}
Truth table33%1/3
A and not(B)
A= $effective{"reuseport"}B= not $supplied{"reuseport"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | push @invalid, 'v6only' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 1 | ▶ | if defined($effective{v6only}) && !$supplied{v6only}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $effective{"v6only"} and not $supplied{"v6only"}
MC/DC0%0/2
defined $effective{"v6only"} and not $supplied{"v6only"}
defined $effective{"v6only"}
not $supplied{"v6only"}
Truth table33%1/3
A and not(B)
A= defined $effective{"v6only"}B= not $supplied{"v6only"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 4 | ▶ | croak 'new(): options not valid for this socket source: ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | . join(', ', sort @invalid) if @invalid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 4 | _set_adopted_flags($fh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 4 | my $packed_peer = eval { getpeername($fh) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 4 | ▶ | $peer = Linux::Event::Address->new($packed_peer) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | if defined $packed_peer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 4 | ▶ | $connect = defined($peer) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | ▶ | } elsif (!$connect && (exists($option{host}) || exists($option{port}))) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition83%5/6
not $connect and exists $option{"host"} || exists $option{"port"}
exists $option{"host"} or exists $option{"port"}
MC/DC66%2/3
not $connect and exists $option{"host"} || exists $option{"port"}
not $connect
exists $option{"host"}
exists $option{"port"}
Truth table75%3/4
not(A) and B or C
A= not $connectB= exists $option{"host"}C= exists $option{"port"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 15 | $host = delete $option{host}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 15 | $port = delete $option{port}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 15 | ▶ | croak 'new(): host is required' if !defined $host; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 15 | ▶ | croak 'new(): host must be a non-empty string without NUL bytes' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
ref $host or $host eq "" or $host =~ /\0/u
ref $host or $host eq ""
MC/DC33%1/3
ref $host or $host eq "" or $host =~ /\0/u
ref $host
$host eq ""
$host =~ /\0/u
Truth table50%2/4
A or B or C
A= ref $hostB= $host eq ""C= $host =~ /\0/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | if ref($host) || $host eq '' || $host =~ /\0/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | 14 | $port = _integer('new():', 'port', $port, 0, 65535); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 13 | my @invalid = grep { $supplied{$_} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | qw(unix local_host local_port local_unix unlink unlink_on_close | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | permissions owns_socket); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 13 | ▶ | croak 'new(): options not valid for UDP: ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | . join(', ', sort @invalid) if @invalid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 12 | ($fh, $family) = _create_bound_inet( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | $host, $port, \%effective, $bind_device, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 11 | $local = Linux::Event::Address->new(getsockname($fh)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 11 | $owns_socket = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | ▶ | } elsif (!$connect && exists $option{unix}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
not $connect and exists $option{"unix"}
MC/DC50%1/2
not $connect and exists $option{"unix"}
not $connect
exists $option{"unix"}
Truth table66%2/3
not(A) and B
A= not $connectB= exists $option{"unix"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 4 | $path = delete $option{unix}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 4 | ▶ | croak 'new(): unix must be a non-empty path without NUL bytes' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition44%4/9
not defined $path or ref $path or $path eq "" or $path =~ /\0/u
not defined $path or ref $path or $path eq ""
not defined $path or ref $path
MC/DC25%1/4
not defined $path or ref $path or $path eq "" or $path =~ /\0/u
not defined $path
ref $path
$path eq ""
$path =~ /\0/u
Truth table40%2/5
not(A) or B or C or D
A= not defined $pathB= ref $pathC= $path eq ""D= $path =~ /\0/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | if !defined($path) || ref($path) || $path eq '' || $path =~ /\0/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 3 | my @invalid = grep { $supplied{$_} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | qw(local_host local_port local_unix bind_device v6only broadcast | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | reuseaddr reuseport owns_socket); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | push @invalid, 'broadcast' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 3 | ▶ | if $effective{broadcast} && !$supplied{broadcast}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$effective{"broadcast"} and not $supplied{"broadcast"}
MC/DC0%0/2
$effective{"broadcast"} and not $supplied{"broadcast"}
$effective{"broadcast"}
not $supplied{"broadcast"}
Truth table33%1/3
A and not(B)
A= $effective{"broadcast"}B= not $supplied{"broadcast"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | push @invalid, 'reuseaddr' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 3 | ▶ | if $effective{reuseaddr} && !$supplied{reuseaddr}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$effective{"reuseaddr"} and not $supplied{"reuseaddr"}
MC/DC0%0/2
$effective{"reuseaddr"} and not $supplied{"reuseaddr"}
$effective{"reuseaddr"}
not $supplied{"reuseaddr"}
Truth table33%1/3
A and not(B)
A= $effective{"reuseaddr"}B= not $supplied{"reuseaddr"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | push @invalid, 'reuseport' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 3 | ▶ | if $effective{reuseport} && !$supplied{reuseport}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$effective{"reuseport"} and not $supplied{"reuseport"}
MC/DC0%0/2
$effective{"reuseport"} and not $supplied{"reuseport"}
$effective{"reuseport"}
not $supplied{"reuseport"}
Truth table33%1/3
A and not(B)
A= $effective{"reuseport"}B= not $supplied{"reuseport"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | push @invalid, 'v6only' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 3 | ▶ | if defined($effective{v6only}) && !$supplied{v6only}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $effective{"v6only"} and not $supplied{"v6only"}
MC/DC0%0/2
defined $effective{"v6only"} and not $supplied{"v6only"}
defined $effective{"v6only"}
not $supplied{"v6only"}
Truth table33%1/3
A and not(B)
A= defined $effective{"v6only"}B= not $supplied{"v6only"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 3 | ▶ | croak 'new(): options not valid for Unix datagrams: ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | . join(', ', sort @invalid) if @invalid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 2 | ($fh, $family) = _create_bound_unix( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | $path, $unlink_existing, $permissions, \%effective, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 2 | $local = Linux::Event::Address->new(getsockname($fh)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 2 | $owns_socket = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | ▶ | } elsif ($connect && (exists($option{host}) || exists($option{port}))) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%4/6
$connect and exists $option{"host"} || exists $option{"port"}
exists $option{"host"} or exists $option{"port"}
MC/DC33%1/3
$connect and exists $option{"host"} || exists $option{"port"}
$connect
exists $option{"host"}
exists $option{"port"}
Truth table50%2/4
A and B or C
A= $connectB= exists $option{"host"}C= exists $option{"port"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 10 | $host = delete $option{host}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 10 | $port = delete $option{port}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | 10 | ▶ | croak 'connect(): host is required' if !defined $host; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 10 | ▶ | croak 'connect(): host must be a non-empty string without NUL bytes' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
ref $host or $host eq "" or $host =~ /\0/u
ref $host or $host eq ""
MC/DC33%1/3
ref $host or $host eq "" or $host =~ /\0/u
ref $host
$host eq ""
$host =~ /\0/u
Truth table50%2/4
A or B or C
A= ref $hostB= $host eq ""C= $host =~ /\0/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | if ref($host) || $host eq '' || $host =~ /\0/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 9 | $port = _integer('connect():', 'port', $port, 0, 65535); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 9 | my $has_local_host = exists $option{local_host}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 9 | $local_host = delete $option{local_host}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 9 | my $has_local_port = exists $option{local_port}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | $local_port = $has_local_port ? _integer( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 9 | ▶ | 'connect():', 'local_port', delete($option{local_port}), 0, 65535, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | ) : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 9 | ▶ | $local_bind = $has_local_host || $has_local_port ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$has_local_host or $has_local_port
MC/DC100%2/2
$has_local_host or $has_local_port
$has_local_host
$has_local_port
Truth table100%3/3
A or B
A= $has_local_hostB= $has_local_port
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 9 | ▶ | if ($has_local_host) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 3 | ▶ | croak 'connect(): local_host must be a non-empty numeric IP address' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
not defined $local_host or ref $local_host or $local_host eq ""
not defined $local_host or ref $local_host
MC/DC0%0/3
not defined $local_host or ref $local_host or $local_host eq ""
not defined $local_host
ref $local_host
$local_host eq ""
Truth table25%1/4
not(A) or B or C
A= not defined $local_hostB= ref $local_hostC= $local_host eq ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | if !defined($local_host) || ref($local_host) || $local_host eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 3 | ▶ | croak 'connect(): local_host must be a numeric IPv4 or IPv6 address' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined inet_pton(2, $local_host) or defined inet_pton(10, $local_host)
MC/DC100%2/2
defined inet_pton(2, $local_host) or defined inet_pton(10, $local_host)
defined inet_pton(2, $local_host)
defined inet_pton(10, $local_host)
Truth table100%3/3
A or B
A= defined inet_pton(2, $local_host)B= defined inet_pton(10, $local_host)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | if !defined(inet_pton(AF_INET, $local_host)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | && !defined(inet_pton(AF_INET6, $local_host)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 2 | ▶ | $required_family = defined(inet_pton(AF_INET, $local_host)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | ? AF_INET : AF_INET6; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 2 | $required_family_option = 'local_host'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 8 | ▶ | if (defined $effective{v6only}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | croak 'connect(): local_host conflicts with v6only' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $required_family and $required_family != 10
MC/DC0%0/2
defined $required_family and $required_family != 10
defined $required_family
$required_family != 10
Truth table0%0/3
A and B
A= defined $required_familyB= $required_family != 10
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | if defined($required_family) && $required_family != AF_INET6; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | $required_family = AF_INET6; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | $required_family_option = 'v6only'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 8 | ▶ | if ($effective{broadcast}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | ▶ | croak 'connect(): local_host conflicts with broadcast' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $required_family and $required_family != 2
MC/DC0%0/2
defined $required_family and $required_family != 2
defined $required_family
$required_family != 2
Truth table0%0/3
A and B
A= defined $required_familyB= $required_family != 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | if defined($required_family) && $required_family != AF_INET; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 0 | $required_family = AF_INET; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | $required_family_option = 'broadcast'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 8 | my @invalid = grep { $supplied{$_} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | qw(fh unix local_unix unlink unlink_on_close permissions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | owns_socket); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 8 | ▶ | croak 'connect(): options not valid for UDP: ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | . join(', ', sort @invalid) if @invalid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 8 | ▶ | $needs_resolution = !defined(inet_pton(AF_INET, $host)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
defined inet_pton(2, $host) || defined inet_pton(10, $host)
MC/DC50%1/2
defined inet_pton(2, $host) || defined inet_pton(10, $host)
defined inet_pton(2, $host)
defined inet_pton(10, $host)
Truth table66%2/3
A || B
A= defined inet_pton(2, $host)B= defined inet_pton(10, $host)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | && !defined(inet_pton(AF_INET6, $host)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 8 | $owns_socket = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | ▶ | } elsif ($connect && exists $option{unix}) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$connect and exists $option{"unix"}
MC/DC0%0/2
$connect and exists $option{"unix"}
$connect
exists $option{"unix"}
Truth table33%1/3
A and B
A= $connectB= exists $option{"unix"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 5 | $path = delete $option{unix}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 5 | $local_path = delete $option{local_unix}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 5 | ▶ | croak 'connect(): unix must be a non-empty path without NUL bytes' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition44%4/9
not defined $path or ref $path or $path eq "" or $path =~ /\0/u
not defined $path or ref $path or $path eq ""
not defined $path or ref $path
MC/DC25%1/4
not defined $path or ref $path or $path eq "" or $path =~ /\0/u
not defined $path
ref $path
$path eq ""
$path =~ /\0/u
Truth table40%2/5
not(A) or B or C or D
A= not defined $pathB= ref $pathC= $path eq ""D= $path =~ /\0/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | if !defined($path) || ref($path) || $path eq '' || $path =~ /\0/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 4 | ▶ | croak 'connect(): local_unix must be a non-empty path without NUL bytes' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
defined $local_path and ref $local_path || $local_path eq "" || $local_path =~ /\0/u
ref $local_path or $local_path eq "" or $local_path =~ /\0/u
ref $local_path or $local_path eq ""
MC/DC50%2/4
defined $local_path and ref $local_path || $local_path eq "" || $local_path =~ /\0/u
defined $local_path
ref $local_path
$local_path eq ""
$local_path =~ /\0/u
Truth table60%3/5
A and B or C or D
A= defined $local_pathB= ref $local_pathC= $local_path eq ""D= $local_path =~ /\0/u
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | if defined($local_path) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | && (ref($local_path) || $local_path eq '' || $local_path =~ /\0/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 3 | my @invalid = grep { $supplied{$_} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | qw(fh host port local_host local_port bind_device v6only broadcast | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | reuseaddr reuseport owns_socket); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 3 | ▶ | push @invalid, grep { $supplied{$_} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | qw(unlink unlink_on_close permissions) if !defined $local_path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | push @invalid, 'broadcast' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 3 | ▶ | if $effective{broadcast} && !$supplied{broadcast}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$effective{"broadcast"} and not $supplied{"broadcast"}
MC/DC0%0/2
$effective{"broadcast"} and not $supplied{"broadcast"}
$effective{"broadcast"}
not $supplied{"broadcast"}
Truth table33%1/3
A and not(B)
A= $effective{"broadcast"}B= not $supplied{"broadcast"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | push @invalid, 'reuseaddr' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 3 | ▶ | if $effective{reuseaddr} && !$supplied{reuseaddr}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$effective{"reuseaddr"} and not $supplied{"reuseaddr"}
MC/DC0%0/2
$effective{"reuseaddr"} and not $supplied{"reuseaddr"}
$effective{"reuseaddr"}
not $supplied{"reuseaddr"}
Truth table33%1/3
A and not(B)
A= $effective{"reuseaddr"}B= not $supplied{"reuseaddr"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | push @invalid, 'reuseport' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 3 | ▶ | if $effective{reuseport} && !$supplied{reuseport}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$effective{"reuseport"} and not $supplied{"reuseport"}
MC/DC0%0/2
$effective{"reuseport"} and not $supplied{"reuseport"}
$effective{"reuseport"}
not $supplied{"reuseport"}
Truth table33%1/3
A and not(B)
A= $effective{"reuseport"}B= not $supplied{"reuseport"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | push @invalid, 'v6only' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 3 | ▶ | if defined($effective{v6only}) && !$supplied{v6only}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $effective{"v6only"} and not $supplied{"v6only"}
MC/DC0%0/2
defined $effective{"v6only"} and not $supplied{"v6only"}
defined $effective{"v6only"}
not $supplied{"v6only"}
Truth table33%1/3
A and not(B)
A= defined $effective{"v6only"}B= not $supplied{"v6only"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 3 | ▶ | croak 'connect(): options not valid for Unix datagrams: ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | . join(', ', sort @invalid) if @invalid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 1 | $owns_socket = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | ▶ | croak "$method(): exactly one socket source is required " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | . ($connect ? '(host/port or unix)' : '(fh, host/port, or unix)'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 26 | ▶ | my $validation_error = !$adopted && $owns_socket_supplied | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
not $adopted and $owns_socket_supplied
MC/DC0%0/2
not $adopted and $owns_socket_supplied
not $adopted
$owns_socket_supplied
Truth table66%2/3
not(A) and B
A= not $adoptedB= $owns_socket_supplied
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | ? "$method(): owns_socket is valid only with fh" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | : %option | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | ? "$method(): options not valid for this socket source: " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | . join(', ', sort keys %option) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 26 | ▶ | if (defined $validation_error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | if (!$adopted && defined $fh) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $adopted and defined $fh
MC/DC0%0/2
not $adopted and defined $fh
not $adopted
defined $fh
Truth table0%0/3
not(A) and B
A= not $adoptedB= defined $fh
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | ▶ | unlink $path if !$connect && defined($path) && -S $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not $connect and defined $path and -S $path
not $connect and defined $path
MC/DC0%0/3
not $connect and defined $path and -S $path
not $connect
defined $path
-S $path
Truth table0%0/4
not(A) and B and C
A= not $connectB= defined $pathC= -S $path
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | croak $validation_error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 26 | ▶ | my $self = bless { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | descriptor => $descriptor, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | options => \%effective, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | loop => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | fh => $fh, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | watcher => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | family_number => $family, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | local => $local, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | peer => $peer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | connected => $connect ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | host => $host, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | port => $port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | path => $path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | local_host => $local_host, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | local_port => $local_port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | local_bind => $local_bind ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | local_path => $local_path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | bind_device => $bind_device, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | required_family => $required_family, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | required_family_option => $required_family_option, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | needs_resolution => $needs_resolution ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | resolver => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | resolver_request => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | owns_socket => $owns_socket ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | unlink_existing => $unlink_existing, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | unlink_on_close => $unlink_on_close, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | permissions => $permissions, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | queue => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | pending_bytes => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | above_high => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | read_paused => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | state => 'unattached', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | last_error => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | ready_fired => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | ready_timer => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 26 | ▶ | if ($fh) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 17 | my $configured = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 17 | ▶ | $self->_apply_socket_policy($fh, $family) if $adopted; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 17 | ▶ | $self->_configure_socket( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
$peer // $local
MC/DC0%0/2
$peer // $local
$peer
$local
Truth table66%2/3
A // B
A= $peerB= $local
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | $fh, $adopted ? 'adopted' : 'bind', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | $adopted ? ($peer // $local) : $local, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 17 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 17 | ▶ | if (!$configured) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | ▶ | my $error = $@ || 'socket configuration failed'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$@ || 'socket configuration failed'
MC/DC0%0/1
$@ || 'socket configuration failed'
$@
Truth table0%0/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | ▶ | close $fh if $self->{owns_socket}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | unlink $path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | ▶ | if $self->{owns_socket} && defined($path) && -S $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$self->{"owns_socket"} and defined $path and -S $path
$self->{"owns_socket"} and defined $path
MC/DC0%0/3
$self->{"owns_socket"} and defined $path and -S $path
$self->{"owns_socket"}
defined $path
-S $path
Truth table0%0/4
A and B and C
A= $self->{"owns_socket"}B= defined $pathC= -S $path
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | $self->{fh} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 0 | die $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 26 | ▶ | $loop->add($self) if defined $loop; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 26 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 1 | ▶ | sub _message ($errno) { local $! = $errno; return "$!" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_message: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | ▶ | sub _setup_error ($operation, $errno, %field) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_setup_error: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | die Linux::Event::Error->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | type => 'setup', operation => $operation, errno => $errno, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | message => _message($errno), fatal => 1, %field, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 4 | ▶ | sub _set_adopted_flags ($fh) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_adopted_flags: called CC=5 SCAR=17.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 4 | my $status = fcntl($fh, F_GETFL, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 4 | ▶ | _setup_error('fcntl', 0 + $!) if !defined $status; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 4 | ▶ | fcntl($fh, F_SETFL, $status | O_NONBLOCK) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | or _setup_error('fcntl', 0 + $!); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 4 | my $descriptor = fcntl($fh, F_GETFD, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 4 | ▶ | _setup_error('fcntl', 0 + $!) if !defined $descriptor; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 4 | ▶ | fcntl($fh, F_SETFD, $descriptor | FD_CLOEXEC) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | or _setup_error('fcntl', 0 + $!); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 4 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 12 | ▶ | sub _create_bound_inet ($host, $port, $option, $bind_device) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_create_bound_inet: called CC=23 SCAR=46.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 12 | ▶ | my $node = $host eq '*' ? undef : $host; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 12 | my ($error, @candidate) = getaddrinfo( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | $node, $port, { socktype => SOCK_DGRAM, flags => AI_PASSIVE }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 12 | ▶ | die Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | type => 'resolve', operation => 'resolve', message => "$error", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | host => $host, port => $port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | ) if $error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 12 | my $last_errno = Errno::EADDRNOTAVAIL(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | 12 | my $compatible = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 12 | for my $candidate (@candidate) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | next if $candidate->{family} != AF_INET | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 12 | ▶ | && $candidate->{family} != AF_INET6; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$candidate->{"family"} != 2 and $candidate->{"family"} != 10
MC/DC0%0/2
$candidate->{"family"} != 2 and $candidate->{"family"} != 10
$candidate->{"family"} != 2
$candidate->{"family"} != 10
Truth table66%2/3
A and B
A= $candidate->{"family"} != 2B= $candidate->{"family"} != 10
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | next if defined($option->{v6only}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 12 | ▶ | && $candidate->{family} != AF_INET6; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $option->{"v6only"} and $candidate->{"family"} != 10
MC/DC100%2/2
defined $option->{"v6only"} and $candidate->{"family"} != 10
defined $option->{"v6only"}
$candidate->{"family"} != 10
Truth table100%3/3
A and B
A= defined $option->{"v6only"}B= $candidate->{"family"} != 10
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 11 | ▶ | next if $option->{broadcast} && $candidate->{family} != AF_INET; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$option->{"broadcast"} and $candidate->{"family"} != 2
MC/DC0%0/2
$option->{"broadcast"} and $candidate->{"family"} != 2
$option->{"broadcast"}
$candidate->{"family"} != 2
Truth table33%1/3
A and B
A= $option->{"broadcast"}B= $candidate->{"family"} != 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 11 | $compatible = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 11 | my $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 11 | ▶ | if (!socket($fh, $candidate->{family}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$candidate->{"protocol"} // 0
MC/DC0%0/1
$candidate->{"protocol"} // 0
$candidate->{"protocol"}
Truth table50%1/2
A
A= $candidate->{"protocol"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | SOCK_DGRAM | SOCK_NONBLOCK | SOCK_CLOEXEC, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | $candidate->{protocol} // 0)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | $last_errno = 0 + $!; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 11 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | _apply_creation_policy( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 11 | $fh, $candidate->{family}, $option, $bind_device, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | bind($fh, $candidate->{addr}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 11 | ▶ | or _setup_error('bind', 0 + $!, host => $host, port => $port); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 11 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 11 | ▶ | return ($fh, $candidate->{family}) if $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | my $failure = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | ▶ | die $failure if blessed($failure) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
builtin::blessed($failure) and $failure->isa("Linux::Event::Error") and $failure->type eq "socket_configuration"
builtin::blessed($failure) and $failure->isa("Linux::Event::Error")
MC/DC0%0/3
builtin::blessed($failure) and $failure->isa("Linux::Event::Error") and $failure->type eq "socket_configuration"
builtin::blessed($failure)
$failure->isa("Linux::Event::Error")
$failure->type eq "socket_configuration"
Truth table0%0/4
A and B and C
A= builtin::blessed($failure)B= $failure->isa("Linux::Event::Error")C= $failure->type eq "socket_configuration"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | && $failure->isa('Linux::Event::Error') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | && $failure->type eq 'socket_configuration'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | ▶ | $last_errno = blessed($failure) && defined($failure->errno) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($failure) and defined $failure->errno
MC/DC0%0/2
builtin::blessed($failure) and defined $failure->errno
builtin::blessed($failure)
defined $failure->errno
Truth table0%0/3
A and B
A= builtin::blessed($failure)B= defined $failure->errno
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | ? $failure->errno : 0 + $!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | die Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | type => 'socket_configuration', operation => 'setsockopt', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | option => 'v6only', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | message => 'v6only requires an IPv6 bind address', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | host => $host, port => $port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 1 | ▶ | ) if defined($option->{v6only}) && !$compatible; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $option->{"v6only"} and not $compatible
MC/DC0%0/2
defined $option->{"v6only"} and not $compatible
defined $option->{"v6only"}
not $compatible
Truth table33%1/3
A and not(B)
A= defined $option->{"v6only"}B= not $compatible
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | die Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | type => 'socket_configuration', operation => 'setsockopt', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | option => 'broadcast', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | message => 'broadcast requires an IPv4 bind address', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | host => $host, port => $port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | ▶ | ) if $option->{broadcast} && !$compatible; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$option->{"broadcast"} and not $compatible
MC/DC0%0/2
$option->{"broadcast"} and not $compatible
$option->{"broadcast"}
not $compatible
Truth table0%0/3
A and not(B)
A= $option->{"broadcast"}B= not $compatible
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | _setup_error('bind', $last_errno, host => $host, port => $port); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 3 | ▶ | sub _prepare_unix_path ($path, $unlink_existing) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prepare_unix_path: called CC=6 SCAR=30.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | 3 | ▶ | if (-e $path || -l $path) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
-e $path or -l $path
MC/DC0%0/2
-e $path or -l $path
-e $path
-l $path
Truth table33%1/3
A or B
A= -e $pathB= -l $path
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | ▶ | croak "Unix datagram path already exists: $path" if !$unlink_existing; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | ▶ | croak "refusing to unlink non-socket path: $path" if !-S $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | unlink($path) or _setup_error('unlink', 0 + $!, path => $path); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 2 | ▶ | sub _create_bound_unix ($path, $unlink_existing, $permissions, $option) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_create_bound_unix: called CC=7 SCAR=25.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 2 | _prepare_unix_path($path, $unlink_existing); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 2 | ▶ | socket(my $fh, AF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | or _setup_error('socket', 0 + $!, path => $path); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 2 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | Linux::Event::_SocketConfig::apply_policy($fh, AF_UNIX, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | send_buffer => $option->{send_buffer}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | receive_buffer => $option->{receive_buffer}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 2 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 2 | ▶ | bind($fh, pack_sockaddr_un($path)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | or _setup_error('bind', 0 + $!, path => $path); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 2 | ▶ | if (defined($permissions) && !chmod($permissions, $path)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $permissions and not chmod($permissions, $path)
MC/DC0%0/2
defined $permissions and not chmod($permissions, $path)
defined $permissions
not chmod($permissions, $path)
Truth table33%1/3
A and not(B)
A= defined $permissionsB= not chmod($permissions, $path)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | _setup_error('chmod', 0 + $!, path => $path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 2 | ▶ | if (!$ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | my $failure = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | ▶ | unlink $path if -S $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | die $failure; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 2 | return ($fh, AF_UNIX); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 1 | ▶ | sub _socket_option_error ($name, $errno, $message = undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_socket_option_error: called CC=5 SCAR=18.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 1 | $operation = 'setsockopt') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 1 | ▶ | die Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition40%2/5
$errno || undef
$message // _message($errno)
MC/DC0%0/1
$errno || undef
$errno
MC/DC0%0/2
$message // _message($errno)
$message
_message($errno)
Truth table50%1/2
A
A= $errno
Truth table33%1/3
A // B
A= $messageB= _message($errno)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | type => 'socket_configuration', operation => $operation, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | option => $name, errno => $errno || undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | message => $message // _message($errno), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 23 | ▶ | sub _apply_creation_policy ($fh, $family, $option, $bind_device) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_apply_creation_policy: called CC=11 SCAR=32.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 23 | for my $item ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | ['reuseaddr', SO_REUSEADDR, $option->{reuseaddr}], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | ['reuseport', SO_REUSEPORT, $option->{reuseport}], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | ['broadcast', SO_BROADCAST, $option->{broadcast}], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 69 | ▶ | next if !$item->[2]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | ▶ | _socket_option_error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$item->[0] eq "broadcast" and $family != 2
MC/DC0%0/2
$item->[0] eq "broadcast" and $family != 2
$item->[0] eq "broadcast"
$family != 2
Truth table0%0/3
A and B
A= $item->[0] eq "broadcast"B= $family != 2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 'broadcast', 0, 'broadcast is valid only for IPv4 sockets', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | ) if $item->[0] eq 'broadcast' && $family != AF_INET; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 0 | ▶ | setsockopt($fh, SOL_SOCKET, $item->[1], pack('i', 1)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | or _socket_option_error($item->[0], 0 + $!); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 23 | ▶ | if (defined($option->{v6only}) && $family != AF_INET6) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $option->{"v6only"} and $family != 10
MC/DC0%0/2
defined $option->{"v6only"} and $family != 10
defined $option->{"v6only"}
$family != 10
Truth table66%2/3
A and B
A= defined $option->{"v6only"}B= $family != 10
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | die Linux::Event::Error->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | type => 'socket_configuration', operation => 'setsockopt', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | option => 'v6only', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | message => 'v6only is valid only for IPv6 sockets', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 23 | ▶ | if (defined($option->{v6only})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | setsockopt($fh, IPPROTO_IPV6, IPV6_V6ONLY, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 1 | ▶ | pack('i', $option->{v6only})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | or _socket_option_error('v6only', 0 + $!); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | Linux::Event::_SocketConfig::apply_policy($fh, $family, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | send_buffer => $option->{send_buffer}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | receive_buffer => $option->{receive_buffer}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 23 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 23 | ▶ | Linux::Event::_SocketConfig::bind_device($fh, $bind_device) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | if defined $bind_device; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 23 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | 12 | ▶ | sub _apply_socket_policy ($self, $fh, $family) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_apply_socket_policy: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | _apply_creation_policy( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | $fh, $family, $self->{options}, $self->{bind_device}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 12 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 12 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 25 | ▶ | sub _configure_socket ($self, $fh, $role, $address) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_configure_socket: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 25 | my $callback = $self->{descriptor}{callbacks}{configure_socket}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 25 | ▶ | return if !$callback; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 2 | my $ok = eval { $callback->($self, $fh, $role, $address); 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 2 | ▶ | return if $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 1 | my $message = "$@"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 1 | $message =~ s/\s+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 1 | ▶ | die Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$message || 'configure_socket callback failed'
MC/DC0%0/1
$message || 'configure_socket callback failed'
$message
Truth table50%1/2
A
A= $message
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | type => 'socket_configuration', operation => 'configure_socket', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | message => $message || 'configure_socket callback failed', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 19 | ▶ | sub _attach_to_loop ($self, $loop) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_attach_to_loop: called CC=21 SCAR=35.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | croak 'add(): Datagram is not unattached' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 19 | ▶ | if $self->{state} ne 'unattached' || $self->{loop}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"state"} ne "unattached" or $self->{"loop"}
MC/DC0%0/2
$self->{"state"} ne "unattached" or $self->{"loop"}
$self->{"state"} ne "unattached"
$self->{"loop"}
Truth table33%1/3
A or B
A= $self->{"state"} ne "unattached"B= $self->{"loop"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 19 | $self->{loop} = $loop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 19 | ▶ | if ($self->{fh}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 11 | $self->{state} = 'active'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 11 | my $registered = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 11 | $self->_register; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 10 | $self->_schedule_ready; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 10 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 11 | ▶ | if (!$registered) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 1 | ▶ | my $failure = $@ || 'could not register Datagram socket'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$@ || 'could not register Datagram socket'
MC/DC0%0/1
$@ || 'could not register Datagram socket'
$@
Truth table50%1/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 1 | ▶ | if (my $timer = delete $self->{ready_timer}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | ▶ | $timer->cancel if !$timer->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 1 | ▶ | if (my $watcher = delete $self->{watcher}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 0 | $watcher->cancel; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 1 | $self->{state} = 'unattached'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 1 | $self->{loop} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 1 | ▶ | die $failure if blessed($failure) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($failure) and $failure->isa("Linux::Event::Error")
MC/DC0%0/2
builtin::blessed($failure) and $failure->isa("Linux::Event::Error")
builtin::blessed($failure)
$failure->isa("Linux::Event::Error")
Truth table33%1/3
A and B
A= builtin::blessed($failure)B= $failure->isa("Linux::Event::Error")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | && $failure->isa('Linux::Event::Error'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 1 | die Linux::Event::Error->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | type => 'setup', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | operation => 'watch', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | fatal => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | message => "$failure", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 10 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 8 | ▶ | if ($self->{needs_resolution}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 2 | $self->{state} = 'resolving'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 2 | my ($resolver, $id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 2 | my $submitted = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 2 | $resolver = Linux::Event::_Resolver->for_loop($loop); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 2 | $self->{resolver} = $resolver; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | $id = $resolver->submit( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 2 | $self, $self->{host}, $self->{port}, SOCK_DGRAM, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 2 | ▶ | if (!$submitted || !$id) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$submitted && $id
MC/DC0%0/2
$submitted && $id
$submitted
$id
Truth table33%1/3
A && B
A= $submittedB= $id
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | ▶ | my $message = "$@" || 'could not submit hostname resolution'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
"$@" || 'could not submit hostname resolution'
MC/DC0%0/1
"$@" || 'could not submit hostname resolution'
"$@"
Truth table0%0/2
A
A= "$@"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | $self->_fail(Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | type => 'resolve', operation => 'resolve', message => $message, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | host => $self->{host}, port => $self->{port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | )); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 2 | $self->{resolver_request} = $id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 6 | my $activated = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 6 | ▶ | if ($self->{path}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 1 | $self->_activate_unix; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 5 | my $packed4 = inet_pton(AF_INET, $self->{host}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 5 | my ($family, $sockaddr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 5 | ▶ | if (defined $packed4) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | 5 | $family = AF_INET; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 5 | $sockaddr = pack_sockaddr_in($self->{port}, $packed4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | $family = AF_INET6; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | $sockaddr = pack_sockaddr_in6( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | $self->{port}, inet_pton(AF_INET6, $self->{host}), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 5 | $self->_activate_inet_candidate({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | family => $family, protocol => 0, sockaddr => $sockaddr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 6 | ▶ | if (!$activated) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 2 | my $failure = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | my $error = blessed($failure) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | && $failure->isa('Linux::Event::Error') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | ? $failure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | : Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | type => 'connect', operation => 'connect', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | message => "$failure" || 'datagram connection failed', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | host => $self->{host}, port => $self->{port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | path => $self->{path}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 2 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition20%1/5
builtin::blessed($failure) and $failure->isa("Linux::Event::Error")
"$failure" || 'datagram connection failed'
MC/DC0%0/2
builtin::blessed($failure) and $failure->isa("Linux::Event::Error")
builtin::blessed($failure)
$failure->isa("Linux::Event::Error")
MC/DC0%0/1
"$failure" || 'datagram connection failed'
"$failure"
Truth table33%1/3
A and B
A= builtin::blessed($failure)B= $failure->isa("Linux::Event::Error")
Truth table0%0/2
A
A= "$failure"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 2 | $self->_fail($error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 6 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 2 | ▶ | sub _resolver_completed ($self, $result) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolver_completed: called CC=23 SCAR=45.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 2 | ▶ | return if $self->{state} ne 'resolving'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | return if !defined($self->{resolver_request}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 2 | ▶ | || $result->{id} != $self->{resolver_request}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $self->{"resolver_request"} or $result->{"id"} != $self->{"resolver_request"}
MC/DC0%0/2
not defined $self->{"resolver_request"} or $result->{"id"} != $self->{"resolver_request"}
not defined $self->{"resolver_request"}
$result->{"id"} != $self->{"resolver_request"}
Truth table33%1/3
not(A) or B
A= not defined $self->{"resolver_request"}B= $result->{"id"} != $self->{"resolver_request"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 2 | delete $self->{resolver_request}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 2 | delete $self->{resolver}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 2 | ▶ | if ($result->{error_code}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | $self->_fail(Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | type => 'resolve', operation => 'resolve', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | errno => $result->{system_errno} || undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | message => $result->{message} || 'hostname resolution failed', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | resolver_message => $result->{message}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | host => $self->{host}, port => $self->{port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | ▶ | )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/4
$result->{'system_errno'} || undef
$result->{'message'} || 'hostname resolution failed'
MC/DC0%0/1
$result->{'system_errno'} || undef
$result->{'system_errno'}
MC/DC0%0/1
$result->{'message'} || 'hostname resolution failed'
$result->{'message'}
Truth table0%0/2
A
A= $result->{'system_errno'}
Truth table0%0/2
A
A= $result->{'message'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 2 | my $last_error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 2 | my $compatible = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 2 | for my $candidate (@{ $result->{candidates} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | next if $candidate->{family} != AF_INET | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 3 | ▶ | && $candidate->{family} != AF_INET6; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$candidate->{"family"} != 2 and $candidate->{"family"} != 10
MC/DC0%0/2
$candidate->{"family"} != 2 and $candidate->{"family"} != 10
$candidate->{"family"} != 2
$candidate->{"family"} != 10
Truth table66%2/3
A and B
A= $candidate->{"family"} != 2B= $candidate->{"family"} != 10
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | next if defined($self->{required_family}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 3 | ▶ | && $candidate->{family} != $self->{required_family}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
defined $self->{"required_family"} and $candidate->{"family"} != $self->{"required_family"}
MC/DC100%2/2
defined $self->{"required_family"} and $candidate->{"family"} != $self->{"required_family"}
defined $self->{"required_family"}
$candidate->{"family"} != $self->{"required_family"}
Truth table100%3/3
A and B
A= defined $self->{"required_family"}B= $candidate->{"family"} != $self->{"required_family"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | 2 | $compatible = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 2 | my $ok = eval { $self->_activate_inet_candidate($candidate); 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | 2 | ▶ | return if $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 1 | $last_error = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 1 | ▶ | if (blessed($last_error) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
builtin::blessed($last_error) and $last_error->isa("Linux::Event::Error") and $last_error->type eq "socket_configuration" || $last_error->type eq "setup"
builtin::blessed($last_error) and $last_error->isa("Linux::Event::Error")
$last_error->type eq "socket_configuration" or $last_error->type eq "setup"
MC/DC0%0/4
builtin::blessed($last_error) and $last_error->isa("Linux::Event::Error") and $last_error->type eq "socket_configuration" || $last_error->type eq "setup"
builtin::blessed($last_error)
$last_error->isa("Linux::Event::Error")
$last_error->type eq "socket_configuration"
$last_error->type eq "setup"
Truth table20%1/5
A and B and C or D
A= builtin::blessed($last_error)B= $last_error->isa("Linux::Event::Error")C= $last_error->type eq "socket_configuration"D= $last_error->type eq "setup"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | && $last_error->isa('Linux::Event::Error') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | && ($last_error->type eq 'socket_configuration' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | || $last_error->type eq 'setup')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 1 | $self->_fail($last_error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | 0 | ▶ | if (defined($self->{required_family}) && !$compatible) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self->{"required_family"} and not $compatible
MC/DC0%0/2
defined $self->{"required_family"} and not $compatible
defined $self->{"required_family"}
not $compatible
Truth table0%0/3
A and not(B)
A= defined $self->{"required_family"}B= not $compatible
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 0 | my $option = $self->{required_family_option}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 0 | ▶ | my $message = $option eq 'local_host' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | ? 'local_host address family does not match any peer address' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | : "$option has no compatible peer address"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | $self->_fail(Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | type => 'socket_configuration', operation => 'bind', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | option => $option, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | message => $message, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | host => $self->{host}, port => $self->{port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | )); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | $self->_fail(blessed($last_error) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | && $last_error->isa('Linux::Event::Error') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | ? $last_error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | : Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | type => 'connect', operation => 'connect', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | message => "$last_error" || 'no compatible datagram address', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | host => $self->{host}, port => $self->{port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | ▶ | )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/5
builtin::blessed($last_error) and $last_error->isa("Linux::Event::Error")
"$last_error" || 'no compatible datagram address'
MC/DC0%0/2
builtin::blessed($last_error) and $last_error->isa("Linux::Event::Error")
builtin::blessed($last_error)
$last_error->isa("Linux::Event::Error")
MC/DC0%0/1
"$last_error" || 'no compatible datagram address'
"$last_error"
Truth table0%0/3
A and B
A= builtin::blessed($last_error)B= $last_error->isa("Linux::Event::Error")
Truth table0%0/2
A
A= "$last_error"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 7 | ▶ | sub _activate_inet_candidate ($self, $candidate) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_activate_inet_candidate: called CC=12 SCAR=25.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 7 | my $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | socket($fh, $candidate->{family}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | SOCK_DGRAM | SOCK_NONBLOCK | SOCK_CLOEXEC, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | $candidate->{protocol} // 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | or _setup_error('socket', 0 + $!, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 7 | ▶ | host => $self->{host}, port => $self->{port}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$candidate->{"protocol"} // 0
MC/DC0%0/1
$candidate->{"protocol"} // 0
$candidate->{"protocol"}
Truth table50%1/2
A
A= $candidate->{"protocol"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | 7 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 7 | $self->_apply_socket_policy($fh, $candidate->{family}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | $self->_configure_socket( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | 7 | $fh, 'connect', Linux::Event::Address->new($candidate->{sockaddr}), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 6 | ▶ | if ($self->{local_bind}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 3 | my $packed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 3 | ▶ | if (defined $self->{local_host}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 2 | $packed = inet_pton($candidate->{family}, $self->{local_host}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 2 | ▶ | die Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | type => 'socket_configuration', operation => 'bind', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | option => 'local_host', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | message => 'local_host address family does not match peer', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | ) if !defined $packed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | $packed = inet_pton( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | $candidate->{family}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | 1 | ▶ | $candidate->{family} == AF_INET ? '0.0.0.0' : '::', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | my $local = $candidate->{family} == AF_INET | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | ? pack_sockaddr_in($self->{local_port}, $packed) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 2 | ▶ | : pack_sockaddr_in6($self->{local_port}, $packed); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 2 | ▶ | if (!bind($fh, $local)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 1 | my $errno = 0 + $!; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | die Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | type => 'socket_configuration', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | operation => 'bind', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | option => defined($self->{local_host}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | ? 'local_host' : 'local_port', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | errno => $errno, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | message => _message($errno), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | host => $self->{local_host}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | port => $self->{local_port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 1 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | CORE::connect($fh, $candidate->{sockaddr}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | or _setup_error('connect', 0 + $!, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 4 | ▶ | host => $self->{host}, port => $self->{port}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 7 | ▶ | if (!$ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 3 | my $failure = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 3 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 3 | die $failure; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 4 | $self->_finish_activation($fh, $candidate->{family}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 4 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 1 | ▶ | sub _activate_unix ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_activate_unix: called CC=13 SCAR=36.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | 1 | my $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | socket($fh, AF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 1 | ▶ | or _setup_error('socket', 0 + $!, path => $self->{path}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 1 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 1 | $self->_apply_socket_policy($fh, AF_UNIX); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | $self->_configure_socket( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | $fh, 'connect', Linux::Event::Address->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 1 | pack_sockaddr_un($self->{path}), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 1 | ▶ | if (defined $self->{local_path}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 1 | _prepare_unix_path($self->{local_path}, $self->{unlink_existing}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | bind($fh, pack_sockaddr_un($self->{local_path})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 1 | ▶ | or _setup_error('bind', 0 + $!, path => $self->{local_path}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | chmod($self->{permissions}, $self->{local_path}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | or _setup_error('chmod', 0 + $!, path => $self->{local_path}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 1 | ▶ | if defined $self->{permissions}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition16%1/6
defined $self->{'permissions'} && (chmod($self->{'permissions'}, $self->{'local_path'}) || _setup_error('chmod', 0 + $!, 'path', $self->{'local_path'}))
chmod $self->{"permissions"}, $self->{"local_path"} or _setup_error("chmod", 0 + $!, "path", $self->{"local_path"})
MC/DC0%0/3
defined $self->{'permissions'} && (chmod($self->{'permissions'}, $self->{'local_path'}) || _setup_error('chmod', 0 + $!, 'path', $self->{'local_path'}))
defined $self->{'permissions'}
chmod $self->{"permissions"}, $self->{"local_path"}
_setup_error("chmod", 0 + $!, "path", $self->{"local_path"})
Truth table0%0/4
A && B or C
A= defined $self->{'permissions'}B= chmod $self->{"permissions"}, $self->{"local_path"}C= _setup_error("chmod", 0 + $!, "path", $self->{"local_path"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | CORE::connect($fh, pack_sockaddr_un($self->{path})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 1 | ▶ | or _setup_error('connect', 0 + $!, path => $self->{path}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 1 | ▶ | if (!$ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | my $failure = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | unlink $self->{local_path} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 0 | ▶ | if defined($self->{local_path}) && -S $self->{local_path}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self->{"local_path"} and -S $self->{"local_path"}
MC/DC0%0/2
defined $self->{"local_path"} and -S $self->{"local_path"}
defined $self->{"local_path"}
-S $self->{"local_path"}
Truth table0%0/3
A and B
A= defined $self->{"local_path"}B= -S $self->{"local_path"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 0 | die $failure; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 1 | my $activated = eval { $self->_finish_activation($fh, AF_UNIX); 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 1 | ▶ | if (!$activated) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 0 | my $failure = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | unlink $self->{local_path} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 0 | ▶ | if defined($self->{local_path}) && -S $self->{local_path}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $self->{"local_path"} and -S $self->{"local_path"}
MC/DC0%0/2
defined $self->{"local_path"} and -S $self->{"local_path"}
defined $self->{"local_path"}
-S $self->{"local_path"}
Truth table0%0/3
A and B
A= defined $self->{"local_path"}B= -S $self->{"local_path"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 0 | die $failure; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | 5 | ▶ | sub _finish_activation ($self, $fh, $family) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_finish_activation: called CC=9 SCAR=35.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 5 | my $previous_state = $self->{state}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 5 | $self->{fh} = $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | 5 | $self->{family_number} = $family; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 5 | my $activated = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 5 | $self->{local} = Linux::Event::Address->new(getsockname($fh)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 5 | $self->{peer} = Linux::Event::Address->new(getpeername($fh)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 5 | $self->{state} = 'active'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 5 | $self->_register; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 5 | $self->_schedule_ready; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | 5 | $self->_flush_output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 5 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | 5 | ▶ | return if $activated; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 0 | ▶ | my $failure = $@ || 'could not register Datagram socket'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$@ || 'could not register Datagram socket'
MC/DC0%0/1
$@ || 'could not register Datagram socket'
$@
Truth table0%0/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 0 | ▶ | if (my $timer = delete $self->{ready_timer}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | ▶ | $timer->cancel if $timer->is_active; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | 0 | ▶ | if (my $watcher = delete $self->{watcher}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 0 | $watcher->cancel; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | ▶ | close delete $self->{fh} if $self->{fh}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 0 | $self->{family_number} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 0 | $self->{local} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 0 | $self->{peer} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 0 | $self->{state} = $previous_state; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 0 | ▶ | die $failure if blessed($failure) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
builtin::blessed($failure) and $failure->isa("Linux::Event::Error")
MC/DC0%0/2
builtin::blessed($failure) and $failure->isa("Linux::Event::Error")
builtin::blessed($failure)
$failure->isa("Linux::Event::Error")
Truth table0%0/3
A and B
A= builtin::blessed($failure)B= $failure->isa("Linux::Event::Error")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | && $failure->isa('Linux::Event::Error'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | die Linux::Event::Error->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | type => 'setup', operation => 'watch', fatal => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | message => "$failure", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 16 | ▶ | sub _register ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_register: called CC=5 SCAR=17.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 16 | ▶ | return if !$self->{loop} || !$self->{fh}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"loop"} and $self->{"fh"}
MC/DC0%0/2
$self->{"loop"} and $self->{"fh"}
$self->{"loop"}
$self->{"fh"}
Truth table33%1/3
A and B
A= $self->{"loop"}B= $self->{"fh"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | $self->{watcher} = $self->{loop}->watch( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | fh => $self->{fh}, _internal => 1, data => $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | read => \&_read_ready, write => \&_write_ready, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | error => \&_error_ready, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | edge_triggered => $self->{options}{edge_triggered}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 16 | _callback_data_arg => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 15 | ▶ | $self->{watcher}->disable_write if !@{ $self->{queue} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 15 | ▶ | $self->{watcher}->disable_read if $self->{read_paused}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 15 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 15 | ▶ | sub _schedule_ready ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_schedule_ready: called CC=3 SCAR=11.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 15 | ▶ | return if $self->{ready_fired} || !$self->{loop}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"ready_fired"} or not $self->{"loop"}
MC/DC0%0/2
$self->{"ready_fired"} or not $self->{"loop"}
$self->{"ready_fired"}
not $self->{"loop"}
Truth table33%1/3
A or not(B)
A= $self->{"ready_fired"}B= not $self->{"loop"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 15 | my $timer = Linux::Event::_Socket::Dgram::_ReadyTimer->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | after => 0, data => $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 15 | $self->{ready_timer} = $timer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 15 | $self->{loop}->add($timer); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 15 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 9 | ▶ | sub _fire_ready ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fire_ready: called CC=4 SCAR=14.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 9 | delete $self->{ready_timer}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 9 | ▶ | return if $self->{state} ne 'active' || $self->{ready_fired}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"state"} ne "active" or $self->{"ready_fired"}++
MC/DC0%0/2
$self->{"state"} ne "active" or $self->{"ready_fired"}++
$self->{"state"} ne "active"
$self->{"ready_fired"}++
Truth table33%1/3
A or B
A= $self->{"state"} ne "active"B= $self->{"ready_fired"}++
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 9 | my $callback = $self->{descriptor}{callbacks}{on_ready}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 9 | ▶ | $callback->($self) if $callback; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 9 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 5 | ▶ | sub _report ($self, $error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_report: called CC=2 SCAR=7.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | 5 | $self->{last_error} = $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 5 | ▶ | if (my $callback = $self->{descriptor}{callbacks}{on_error}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 5 | $callback->($self, $error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 0 | warn "$error\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 5 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 3 | ▶ | sub _fail ($self, $error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fail: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 3 | ▶ | return if $self->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 3 | $self->{last_error} = $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | 3 | $self->_shutdown('failed', 0, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 3 | my $reported = eval { $self->_report($error); 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 3 | my $failure = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 3 | $self->{descriptor} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 3 | $self->{loop} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | 3 | ▶ | die $failure if !$reported; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 84 | ▶ | sub _read_ready ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read_ready: called CC=9 SCAR=24.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 84 | ▶ | return if $self->{state} ne 'active' || $self->{read_paused}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"state"} ne "active" or $self->{"read_paused"}
MC/DC0%0/2
$self->{"state"} ne "active" or $self->{"read_paused"}
$self->{"state"} ne "active"
$self->{"read_paused"}
Truth table33%1/3
A or B
A= $self->{"state"} ne "active"B= $self->{"read_paused"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | my $batch = Linux::Event::_Socket::Dgram::_recv_batch( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | fileno($self->{fh}), $self->{options}{max_datagram_size}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | $self->{options}{max_datagrams_per_tick}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 84 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 84 | my $errno = $batch->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | 84 | ▶ | for (my $at = 1; $at < @$batch; $at += 4) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 86 | ▶ | last if $self->{state} ne 'active' || $self->{read_paused}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"state"} ne "active" or $self->{"read_paused"}
MC/DC0%0/2
$self->{"state"} ne "active" or $self->{"read_paused"}
$self->{"state"} ne "active"
$self->{"read_paused"}
Truth table33%1/3
A or B
A= $self->{"state"} ne "active"B= $self->{"read_paused"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 86 | my ($payload, $sockaddr, $length, $truncated) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | = @$batch[$at .. $at + 3]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 86 | my $peer = Linux::Event::Address->new($sockaddr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 86 | ▶ | if ($truncated) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | $self->_report(Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | type => 'datagram_size', operation => 'receive', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | message => "received datagram exceeds " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | . "$self->{options}{max_datagram_size} bytes", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | datagram_size => $length, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | limit => $self->{options}{max_datagram_size}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 1 | )); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 85 | $self->{descriptor}{callbacks}{on_datagram}->($self, $payload, $peer); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 84 | ▶ | if ($errno && $self->{state} eq 'active') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$errno and $self->{"state"} eq "active"
MC/DC0%0/2
$errno and $self->{"state"} eq "active"
$errno
$self->{"state"} eq "active"
Truth table33%1/3
A and B
A= $errnoB= $self->{"state"} eq "active"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | 0 | $self->_report(Linux::Event::Error->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | type => 'io', operation => 'receive', errno => $errno, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | message => _message($errno), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 84 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 88 | ▶ | sub send ($self, $payload, %option) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send: called CC=23 SCAR=41.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 88 | ▶ | croak 'send(): Datagram is terminal' if $self->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | 88 | ▶ | croak 'send(): payload must be a defined scalar' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not defined $payload or ref $payload
MC/DC0%0/2
not defined $payload or ref $payload
not defined $payload
ref $payload
Truth table33%1/3
not(A) or B
A= not defined $payloadB= ref $payload
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | if !defined($payload) || ref($payload); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | 88 | $payload = "$payload"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 88 | ▶ | croak 'send(): payload must be a byte string' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | if !utf8::downgrade($payload, 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | croak "send(): payload exceeds $self->{options}{max_datagram_size} bytes" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 87 | ▶ | if length($payload) > $self->{options}{max_datagram_size}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 87 | my $to = delete $option{to}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 87 | ▶ | croak 'send(): unknown options: ' . join(', ', sort keys %option) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | if %option; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 87 | ▶ | if ($self->{connected}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | 25 | ▶ | croak 'send(): to is not valid for a connected Datagram' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | if defined $to; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | 62 | ▶ | croak 'send(): to requires a Linux::Event::Address' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
builtin::blessed($to) and $to->isa("Linux::Event::Address")
MC/DC0%0/2
builtin::blessed($to) and $to->isa("Linux::Event::Address")
builtin::blessed($to)
$to->isa("Linux::Event::Address")
Truth table33%1/3
A and B
A= builtin::blessed($to)B= $to->isa("Linux::Event::Address")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | if !blessed($to) || !$to->isa('Linux::Event::Address'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 87 | ▶ | my $address = defined($to) ? $to->sockaddr : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | 87 | ▶ | croak 'send(): destination Address has no packed socket address' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
defined $to and !defined($address) || ref $address
not defined $address or ref $address
MC/DC0%0/3
defined $to and !defined($address) || ref $address
defined $to
not defined $address
ref $address
Truth table50%2/4
A and not(B) or C
A= defined $toB= not defined $addressC= ref $address
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | if defined($to) && (!defined($address) || ref($address)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | return $self->_queue_packet($payload, $address) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | 87 | ▶ | if !$self->{fh} || @{ $self->{queue} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $self->{"fh"} or @{$self->{"queue"};}
MC/DC50%1/2
not $self->{"fh"} or @{$self->{"queue"};}
not $self->{"fh"}
@{$self->{"queue"};}
Truth table66%2/3
not(A) or B
A= not $self->{"fh"}B= @{$self->{"queue"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | my ($sent, $errno) = Linux::Event::_Socket::Dgram::_send_packet( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | 85 | ▶ | fileno($self->{fh}), $payload, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | defined($address) ? $address : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | 85 | ▶ | return 1 if $sent == length($payload); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | 0 | ▶ | if ($errno == Errno::EAGAIN() || $errno == Errno::EWOULDBLOCK() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$errno == 11 or $errno == 11 or $errno == 105
$errno == 11 or $errno == 11
MC/DC0%0/3
$errno == 11 or $errno == 11 or $errno == 105
$errno == 11
$errno == 11
$errno == 105
Truth table0%0/4
A or B or C
A= $errno == 11B= $errno == 11C= $errno == 105
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | || $errno == Errno::ENOBUFS()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | 0 | return $self->_queue_packet($payload, $address); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 0 | ▶ | $self->_report(Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | type => 'io', operation => 'send', errno => $errno, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | message => $errno ? _message($errno) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | : "short datagram send ($sent of " . length($payload) . ' bytes)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 2 | ▶ | sub _queue_packet ($self, $payload, $address) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_queue_packet: called CC=10 SCAR=25.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 2 | my $bytes = $self->{pending_bytes} + length($payload); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 2 | my $datagrams = @{ $self->{queue} } + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | 2 | my $byte_limit = $self->{options}{max_pending_bytes}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 2 | my $packet_limit = $self->{options}{max_pending_datagrams}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | 2 | ▶ | if (($byte_limit && $bytes > $byte_limit) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition55%5/9
$byte_limit and $bytes > $byte_limit or $packet_limit and $datagrams > $packet_limit
$byte_limit and $bytes > $byte_limit
$packet_limit and $datagrams > $packet_limit
MC/DC25%1/4
$byte_limit and $bytes > $byte_limit or $packet_limit and $datagrams > $packet_limit
$byte_limit
$bytes > $byte_limit
$packet_limit
$datagrams > $packet_limit
Truth table28%2/7
A and B or C and D
A= $byte_limitB= $bytes > $byte_limitC= $packet_limitD= $datagrams > $packet_limit
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | || ($packet_limit && $datagrams > $packet_limit)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | 1 | ▶ | my $limit = $byte_limit && $bytes > $byte_limit | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$byte_limit and $bytes > $byte_limit
MC/DC0%0/2
$byte_limit and $bytes > $byte_limit
$byte_limit
$bytes > $byte_limit
Truth table33%1/3
A and B
A= $byte_limitB= $bytes > $byte_limit
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | ? $byte_limit : $packet_limit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 1 | $self->_report(Linux::Event::Error->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | type => 'output_limit', operation => 'send', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | message => 'pending datagram output limit would be exceeded', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | pending_bytes => $bytes, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | pending_datagrams => $datagrams, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | limit => $limit, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | 1 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | 1 | push @{ $self->{queue} }, [$payload, $address]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | 1 | $self->{pending_bytes} = $bytes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | 1 | ▶ | if ($bytes > $self->{options}{high_watermark}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | 0 | $self->{above_high} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 1 | ▶ | $self->{watcher}->enable_write if $self->{watcher}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 1 | ▶ | return $self->{above_high} ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 0 | ▶ | sub _write_ready ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_write_ready: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | 0 | ▶ | return if $self->{state} ne 'active'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | 0 | $self->_flush_output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | 5 | ▶ | sub _flush_output ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_flush_output: called CC=15 SCAR=41.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | 5 | ▶ | return if !$self->{fh}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | 5 | ▶ | while (my $packet = $self->{queue}[0]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | 1 | my ($payload, $address) = @$packet; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | my ($sent, $errno) = Linux::Event::_Socket::Dgram::_send_packet( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | 1 | ▶ | fileno($self->{fh}), $payload, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | defined($address) ? $address : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | 1 | ▶ | if ($sent == length($payload)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | 1 | shift @{ $self->{queue} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | 1 | $self->{pending_bytes} -= length($payload); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | 0 | ▶ | last if $errno == Errno::EAGAIN() || $errno == Errno::EWOULDBLOCK() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$errno == 11 or $errno == 11 or $errno == 105
$errno == 11 or $errno == 11
MC/DC0%0/3
$errno == 11 or $errno == 11 or $errno == 105
$errno == 11
$errno == 11
$errno == 105
Truth table0%0/4
A or B or C
A= $errno == 11B= $errno == 11C= $errno == 105
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | || $errno == Errno::ENOBUFS(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | 0 | shift @{ $self->{queue} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | 0 | $self->{pending_bytes} -= length($payload); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 0 | ▶ | $self->_report(Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | type => 'io', operation => 'send', errno => $errno, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | message => $errno ? _message($errno) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | : "short datagram send ($sent of " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | . length($payload) . ' bytes)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | 0 | ▶ | last if $self->{state} ne 'active'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | $self->{watcher}->disable_write | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | 5 | ▶ | if $self->{watcher} && !@{ $self->{queue} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"watcher"} and not @{$self->{"queue"};}
MC/DC0%0/2
$self->{"watcher"} and not @{$self->{"queue"};}
$self->{"watcher"}
not @{$self->{"queue"};}
Truth table33%1/3
A and not(B)
A= $self->{"watcher"}B= not @{$self->{"queue"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 5 | ▶ | if ($self->{above_high} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"above_high"} and $self->{"pending_bytes"} <= $self->{"options"}{"low_watermark"}
MC/DC0%0/2
$self->{"above_high"} and $self->{"pending_bytes"} <= $self->{"options"}{"low_watermark"}
$self->{"above_high"}
$self->{"pending_bytes"} <= $self->{"options"}{"low_watermark"}
Truth table33%1/3
A and B
A= $self->{"above_high"}B= $self->{"pending_bytes"} <= $self->{"options"}{"low_watermark"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | && $self->{pending_bytes} <= $self->{options}{low_watermark}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 0 | $self->{above_high} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | 0 | my $callback = $self->{descriptor}{callbacks}{on_drain}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | 0 | ▶ | $callback->($self) if $callback; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | 5 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 0 | ▶ | sub _error_ready ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_error_ready: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | 0 | ▶ | return if $self->{state} ne 'active'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | 0 | my $packed = getsockopt($self->{fh}, SOL_SOCKET, SO_ERROR); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | 0 | ▶ | my $errno = defined($packed) && length($packed) >= 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $packed and length $packed >= 4
MC/DC0%0/2
defined $packed and length $packed >= 4
defined $packed
length $packed >= 4
Truth table0%0/3
A and B
A= defined $packedB= length $packed >= 4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | ? unpack('i', $packed) : 0 + $!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | 0 | ▶ | $self->_report(Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
$errno || undef
MC/DC0%0/1
$errno || undef
$errno
Truth table0%0/2
A
A= $errno
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | type => 'io', operation => 'socket', errno => $errno || undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | message => $errno ? _message($errno) : 'datagram socket error', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | 0 | ▶ | sub _fork_preflight ($self, $mode, $loop) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fork_preflight: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | 0 | ▶ | croak "fork(): Datagram does not support '$mode'" if $mode ne 'drop'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | croak 'fork(): Datagram must be active before fork' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | if $self->{state} ne 'active' || !$self->{loop} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | 0 | ▶ | || Scalar::Util::refaddr($self->{loop}) != Scalar::Util::refaddr($loop); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$self->{"state"} ne "active" or not $self->{"loop"} or builtin::refaddr($self->{"loop"}) != builtin::refaddr($loop)
$self->{"state"} ne "active" or not $self->{"loop"}
MC/DC0%0/3
$self->{"state"} ne "active" or not $self->{"loop"} or builtin::refaddr($self->{"loop"}) != builtin::refaddr($loop)
$self->{"state"} ne "active"
not $self->{"loop"}
builtin::refaddr($self->{"loop"}) != builtin::refaddr($loop)
Truth table0%0/4
A or not(B) or C
A= $self->{"state"} ne "active"B= not $self->{"loop"}C= builtin::refaddr($self->{"loop"}) != builtin::refaddr($loop)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | 0 | ▶ | sub _fork_child_drop ($self, $loop) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fork_child_drop: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | 0 | $self->{watcher} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | 0 | delete $self->{resolver_request}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | 0 | delete $self->{resolver}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | 0 | ▶ | if (my $timer = delete $self->{ready_timer}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | 0 | ▶ | eval { $timer->cancel; 1 } if !$timer->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | 0 | ▶ | if (my $fh = delete $self->{fh}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | 0 | ▶ | close $fh if $self->{owns_socket}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | 0 | $self->{unlink_on_close} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | 0 | $self->{queue} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | 0 | $self->{pending_bytes} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 0 | $self->{above_high} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 0 | $self->{loop} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | 0 | $self->{descriptor} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | 0 | $self->{state} = 'not_inherited'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | 27 | ▶ | sub _shutdown ($self, $state, $fire_close = 1, $retain_loop = 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_shutdown: called CC=20 SCAR=30.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 27 | ▶ | return if $self->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 26 | $self->{state} = $state; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 26 | my $request = delete $self->{resolver_request}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | 26 | my $resolver = delete $self->{resolver}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | 26 | ▶ | $resolver->cancel($request) if $resolver && defined $request; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$resolver and defined $request
MC/DC0%0/2
$resolver and defined $request
$resolver
defined $request
Truth table33%1/3
A and B
A= $resolverB= defined $request
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | 26 | ▶ | if (my $timer = delete $self->{ready_timer}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | 6 | ▶ | $timer->cancel if $timer->is_active; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | 26 | ▶ | if (my $watcher = delete $self->{watcher}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 15 | $watcher->cancel; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | 26 | ▶ | if (my $fh = delete $self->{fh}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | 22 | ▶ | close $fh if $self->{owns_socket}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | my $remove_path = $self->{connected} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | 26 | ▶ | ? $self->{local_path} : $self->{path}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | unlink $remove_path if $self->{unlink_on_close} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | 26 | ▶ | && defined($remove_path) && -S $remove_path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$self->{"unlink_on_close"} and defined $remove_path and -S $remove_path
$self->{"unlink_on_close"} and defined $remove_path
MC/DC66%2/3
$self->{"unlink_on_close"} and defined $remove_path and -S $remove_path
$self->{"unlink_on_close"}
defined $remove_path
-S $remove_path
Truth table75%3/4
A and B and C
A= $self->{"unlink_on_close"}B= defined $remove_pathC= -S $remove_path
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | 26 | $self->{queue} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | 26 | $self->{pending_bytes} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | 26 | my ($called, $failure) = (1, undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | 26 | ▶ | if ($fire_close && (my $callback = $self->{descriptor}{callbacks}{on_close})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$fire_close and my $callback = $self->{"descriptor"}{"callbacks"}{"on_close"}
MC/DC100%2/2
$fire_close and my $callback = $self->{"descriptor"}{"callbacks"}{"on_close"}
$fire_close
my $callback = $self->{"descriptor"}{"callbacks"}{"on_close"}
Truth table100%3/3
A and B
A= $fire_closeB= my $callback = $self->{"descriptor"}{"callbacks"}{"on_close"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | 5 | $called = eval { $callback->($self); 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 5 | $failure = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | 26 | ▶ | $self->{descriptor} = undef if !$retain_loop; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | 26 | ▶ | $self->{loop} = undef if !$retain_loop; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | 26 | ▶ | die $failure if !$called; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | 26 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | 23 | ▶ | sub close ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
close: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | 23 | $self->_shutdown('closed'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | 23 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 1 | ▶ | sub detach ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
detach: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | 1 | ▶ | croak 'detach(): Datagram has no active socket' if !$self->{fh}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | 1 | my $fh = $self->{fh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | 1 | $self->{owns_socket} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | 1 | $self->{unlink_on_close} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | 1 | $self->_shutdown('detached', 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | 1 | return $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | 1 | ▶ | sub pause_read ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pause_read: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | 1 | ▶ | return $self if $self->{read_paused}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | 1 | $self->{read_paused} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | 1 | ▶ | $self->{watcher}->disable_read if $self->{watcher}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | 1 | ▶ | sub resume_read ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resume_read: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | 1 | ▶ | return $self if !$self->{read_paused}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | 1 | $self->{read_paused} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | 1 | ▶ | $self->{watcher}->enable_read if $self->{watcher}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | 2 | ▶ | sub _buffer_option ($self, $name, @argument) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_buffer_option: called CC=4 SCAR=14.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | 2 | ▶ | croak "$name(): Datagram has no active socket" if !$self->{fh}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | 2 | ▶ | croak "$name(): expected zero or one argument" if @argument > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | Linux::Event::_SocketConfig::set_option( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | 2 | ▶ | $self->{fh}, $self->{family_number}, $name, $argument[0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | ) if @argument; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | return Linux::Event::_SocketConfig::get_option( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | 2 | $self->{fh}, $self->{family_number}, $name, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | 1 | ▶ | sub send_buffer ($self, @argument) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_buffer: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | 1 | return $self->_buffer_option('send_buffer', @argument); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | 1 | ▶ | sub receive_buffer ($self, @argument) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
receive_buffer: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | 1 | return $self->_buffer_option('receive_buffer', @argument); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | 3 | ▶ | sub broadcast ($self, @argument) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
broadcast: called CC=9 SCAR=23.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | 3 | ▶ | croak 'broadcast(): Datagram has no active socket' if !$self->{fh}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | 3 | ▶ | croak 'broadcast(): expected zero or one argument' if @argument > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | _socket_option_error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | 'broadcast', 0, 'broadcast is valid only for IPv4 sockets', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | @argument ? 'setsockopt' : 'getsockopt', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | 3 | ▶ | ) if $self->{family_number} != AF_INET; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | 2 | ▶ | if (@argument) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | 2 | my $value = _boolean('broadcast():', 'value', $argument[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | 2 | ▶ | setsockopt($self->{fh}, SOL_SOCKET, SO_BROADCAST, pack('i', $value)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | or die Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | type => 'socket_configuration', operation => 'setsockopt', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | option => 'broadcast', errno => 0 + $!, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | message => _message(0 + $!), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | 2 | my $packed = getsockopt($self->{fh}, SOL_SOCKET, SO_BROADCAST); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | 2 | ▶ | die Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | type => 'socket_configuration', operation => 'getsockopt', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | option => 'broadcast', errno => 0 + $!, message => _message(0 + $!), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | ) if !defined $packed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | 2 | ▶ | return unpack('i', $packed) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | 0 | ▶ | sub fh ($self) { $self->{fh} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fh: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | 4 | ▶ | sub fd ($self) { $self->{fh} ? fileno($self->{fh}) : undef } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fd: called CC=2 SCAR=7.6
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | 35 | ▶ | sub loop ($self) { $self->{loop} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
loop: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | 12 | ▶ | sub local ($self) { $self->{local} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
local: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | 4 | ▶ | sub peer ($self) { $self->{peer} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
peer: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | 5 | ▶ | sub is_connected ($self) { !!$self->{connected} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_connected: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | 8 | ▶ | sub state ($self) { $self->{state} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
state: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | 0 | ▶ | sub last_error ($self) { $self->{last_error} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
last_error: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | 4 | ▶ | sub pending_bytes ($self) { $self->{pending_bytes} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pending_bytes: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | 6 | ▶ | sub pending_datagrams ($self) { scalar @{ $self->{queue} } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pending_datagrams: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | 5 | ▶ | sub is_read_paused ($self) { !!$self->{read_paused} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_read_paused: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | 2 | ▶ | sub is_active ($self) { $self->{state} eq 'active' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_active: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | 173 | ▶ | sub is_terminal ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_terminal: called CC=5 SCAR=16.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | return $self->{state} eq 'closed' || $self->{state} eq 'failed' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | || $self->{state} eq 'detached' || $self->{state} eq 'not_inherited' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | 173 | ▶ | || $self->{state} eq 'moved'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition83%10/12
$self->{'state'} eq 'closed' || $self->{'state'} eq 'failed' || $self->{'state'} eq 'detached' || $self->{'state'} eq 'not_inherited' || $self->{'state'} eq 'moved'
$self->{"state"} eq "closed" or $self->{"state"} eq "failed" or $self->{"state"} eq "detached" or $self->{"state"} eq "not_inherited"
$self->{"state"} eq "closed" or $self->{"state"} eq "failed" or $self->{"state"} eq "detached"
$self->{"state"} eq "closed" or $self->{"state"} eq "failed"
MC/DC60%3/5
$self->{'state'} eq 'closed' || $self->{'state'} eq 'failed' || $self->{'state'} eq 'detached' || $self->{'state'} eq 'not_inherited' || $self->{'state'} eq 'moved'
$self->{"state"} eq "closed"
$self->{"state"} eq "failed"
$self->{"state"} eq "detached"
$self->{"state"} eq "not_inherited"
$self->{'state'} eq 'moved'
Truth table66%4/6
A or B or C or D || E
A= $self->{"state"} eq "closed"B= $self->{"state"} eq "failed"C= $self->{"state"} eq "detached"D= $self->{"state"} eq "not_inherited"E= $self->{'state'} eq 'moved'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | 42 | ▶ | sub data ($self, @argument) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
data: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | 42 | ▶ | $self->{data} = $argument[0] if @argument; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | 42 | return $self->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | 0 | ▶ | sub CLONE_SKIP ($class) { 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CLONE_SKIP: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | 26 | ▶ | sub DESTROY ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | 0 | ▶ | eval { $self->_shutdown('closed', 0) } if !$self->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | 26 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | package Linux::Event::_Socket::Dgram::_ReadyTimer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | 11 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | 11 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | 11 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | 11 | ▶ | use parent -norequire, 'Linux::Event::Kernel::Timer'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | 9 | ▶ | sub on_timer ($timer) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
on_timer: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | 9 | my $datagram = $timer->data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | 9 | ▶ | $datagram->_fire_ready if $datagram; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | 9 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | 11 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||