| 1 | package Linux::Event::Datagram; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 8 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 8 | our $VERSION = '0.105'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 8 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 8 | ▶ | use Config (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 8 | ▶ | use Errno (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 8 | ▶ | use Fcntl qw(F_GETFD F_GETFL F_SETFD F_SETFL FD_CLOEXEC O_NONBLOCK); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 8 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 8 | ▶ | 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 | 8 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 8 | ▶ | use utf8 (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 8 | ▶ | use Linux::Event::Address; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 8 | ▶ | use Linux::Event::Error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 8 | ▶ | use Linux::Event::_SocketConfig (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 8 | ▶ | use Linux::Event::_Resolver (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 8 | require Linux::Event::Timer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 8 | require XSLoader; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 8 | XSLoader::load(__PACKAGE__, $VERSION); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 8 | my %CLASS_DESCRIPTOR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 8 | ▶ | my $MAX_INTEGER = $Config::Config{ivsize} >= 8 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | ? '9223372036854775807' : '2147483647'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 318 | ▶ | sub _integer ($target, $name, $value, $minimum, $maximum = undef) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_integer: called CC=10 SCAR=23.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 318 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | if !defined($value) || ref($value) || $value !~ /\A\d+\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 317 | ▶ | $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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 317 | my $digits = "$value"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 317 | $digits =~ s/\A0+(?=\d)//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 317 | ▶ | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | if length($digits) > length("$maximum") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | || (length($digits) == length("$maximum") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | && $digits gt "$maximum"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 316 | $value = 0 + $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 316 | ▶ | croak "$target $name must be at least $minimum" if $value < $minimum; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 316 | return $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 201 | ▶ | sub _boolean ($target, $name, $value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_boolean: called CC=5 SCAR=19.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 201 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | if !defined($value) || ref($value) || $value !~ /\A[01]\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 201 | ▶ | return $value ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 40 | ▶ | sub _descriptor_for ($class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_descriptor_for: called CC=18 SCAR=30.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 40 | ▶ | return $CLASS_DESCRIPTOR{$class} if exists $CLASS_DESCRIPTOR{$class}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 13 | ▶ | croak 'Linux::Event::Datagram is an abstract base class' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | if $class eq __PACKAGE__; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 12 | ▶ | croak "$class is not a Linux::Event::Datagram subclass" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | if !$class->isa(__PACKAGE__); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 12 | my %callback = map { $_ => scalar $class->can($_) } qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | on_datagram on_drain on_ready on_error on_close configure_socket | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 12 | ▶ | croak "$class must define on_datagram()" if !$callback{on_datagram}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 11 | my %option = ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | max_datagram_size => 65_535, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | max_datagrams_per_tick => 256, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | edge_triggered => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | high_watermark => 1_048_576, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | low_watermark => 262_144, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | max_pending_bytes => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | max_pending_datagrams => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | reuseaddr => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | reuseport => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | broadcast => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | v6only => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | send_buffer => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | receive_buffer => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 11 | ▶ | if (my $configure = $class->can('datagram_options')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 2 | my @configured = $configure->($class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 2 | my %configured; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | %configured = %{ $configured[0] }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 2 | ▶ | croak "$class datagram_options() returned an odd option list" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | if @configured % 2; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | 2 | %configured = @configured; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 2 | my @unknown = grep { !exists $option{$_} } keys %configured; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 2 | ▶ | croak "$class datagram_options() returned unknown options: " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | . join(', ', sort @unknown) if @unknown; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 2 | @option{keys %configured} = values %configured; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | $option{max_datagram_size} = _integer( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 11 | $class, 'max_datagram_size', $option{max_datagram_size}, 1, 16_777_216, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | $option{max_datagrams_per_tick} = _integer( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | $class, 'max_datagrams_per_tick', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 11 | $option{max_datagrams_per_tick}, 0, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | 11 | for my $name (qw(high_watermark low_watermark max_pending_bytes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | max_pending_datagrams)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 44 | $option{$name} = _integer($class, $name, $option{$name}, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | croak "$class low_watermark must be <= high_watermark" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 11 | ▶ | if $option{low_watermark} > $option{high_watermark}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 11 | for my $name (qw(edge_triggered reuseaddr reuseport broadcast)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 44 | $option{$name} = _boolean($class, $name, $option{$name}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | $option{v6only} = _boolean($class, 'v6only', $option{v6only}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 11 | ▶ | if defined $option{v6only}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 11 | for my $name (qw(send_buffer receive_buffer)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | $option{$name} = Linux::Event::_SocketConfig::normalize( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | $class, $name, $option{$name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 22 | ▶ | ) if defined $option{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | croak "$class edge_triggered requires max_datagrams_per_tick => 0" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 11 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 11 | return $CLASS_DESCRIPTOR{$class} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | class => $class, callbacks => \%callback, options => \%option, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 26 | ▶ | sub new ($class, %option) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 26 | return $class->_construct(0, %option); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 15 | ▶ | sub connect ($class, %option) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
connect: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 15 | return $class->_construct(1, %option); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 41 | ▶ | sub _construct ($class, $connect, %option) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_construct: called CC=147 SCAR=72.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 41 | ▶ | croak(($connect ? 'connect' : 'new') . | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | '(): must be called as a class method') if ref $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | 41 | ▶ | my $method = $connect ? 'connect' : 'new'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 41 | my %known = map { $_ => 1 } qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | loop data bind_device | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | max_datagram_size max_datagrams_per_tick edge_triggered | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | high_watermark low_watermark max_pending_bytes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | max_pending_datagrams reuseaddr reuseport broadcast v6only | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | send_buffer receive_buffer | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | unlink unlink_on_close permissions owns_socket | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | fh host port unix local_host local_port local_unix | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 41 | my @unknown = sort grep { !$known{$_} } keys %option; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 41 | ▶ | croak "$method(): unknown options: " . join(', ', @unknown) if @unknown; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 40 | my %supplied = map { $_ => 1 } keys %option; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 40 | my $descriptor = _descriptor_for($class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 38 | my $loop = delete $option{loop}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 38 | ▶ | 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')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | if defined($loop) && (!ref($loop) || !$loop->can('add') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | || !$loop->can('watch')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 38 | my $data = delete $option{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 38 | my $bind_device = delete $option{bind_device}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 38 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | if defined($bind_device) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | && (ref($bind_device) || $bind_device eq '' || $bind_device =~ /\0/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 38 | my %effective = %{ $descriptor->{options} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 38 | for my $name (keys %effective) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 494 | ▶ | next if !exists $option{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 6 | $effective{$name} = delete $option{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | $effective{max_datagram_size} = _integer( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | "$method():", 'max_datagram_size', $effective{max_datagram_size}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 38 | 1, 16_777_216, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | $effective{max_datagrams_per_tick} = _integer( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | "$method():", 'max_datagrams_per_tick', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 38 | $effective{max_datagrams_per_tick}, 0, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 38 | for my $name (qw(high_watermark low_watermark max_pending_bytes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | max_pending_datagrams)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | $effective{$name} = _integer( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 151 | "$method():", $name, $effective{$name}, 0, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | croak "$method(): low_watermark must be <= high_watermark" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 37 | ▶ | if $effective{low_watermark} > $effective{high_watermark}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | 37 | for my $name (qw(edge_triggered reuseaddr reuseport broadcast)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | $effective{$name} = _boolean( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 148 | "$method():", $name, $effective{$name}, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | $effective{v6only} = _boolean( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | "$method():", 'v6only', $effective{v6only}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 37 | ▶ | ) if defined $effective{v6only}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 37 | for my $name (qw(send_buffer receive_buffer)) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | $effective{$name} = Linux::Event::_SocketConfig::normalize( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | $method, $name, $effective{$name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 73 | ▶ | ) if defined $effective{$name}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | croak "$method(): edge_triggered requires max_datagrams_per_tick => 0" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 36 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | croak "$method(): broadcast and v6only cannot be combined" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 35 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | my $unlink_existing = exists($option{unlink}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 35 | ▶ | ? _boolean("$method():", 'unlink', delete $option{unlink}) : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | my $unlink_on_close = exists($option{unlink_on_close}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | ? _boolean("$method():", 'unlink_on_close', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 35 | ▶ | delete $option{unlink_on_close}) : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 35 | my $permissions = delete $option{permissions}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 35 | ▶ | $permissions = _integer("$method():", 'permissions', $permissions, 0, 07777) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | if defined $permissions; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 35 | my $owns_socket_supplied = exists $option{owns_socket}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | my $owns_socket = $owns_socket_supplied | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | ? _boolean("$method():", 'owns_socket', delete $option{owns_socket}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 35 | ▶ | : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 35 | my ($fh, $family, $local, $peer, $path, $local_path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 35 | my $adopted = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 35 | my ($host, $port, $local_host, $local_port, $needs_resolution, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | $local_bind, $required_family, $required_family_option); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 35 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 3 | $adopted = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 3 | $fh = delete $option{fh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 3 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | if !defined($fh) || !defined(fileno($fh)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | croak 'new(): address options are not valid with fh' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 3 | ▶ | if grep { exists $option{$_} } qw(host port unix local_host | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | local_port local_unix); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 3 | my $type = getsockopt($fh, SOL_SOCKET, SO_TYPE); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 3 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | if !defined($type) || length($type) < 4 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | || unpack('i', $type) != SOCK_DGRAM; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 3 | $local = Linux::Event::Address->new(getsockname($fh)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 3 | $family = $local->family_number; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 3 | ▶ | croak 'new(): fh must use an IPv4, IPv6, or Unix address family' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/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 table20%1/5
not(A) or B and C and D
A= not defined $familyB= $family != 2C= $family != 10D= $family != 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | if !defined($family) || ($family != AF_INET | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | && $family != AF_INET6 && $family != AF_UNIX); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 3 | my @invalid = grep { $supplied{$_} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | qw(unlink unlink_on_close permissions); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 3 | ▶ | if ($family == AF_UNIX) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | push @invalid, grep { $supplied{$_} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | qw(bind_device v6only broadcast reuseaddr reuseport); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | push @invalid, 'broadcast' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | if $effective{broadcast} && !$supplied{broadcast}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$effective{"broadcast"} and not $supplied{"broadcast"}
MC/DC0%0/2
$effective{"broadcast"} and not $supplied{"broadcast"}
$effective{"broadcast"}
not $supplied{"broadcast"}
Truth table0%0/3
A and not(B)
A= $effective{"broadcast"}B= not $supplied{"broadcast"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | push @invalid, 'reuseaddr' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | if $effective{reuseaddr} && !$supplied{reuseaddr}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$effective{"reuseaddr"} and not $supplied{"reuseaddr"}
MC/DC0%0/2
$effective{"reuseaddr"} and not $supplied{"reuseaddr"}
$effective{"reuseaddr"}
not $supplied{"reuseaddr"}
Truth table0%0/3
A and not(B)
A= $effective{"reuseaddr"}B= not $supplied{"reuseaddr"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | push @invalid, 'reuseport' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | ▶ | if $effective{reuseport} && !$supplied{reuseport}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$effective{"reuseport"} and not $supplied{"reuseport"}
MC/DC0%0/2
$effective{"reuseport"} and not $supplied{"reuseport"}
$effective{"reuseport"}
not $supplied{"reuseport"}
Truth table0%0/3
A and not(B)
A= $effective{"reuseport"}B= not $supplied{"reuseport"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | push @invalid, 'v6only' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | if defined($effective{v6only}) && !$supplied{v6only}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/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 table0%0/3
A and not(B)
A= defined $effective{"v6only"}B= not $supplied{"v6only"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 3 | ▶ | croak 'new(): options not valid for this socket source: ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | . join(', ', sort @invalid) if @invalid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 3 | _set_adopted_flags($fh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 3 | my $packed_peer = eval { getpeername($fh) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 3 | ▶ | $peer = Linux::Event::Address->new($packed_peer) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | if defined $packed_peer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 3 | ▶ | $connect = defined($peer) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | ▶ | } 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 14 | $host = delete $option{host}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 14 | $port = delete $option{port}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 14 | ▶ | croak 'new(): host is required' if !defined $host; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 14 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | if ref($host) || $host eq '' || $host =~ /\0/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 13 | $port = _integer('new():', 'port', $port, 0, 65535); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 12 | my @invalid = grep { $supplied{$_} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | qw(unix local_host local_port local_unix unlink unlink_on_close | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | permissions owns_socket); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 12 | ▶ | croak 'new(): options not valid for UDP: ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | . join(', ', sort @invalid) if @invalid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 11 | ($fh, $family) = _create_bound_inet( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | $host, $port, \%effective, $bind_device, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 10 | $local = Linux::Event::Address->new(getsockname($fh)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | 10 | $owns_socket = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | ▶ | } 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | 4 | $path = delete $option{unix}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | if !defined($path) || ref($path) || $path eq '' || $path =~ /\0/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 3 | my @invalid = grep { $supplied{$_} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | qw(local_host local_port local_unix bind_device v6only broadcast | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | reuseaddr reuseport owns_socket); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | push @invalid, 'broadcast' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | push @invalid, 'reuseaddr' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | push @invalid, 'reuseport' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | push @invalid, 'v6only' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 3 | ▶ | croak 'new(): options not valid for Unix datagrams: ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | . join(', ', sort @invalid) if @invalid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 2 | ($fh, $family) = _create_bound_unix( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | $path, $unlink_existing, $permissions, \%effective, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 2 | $local = Linux::Event::Address->new(getsockname($fh)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 2 | $owns_socket = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | ▶ | } 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | 9 | $host = delete $option{host}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 9 | $port = delete $option{port}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 9 | ▶ | croak 'connect(): host is required' if !defined $host; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 9 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | if ref($host) || $host eq '' || $host =~ /\0/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 8 | $port = _integer('connect():', 'port', $port, 0, 65535); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 8 | my $has_local_host = exists $option{local_host}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 8 | $local_host = delete $option{local_host}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 8 | my $has_local_port = exists $option{local_port}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | $local_port = $has_local_port ? _integer( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 8 | ▶ | 'connect():', 'local_port', delete($option{local_port}), 0, 65535, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | ) : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 8 | ▶ | $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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 8 | ▶ | if ($has_local_host) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 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 ""
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | if !defined($local_host) || ref($local_host) || $local_host eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 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)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | if !defined(inet_pton(AF_INET, $local_host)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | && !defined(inet_pton(AF_INET6, $local_host)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 2 | ▶ | $required_family = defined(inet_pton(AF_INET, $local_host)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | ? AF_INET : AF_INET6; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 2 | $required_family_option = 'local_host'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | 7 | ▶ | if (defined $effective{v6only}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | if defined($required_family) && $required_family != AF_INET6; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | $required_family = AF_INET6; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | $required_family_option = 'v6only'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 7 | ▶ | if ($effective{broadcast}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | if defined($required_family) && $required_family != AF_INET; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | $required_family = AF_INET; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | $required_family_option = 'broadcast'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 7 | my @invalid = grep { $supplied{$_} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | qw(fh unix local_unix unlink unlink_on_close permissions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | owns_socket); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | 7 | ▶ | croak 'connect(): options not valid for UDP: ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | . join(', ', sort @invalid) if @invalid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 7 | ▶ | $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)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | && !defined(inet_pton(AF_INET6, $host)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 7 | $owns_socket = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | ▶ | } 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 5 | $path = delete $option{unix}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 5 | $local_path = delete $option{local_unix}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | if !defined($path) || ref($path) || $path eq '' || $path =~ /\0/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | if defined($local_path) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | && (ref($local_path) || $local_path eq '' || $local_path =~ /\0/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 3 | my @invalid = grep { $supplied{$_} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | qw(fh host port local_host local_port bind_device v6only broadcast | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | reuseaddr reuseport owns_socket); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 3 | ▶ | push @invalid, grep { $supplied{$_} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | qw(unlink unlink_on_close permissions) if !defined $local_path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | push @invalid, 'broadcast' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | push @invalid, 'reuseaddr' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | push @invalid, 'reuseport' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | push @invalid, 'v6only' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 3 | ▶ | croak 'connect(): options not valid for Unix datagrams: ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | . join(', ', sort @invalid) if @invalid; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 1 | $owns_socket = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | ▶ | croak "$method(): exactly one socket source is required " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | . ($connect ? '(host/port or unix)' : '(fh, host/port, or unix)'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 23 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | ? "$method(): owns_socket is valid only with fh" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | : %option | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | ? "$method(): options not valid for this socket source: " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | . join(', ', sort keys %option) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 23 | ▶ | if (defined $validation_error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | croak $validation_error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 23 | ▶ | my $self = bless { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | descriptor => $descriptor, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | options => \%effective, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | loop => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | fh => $fh, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | watcher => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | family_number => $family, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | local => $local, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | peer => $peer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | connected => $connect ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | host => $host, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | port => $port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | path => $path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | local_host => $local_host, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | local_port => $local_port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | local_bind => $local_bind ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | local_path => $local_path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | bind_device => $bind_device, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | required_family => $required_family, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | required_family_option => $required_family_option, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | needs_resolution => $needs_resolution ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | resolver => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | resolver_request => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | owns_socket => $owns_socket ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | unlink_existing => $unlink_existing, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | unlink_on_close => $unlink_on_close, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | permissions => $permissions, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | queue => [], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | pending_bytes => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | above_high => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | read_paused => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | state => 'unattached', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | last_error => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | ready_fired => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | ready_timer => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 23 | ▶ | if ($fh) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 15 | my $configured = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 15 | ▶ | $self->_apply_socket_policy($fh, $family) if $adopted; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 15 | ▶ | $self->_configure_socket( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%1/3
$peer // $local
MC/DC0%0/2
$peer // $local
$peer
$local
Truth table33%1/3
A // B
A= $peerB= $local
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | $fh, $adopted ? 'adopted' : 'bind', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | $adopted ? ($peer // $local) : $local, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 15 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 15 | ▶ | if (!$configured) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 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= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | close $fh if $self->{owns_socket}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | unlink $path | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | $self->{fh} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | die $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 23 | ▶ | $loop->add($self) if defined $loop; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 23 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 1 | ▶ | sub _message ($errno) { local $! = $errno; return "$!" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_message: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | ▶ | sub _setup_error ($operation, $errno, %field) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_setup_error: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | die Linux::Event::Error->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | type => 'setup', operation => $operation, errno => $errno, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | message => _message($errno), fatal => 1, %field, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 3 | ▶ | sub _set_adopted_flags ($fh) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_adopted_flags: called CC=5 SCAR=17.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 3 | my $status = fcntl($fh, F_GETFL, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 3 | ▶ | _setup_error('fcntl', 0 + $!) if !defined $status; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 3 | ▶ | fcntl($fh, F_SETFL, $status | O_NONBLOCK) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | or _setup_error('fcntl', 0 + $!); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 3 | my $descriptor = fcntl($fh, F_GETFD, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 3 | ▶ | _setup_error('fcntl', 0 + $!) if !defined $descriptor; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 3 | ▶ | fcntl($fh, F_SETFD, $descriptor | FD_CLOEXEC) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | or _setup_error('fcntl', 0 + $!); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 11 | ▶ | sub _create_bound_inet ($host, $port, $option, $bind_device) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_create_bound_inet: called CC=23 SCAR=46.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 11 | ▶ | my $node = $host eq '*' ? undef : $host; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 11 | my ($error, @candidate) = getaddrinfo( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | $node, $port, { socktype => SOCK_DGRAM, flags => AI_PASSIVE }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 11 | ▶ | die Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | type => 'resolve', operation => 'resolve', message => "$error", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | host => $host, port => $port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | ) if $error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 11 | my $last_errno = Errno::EADDRNOTAVAIL(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 11 | my $compatible = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 11 | for my $candidate (@candidate) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | next if $candidate->{family} != AF_INET | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | 11 | ▶ | && $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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | next if defined($option->{v6only}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 11 | ▶ | && $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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 10 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 10 | $compatible = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 10 | my $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 10 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | SOCK_DGRAM | SOCK_NONBLOCK | SOCK_CLOEXEC, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | $candidate->{protocol} // 0)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | $last_errno = 0 + $!; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 10 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | _apply_creation_policy( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 10 | $fh, $candidate->{family}, $option, $bind_device, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | bind($fh, $candidate->{addr}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 10 | ▶ | or _setup_error('bind', 0 + $!, host => $host, port => $port); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 10 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 10 | ▶ | return ($fh, $candidate->{family}) if $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | my $failure = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | && $failure->isa('Linux::Event::Error') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | && $failure->type eq 'socket_configuration'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | ? $failure->errno : 0 + $!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | die Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | type => 'socket_configuration', operation => 'setsockopt', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | option => 'v6only', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | message => 'v6only requires an IPv6 bind address', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | host => $host, port => $port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | die Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | type => 'socket_configuration', operation => 'setsockopt', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | option => 'broadcast', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | message => 'broadcast requires an IPv4 bind address', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | host => $host, port => $port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | _setup_error('bind', $last_errno, host => $host, port => $port); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 3 | ▶ | sub _prepare_unix_path ($path, $unlink_existing) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_prepare_unix_path: called CC=6 SCAR=30.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | ▶ | croak "Unix datagram path already exists: $path" if !$unlink_existing; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | ▶ | croak "refusing to unlink non-socket path: $path" if !-S $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | ▶ | unlink($path) or _setup_error('unlink', 0 + $!, path => $path); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 2 | ▶ | sub _create_bound_unix ($path, $unlink_existing, $permissions, $option) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_create_bound_unix: called CC=7 SCAR=25.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 2 | _prepare_unix_path($path, $unlink_existing); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 2 | ▶ | socket(my $fh, AF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | or _setup_error('socket', 0 + $!, path => $path); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 2 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | Linux::Event::_SocketConfig::apply_policy($fh, AF_UNIX, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | send_buffer => $option->{send_buffer}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | receive_buffer => $option->{receive_buffer}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 2 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 2 | ▶ | bind($fh, pack_sockaddr_un($path)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | or _setup_error('bind', 0 + $!, path => $path); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | 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)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | _setup_error('chmod', 0 + $!, path => $path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 2 | ▶ | if (!$ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | my $failure = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 0 | ▶ | unlink $path if -S $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | die $failure; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 2 | return ($fh, AF_UNIX); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 1 | ▶ | sub _socket_option_error ($name, $errno, $message = undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_socket_option_error: called CC=5 SCAR=18.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 1 | $operation = 'setsockopt') { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 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)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | type => 'socket_configuration', operation => $operation, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | option => $name, errno => $errno || undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | message => $message // _message($errno), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 20 | ▶ | sub _apply_creation_policy ($fh, $family, $option, $bind_device) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_apply_creation_policy: called CC=11 SCAR=32.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 20 | for my $item ( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | ['reuseaddr', SO_REUSEADDR, $option->{reuseaddr}], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | ['reuseport', SO_REUSEPORT, $option->{reuseport}], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | ['broadcast', SO_BROADCAST, $option->{broadcast}], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 60 | ▶ | next if !$item->[2]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 'broadcast', 0, 'broadcast is valid only for IPv4 sockets', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | ) if $item->[0] eq 'broadcast' && $family != AF_INET; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 0 | ▶ | setsockopt($fh, SOL_SOCKET, $item->[1], pack('i', 1)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | or _socket_option_error($item->[0], 0 + $!); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 20 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | die Linux::Event::Error->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | type => 'socket_configuration', operation => 'setsockopt', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | option => 'v6only', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | message => 'v6only is valid only for IPv6 sockets', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 20 | ▶ | if (defined($option->{v6only})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | setsockopt($fh, IPPROTO_IPV6, IPV6_V6ONLY, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 1 | ▶ | pack('i', $option->{v6only})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | or _socket_option_error('v6only', 0 + $!); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | Linux::Event::_SocketConfig::apply_policy($fh, $family, { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | send_buffer => $option->{send_buffer}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | receive_buffer => $option->{receive_buffer}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 20 | }); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 20 | ▶ | Linux::Event::_SocketConfig::bind_device($fh, $bind_device) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | if defined $bind_device; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 20 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 10 | ▶ | sub _apply_socket_policy ($self, $fh, $family) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_apply_socket_policy: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | _apply_creation_policy( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | $fh, $family, $self->{options}, $self->{bind_device}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 10 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 10 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 22 | ▶ | sub _configure_socket ($self, $fh, $role, $address) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_configure_socket: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 22 | my $callback = $self->{descriptor}{callbacks}{configure_socket}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 22 | ▶ | return if !$callback; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 2 | my $ok = eval { $callback->($self, $fh, $role, $address); 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 2 | ▶ | return if $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 1 | my $message = "$@"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 1 | $message =~ s/\s+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | type => 'socket_configuration', operation => 'configure_socket', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | message => $message || 'configure_socket callback failed', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 17 | ▶ | sub _attach_to_loop ($self, $loop) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_attach_to_loop: called CC=21 SCAR=35.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | croak 'add(): Datagram is not unattached' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | 17 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 17 | $self->{loop} = $loop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 17 | ▶ | if ($self->{fh}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 10 | $self->{state} = 'active'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 10 | my $registered = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 10 | $self->_register; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 9 | $self->_schedule_ready; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 9 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 10 | ▶ | if (!$registered) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 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= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 1 | ▶ | if (my $timer = delete $self->{ready_timer}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | ▶ | $timer->cancel if !$timer->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 1 | ▶ | if (my $watcher = delete $self->{watcher}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 0 | $watcher->cancel; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 1 | $self->{state} = 'unattached'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 1 | $self->{loop} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | && $failure->isa('Linux::Event::Error'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 1 | die Linux::Event::Error->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | type => 'setup', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | operation => 'watch', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | fatal => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | message => "$failure", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 9 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 7 | ▶ | if ($self->{needs_resolution}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 2 | $self->{state} = 'resolving'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 2 | my ($resolver, $id); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 2 | my $submitted = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 2 | $resolver = Linux::Event::_Resolver->for_loop($loop); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 2 | $self->{resolver} = $resolver; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | $id = $resolver->submit( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 2 | $self, $self->{host}, $self->{port}, SOCK_DGRAM, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 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= "$@"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | $self->_fail(Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | type => 'resolve', operation => 'resolve', message => $message, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | host => $self->{host}, port => $self->{port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | )); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 2 | $self->{resolver_request} = $id; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 5 | my $activated = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 5 | ▶ | if ($self->{path}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | 1 | $self->_activate_unix; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 4 | my $packed4 = inet_pton(AF_INET, $self->{host}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 4 | my ($family, $sockaddr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 4 | ▶ | if (defined $packed4) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 4 | $family = AF_INET; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 4 | $sockaddr = pack_sockaddr_in($self->{port}, $packed4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | $family = AF_INET6; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | $sockaddr = pack_sockaddr_in6( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | $self->{port}, inet_pton(AF_INET6, $self->{host}), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | 4 | $self->_activate_inet_candidate({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | family => $family, protocol => 0, sockaddr => $sockaddr, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 5 | ▶ | if (!$activated) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 2 | my $failure = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | my $error = blessed($failure) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | && $failure->isa('Linux::Event::Error') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | ? $failure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | : Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | type => 'connect', operation => 'connect', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | message => "$failure" || 'datagram connection failed', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | host => $self->{host}, port => $self->{port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | path => $self->{path}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 2 | $self->_fail($error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | 5 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | 2 | ▶ | sub _resolver_completed ($self, $result) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_resolver_completed: called CC=23 SCAR=45.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 2 | ▶ | return if $self->{state} ne 'resolving'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | return if !defined($self->{resolver_request}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | 2 | delete $self->{resolver_request}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | 2 | delete $self->{resolver}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 2 | ▶ | if ($result->{error_code}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | $self->_fail(Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | type => 'resolve', operation => 'resolve', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | errno => $result->{system_errno} || undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | message => $result->{message} || 'hostname resolution failed', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | resolver_message => $result->{message}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | host => $self->{host}, port => $self->{port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 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'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 2 | my $last_error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 2 | my $compatible = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 2 | for my $candidate (@{ $result->{candidates} }) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | next if $candidate->{family} != AF_INET | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | next if defined($self->{required_family}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 2 | $compatible = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | 2 | my $ok = eval { $self->_activate_inet_candidate($candidate); 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 2 | ▶ | return if $ok; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 1 | $last_error = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | && $last_error->isa('Linux::Event::Error') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | && ($last_error->type eq 'socket_configuration' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | || $last_error->type eq 'setup')) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 1 | $self->_fail($last_error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | my $option = $self->{required_family_option}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | ▶ | my $message = $option eq 'local_host' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | ? 'local_host address family does not match any peer address' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | : "$option has no compatible peer address"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | $self->_fail(Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | type => 'socket_configuration', operation => 'bind', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | option => $option, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | message => $message, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | host => $self->{host}, port => $self->{port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 0 | )); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | $self->_fail(blessed($last_error) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | && $last_error->isa('Linux::Event::Error') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | ? $last_error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | : Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | type => 'connect', operation => 'connect', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | message => "$last_error" || 'no compatible datagram address', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | host => $self->{host}, port => $self->{port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 6 | ▶ | sub _activate_inet_candidate ($self, $candidate) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_activate_inet_candidate: called CC=12 SCAR=25.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 6 | my $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | socket($fh, $candidate->{family}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | SOCK_DGRAM | SOCK_NONBLOCK | SOCK_CLOEXEC, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | $candidate->{protocol} // 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | or _setup_error('socket', 0 + $!, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 6 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 6 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | 6 | $self->_apply_socket_policy($fh, $candidate->{family}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | $self->_configure_socket( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | 6 | $fh, 'connect', Linux::Event::Address->new($candidate->{sockaddr}), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 5 | ▶ | if ($self->{local_bind}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 3 | my $packed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 3 | ▶ | if (defined $self->{local_host}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 2 | $packed = inet_pton($candidate->{family}, $self->{local_host}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | 2 | ▶ | die Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | type => 'socket_configuration', operation => 'bind', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | option => 'local_host', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | message => 'local_host address family does not match peer', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | ) if !defined $packed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | $packed = inet_pton( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | $candidate->{family}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 1 | ▶ | $candidate->{family} == AF_INET ? '0.0.0.0' : '::', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | my $local = $candidate->{family} == AF_INET | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | ? pack_sockaddr_in($self->{local_port}, $packed) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | 2 | ▶ | : pack_sockaddr_in6($self->{local_port}, $packed); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | 2 | ▶ | if (!bind($fh, $local)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 1 | my $errno = 0 + $!; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | die Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | type => 'socket_configuration', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | operation => 'bind', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | option => defined($self->{local_host}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | ? 'local_host' : 'local_port', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | errno => $errno, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | message => _message($errno), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | host => $self->{local_host}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | port => $self->{local_port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 1 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | CORE::connect($fh, $candidate->{sockaddr}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | or _setup_error('connect', 0 + $!, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 3 | ▶ | host => $self->{host}, port => $self->{port}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 6 | ▶ | if (!$ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 3 | my $failure = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 3 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 3 | die $failure; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 3 | $self->_finish_activation($fh, $candidate->{family}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 1 | ▶ | sub _activate_unix ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_activate_unix: called CC=13 SCAR=36.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 1 | my $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | socket($fh, AF_UNIX, SOCK_DGRAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 1 | ▶ | or _setup_error('socket', 0 + $!, path => $self->{path}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 1 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 1 | $self->_apply_socket_policy($fh, AF_UNIX); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | $self->_configure_socket( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | $fh, 'connect', Linux::Event::Address->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 1 | pack_sockaddr_un($self->{path}), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 1 | ▶ | if (defined $self->{local_path}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 1 | _prepare_unix_path($self->{local_path}, $self->{unlink_existing}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | bind($fh, pack_sockaddr_un($self->{local_path})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 1 | ▶ | or _setup_error('bind', 0 + $!, path => $self->{local_path}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | chmod($self->{permissions}, $self->{local_path}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | or _setup_error('chmod', 0 + $!, path => $self->{local_path}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 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"})
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | CORE::connect($fh, pack_sockaddr_un($self->{path})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | 1 | ▶ | or _setup_error('connect', 0 + $!, path => $self->{path}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | 1 | ▶ | if (!$ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | 0 | my $failure = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | unlink $self->{local_path} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 0 | die $failure; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 1 | my $activated = eval { $self->_finish_activation($fh, AF_UNIX); 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 1 | ▶ | if (!$activated) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 0 | my $failure = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | unlink $self->{local_path} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | die $failure; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | 4 | ▶ | sub _finish_activation ($self, $fh, $family) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_finish_activation: called CC=9 SCAR=35.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 4 | my $previous_state = $self->{state}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 4 | $self->{fh} = $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 4 | $self->{family_number} = $family; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 4 | my $activated = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 4 | $self->{local} = Linux::Event::Address->new(getsockname($fh)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 4 | $self->{peer} = Linux::Event::Address->new(getpeername($fh)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 4 | $self->{state} = 'active'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 4 | $self->_register; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 4 | $self->_schedule_ready; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 4 | $self->_flush_output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 4 | ▶ | return if $activated; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 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= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 0 | ▶ | if (my $timer = delete $self->{ready_timer}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | 0 | ▶ | $timer->cancel if $timer->is_active; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | 0 | ▶ | if (my $watcher = delete $self->{watcher}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 0 | $watcher->cancel; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | 0 | ▶ | close delete $self->{fh} if $self->{fh}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | 0 | $self->{family_number} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 0 | $self->{local} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 0 | $self->{peer} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 0 | $self->{state} = $previous_state; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | && $failure->isa('Linux::Event::Error'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | 0 | die Linux::Event::Error->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | type => 'setup', operation => 'watch', fatal => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | message => "$failure", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | 14 | ▶ | sub _register ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_register: called CC=5 SCAR=17.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 14 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | $self->{watcher} = $self->{loop}->watch( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | fh => $self->{fh}, _internal => 1, data => $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | read => \&_read_ready, write => \&_write_ready, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | error => \&_error_ready, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | edge_triggered => $self->{options}{edge_triggered}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | 14 | _callback_data_arg => 1, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | 13 | ▶ | $self->{watcher}->disable_write if !@{ $self->{queue} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 13 | ▶ | $self->{watcher}->disable_read if $self->{read_paused}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 13 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | 13 | ▶ | sub _schedule_ready ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_schedule_ready: called CC=3 SCAR=11.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | 13 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 13 | my $timer = Linux::Event::Datagram::_ReadyTimer->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | after => 0, data => $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | 13 | $self->{ready_timer} = $timer; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | 13 | $self->{loop}->add($timer); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | 13 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | 7 | ▶ | sub _fire_ready ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fire_ready: called CC=4 SCAR=14.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | 7 | delete $self->{ready_timer}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 7 | ▶ | 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"}++
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | 7 | my $callback = $self->{descriptor}{callbacks}{on_ready}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | 7 | ▶ | $callback->($self) if $callback; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 7 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 5 | ▶ | sub _report ($self, $error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_report: called CC=2 SCAR=7.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | 5 | $self->{last_error} = $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | 5 | ▶ | if (my $callback = $self->{descriptor}{callbacks}{on_error}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | 5 | $callback->($self, $error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | warn "$error\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 5 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 3 | ▶ | sub _fail ($self, $error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fail: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 3 | ▶ | return if $self->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 3 | $self->{last_error} = $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 3 | $self->_shutdown('failed', 0, 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 3 | my $reported = eval { $self->_report($error); 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | 3 | my $failure = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 3 | $self->{loop} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | 3 | ▶ | die $failure if !$reported; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 83 | ▶ | sub _read_ready ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_read_ready: called CC=9 SCAR=24.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | 83 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | my $batch = Linux::Event::Datagram::_recv_batch( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | fileno($self->{fh}), $self->{options}{max_datagram_size}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | $self->{options}{max_datagrams_per_tick}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | 83 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 83 | my $errno = $batch->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 83 | ▶ | for (my $at = 1; $at < @$batch; $at += 4) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 85 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | 85 | my ($payload, $sockaddr, $length, $truncated) | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | = @$batch[$at .. $at + 3]; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | 85 | my $peer = Linux::Event::Address->new($sockaddr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | 85 | ▶ | if ($truncated) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | $self->_report(Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | type => 'datagram_size', operation => 'receive', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | message => "received datagram exceeds " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | . "$self->{options}{max_datagram_size} bytes", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | datagram_size => $length, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | limit => $self->{options}{max_datagram_size}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | 1 | )); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | 84 | $self->{descriptor}{callbacks}{on_datagram}->($self, $payload, $peer); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 83 | ▶ | 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"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 0 | $self->_report(Linux::Event::Error->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | type => 'io', operation => 'receive', errno => $errno, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | message => _message($errno), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | 83 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | 87 | ▶ | sub send ($self, $payload, %option) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send: called CC=23 SCAR=41.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | 87 | ▶ | croak 'send(): Datagram is terminal' if $self->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | 87 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | if !defined($payload) || ref($payload); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 87 | $payload = "$payload"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | 87 | ▶ | croak 'send(): payload must be a byte string' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | if !utf8::downgrade($payload, 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | croak "send(): payload exceeds $self->{options}{max_datagram_size} bytes" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | 86 | ▶ | if length($payload) > $self->{options}{max_datagram_size}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 86 | my $to = delete $option{to}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | 86 | ▶ | croak 'send(): unknown options: ' . join(', ', sort keys %option) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | if %option; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | 86 | ▶ | if ($self->{connected}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | 24 | ▶ | croak 'send(): to is not valid for a connected Datagram' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | if defined $to; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | 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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | if !blessed($to) || !$to->isa('Linux::Event::Address'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | 86 | ▶ | my $address = defined($to) ? $to->sockaddr : undef; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | 86 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | if defined($to) && (!defined($address) || ref($address)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | return $self->_queue_packet($payload, $address) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | 86 | ▶ | 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"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | my ($sent, $errno) = Linux::Event::Datagram::_send_packet( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | 84 | ▶ | fileno($self->{fh}), $payload, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | defined($address) ? $address : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | 84 | ▶ | return 1 if $sent == length($payload); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | || $errno == Errno::ENOBUFS()) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | 0 | return $self->_queue_packet($payload, $address); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | 0 | ▶ | $self->_report(Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | type => 'io', operation => 'send', errno => $errno, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | message => $errno ? _message($errno) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | : "short datagram send ($sent of " . length($payload) . ' bytes)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | 2 | ▶ | sub _queue_packet ($self, $payload, $address) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_queue_packet: called CC=10 SCAR=25.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | 2 | my $bytes = $self->{pending_bytes} + length($payload); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | 2 | my $datagrams = @{ $self->{queue} } + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | 2 | my $byte_limit = $self->{options}{max_pending_bytes}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | 2 | my $packet_limit = $self->{options}{max_pending_datagrams}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | || ($packet_limit && $datagrams > $packet_limit)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | ? $byte_limit : $packet_limit; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | 1 | $self->_report(Linux::Event::Error->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | type => 'output_limit', operation => 'send', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | message => 'pending datagram output limit would be exceeded', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | pending_bytes => $bytes, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | pending_datagrams => $datagrams, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | limit => $limit, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | 1 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | 1 | push @{ $self->{queue} }, [$payload, $address]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 1 | $self->{pending_bytes} = $bytes; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | 1 | ▶ | if ($bytes > $self->{options}{high_watermark}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | 0 | $self->{above_high} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | 1 | ▶ | $self->{watcher}->enable_write if $self->{watcher}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | 1 | ▶ | return $self->{above_high} ? 0 : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | 0 | ▶ | sub _write_ready ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_write_ready: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 0 | ▶ | return if $self->{state} ne 'active'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 0 | $self->_flush_output; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | 4 | ▶ | sub _flush_output ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_flush_output: called CC=15 SCAR=41.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | 4 | ▶ | return if !$self->{fh}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | 4 | ▶ | while (my $packet = $self->{queue}[0]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | 1 | my ($payload, $address) = @$packet; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | my ($sent, $errno) = Linux::Event::Datagram::_send_packet( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | 1 | ▶ | fileno($self->{fh}), $payload, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | defined($address) ? $address : undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | 1 | ▶ | if ($sent == length($payload)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 1 | shift @{ $self->{queue} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | 1 | $self->{pending_bytes} -= length($payload); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | 1 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | || $errno == Errno::ENOBUFS(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | 0 | shift @{ $self->{queue} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | 0 | $self->{pending_bytes} -= length($payload); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | 0 | ▶ | $self->_report(Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | type => 'io', operation => 'send', errno => $errno, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | message => $errno ? _message($errno) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | : "short datagram send ($sent of " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | . length($payload) . ' bytes)', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | 0 | ▶ | last if $self->{state} ne 'active'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | $self->{watcher}->disable_write | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | 4 | ▶ | 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"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | 4 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | && $self->{pending_bytes} <= $self->{options}{low_watermark}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | 0 | $self->{above_high} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | 0 | my $callback = $self->{descriptor}{callbacks}{on_drain}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | 0 | ▶ | $callback->($self) if $callback; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | 4 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 0 | ▶ | sub _error_ready ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_error_ready: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | 0 | ▶ | return if $self->{state} ne 'active'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | 0 | my $packed = getsockopt($self->{fh}, SOL_SOCKET, SO_ERROR); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | ? unpack('i', $packed) : 0 + $!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | type => 'io', operation => 'socket', errno => $errno || undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | message => $errno ? _message($errno) : 'datagram socket error', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | )); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | 24 | ▶ | sub _shutdown ($self, $state, $fire_close = 1, $retain_loop = 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_shutdown: called CC=19 SCAR=29.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | 24 | ▶ | return if $self->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | 23 | $self->{state} = $state; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | 23 | my $request = delete $self->{resolver_request}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | 23 | my $resolver = delete $self->{resolver}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | 23 | ▶ | $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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 23 | ▶ | if (my $timer = delete $self->{ready_timer}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 6 | ▶ | $timer->cancel if $timer->is_active; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | 23 | ▶ | if (my $watcher = delete $self->{watcher}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | 13 | $watcher->cancel; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | 23 | ▶ | if (my $fh = delete $self->{fh}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | 19 | ▶ | close $fh if $self->{owns_socket}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | my $remove_path = $self->{connected} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | 23 | ▶ | ? $self->{local_path} : $self->{path}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | unlink $remove_path if $self->{unlink_on_close} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | 23 | ▶ | && 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | 23 | $self->{queue} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | 23 | $self->{pending_bytes} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | 23 | my ($called, $failure) = (1, undef); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | 23 | ▶ | 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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | 5 | $called = eval { $callback->($self); 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | 5 | $failure = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | 23 | ▶ | $self->{loop} = undef if !$retain_loop; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | 23 | ▶ | die $failure if !$called; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | 23 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | 20 | ▶ | sub close ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
close: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | 20 | $self->_shutdown('closed'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | 20 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | 1 | ▶ | sub detach ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
detach: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | 1 | ▶ | croak 'detach(): Datagram has no active socket' if !$self->{fh}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | 1 | my $fh = $self->{fh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | 1 | $self->{owns_socket} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 1 | $self->{unlink_on_close} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 1 | $self->_shutdown('detached', 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | 1 | return $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | 1 | ▶ | sub pause_read ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pause_read: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | 1 | ▶ | return $self if $self->{read_paused}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | 1 | $self->{read_paused} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 1 | ▶ | $self->{watcher}->disable_read if $self->{watcher}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | 1 | ▶ | sub resume_read ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resume_read: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | 1 | ▶ | return $self if !$self->{read_paused}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | 1 | $self->{read_paused} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | 1 | ▶ | $self->{watcher}->enable_read if $self->{watcher}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | 2 | ▶ | sub _buffer_option ($self, $name, @argument) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_buffer_option: called CC=4 SCAR=14.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | 2 | ▶ | croak "$name(): Datagram has no active socket" if !$self->{fh}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | 2 | ▶ | croak "$name(): expected zero or one argument" if @argument > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | Linux::Event::_SocketConfig::set_option( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | 2 | ▶ | $self->{fh}, $self->{family_number}, $name, $argument[0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | ) if @argument; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | return Linux::Event::_SocketConfig::get_option( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | 2 | $self->{fh}, $self->{family_number}, $name, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | 1 | ▶ | sub send_buffer ($self, @argument) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_buffer: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | 1 | return $self->_buffer_option('send_buffer', @argument); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | 1 | ▶ | sub receive_buffer ($self, @argument) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
receive_buffer: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | 1 | return $self->_buffer_option('receive_buffer', @argument); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | 3 | ▶ | sub broadcast ($self, @argument) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
broadcast: called CC=9 SCAR=23.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | 3 | ▶ | croak 'broadcast(): Datagram has no active socket' if !$self->{fh}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | 3 | ▶ | croak 'broadcast(): expected zero or one argument' if @argument > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | _socket_option_error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | 'broadcast', 0, 'broadcast is valid only for IPv4 sockets', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | @argument ? 'setsockopt' : 'getsockopt', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | 3 | ▶ | ) if $self->{family_number} != AF_INET; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | 2 | ▶ | if (@argument) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | 2 | my $value = _boolean('broadcast():', 'value', $argument[0]); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | 2 | ▶ | setsockopt($self->{fh}, SOL_SOCKET, SO_BROADCAST, pack('i', $value)) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | or die Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | type => 'socket_configuration', operation => 'setsockopt', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | option => 'broadcast', errno => 0 + $!, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | message => _message(0 + $!), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | 2 | my $packed = getsockopt($self->{fh}, SOL_SOCKET, SO_BROADCAST); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | 2 | ▶ | die Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | type => 'socket_configuration', operation => 'getsockopt', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | option => 'broadcast', errno => 0 + $!, message => _message(0 + $!), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | ) if !defined $packed; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | 2 | ▶ | return unpack('i', $packed) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | 0 | ▶ | sub fh ($self) { $self->{fh} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fh: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | 4 | ▶ | sub fd ($self) { $self->{fh} ? fileno($self->{fh}) : undef } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fd: called CC=2 SCAR=7.6
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | 24 | ▶ | sub loop ($self) { $self->{loop} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
loop: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | 11 | ▶ | sub local ($self) { $self->{local} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
local: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | 4 | ▶ | sub peer ($self) { $self->{peer} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
peer: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | 5 | ▶ | sub is_connected ($self) { !!$self->{connected} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_connected: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | 8 | ▶ | sub state ($self) { $self->{state} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
state: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | 0 | ▶ | sub last_error ($self) { $self->{last_error} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
last_error: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | 4 | ▶ | sub pending_bytes ($self) { $self->{pending_bytes} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pending_bytes: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | 6 | ▶ | sub pending_datagrams ($self) { scalar @{ $self->{queue} } } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pending_datagrams: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | 5 | ▶ | sub is_read_paused ($self) { !!$self->{read_paused} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_read_paused: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | 2 | ▶ | sub is_active ($self) { $self->{state} eq 'active' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_active: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | 156 | ▶ | sub is_terminal ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_terminal: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | return $self->{state} eq 'closed' || $self->{state} eq 'failed' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | 156 | ▶ | || $self->{state} eq 'detached'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%6/6
$self->{'state'} eq 'closed' || $self->{'state'} eq 'failed' || $self->{'state'} eq 'detached'
$self->{"state"} eq "closed" or $self->{"state"} eq "failed"
MC/DC100%3/3
$self->{'state'} eq 'closed' || $self->{'state'} eq 'failed' || $self->{'state'} eq 'detached'
$self->{"state"} eq "closed"
$self->{"state"} eq "failed"
$self->{'state'} eq 'detached'
Truth table100%4/4
A or B || C
A= $self->{"state"} eq "closed"B= $self->{"state"} eq "failed"C= $self->{'state'} eq 'detached'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | 42 | ▶ | sub data ($self, @argument) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
data: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | 42 | ▶ | $self->{data} = $argument[0] if @argument; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | 42 | return $self->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | 0 | ▶ | sub CLONE_SKIP ($class) { 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CLONE_SKIP: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | 23 | ▶ | sub DESTROY ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=2 SCAR=8.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | 0 | ▶ | eval { $self->_shutdown('closed', 0) } if !$self->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | 23 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | package Linux::Event::Datagram::_ReadyTimer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | 8 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | 8 | ▶ | use parent -norequire, 'Linux::Event::Timer'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | 7 | ▶ | sub on_timer ($timer) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
on_timer: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | 7 | my $datagram = $timer->data; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | 7 | ▶ | $datagram->_fire_ready if $datagram; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | 7 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | 8 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||