| 1 | package Linux::Event::Listener; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 19 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 19 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 19 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 19 | our $VERSION = '0.105'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 19 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 19 | ▶ | use Errno (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 19 | ▶ | use Fcntl qw(F_GETFD F_GETFL F_SETFD F_SETFL FD_CLOEXEC O_NONBLOCK); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 19 | ▶ | use Scalar::Util qw(blessed); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 19 | ▶ | use Socket qw( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | AF_INET AF_INET6 AF_UNIX AI_PASSIVE | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | IPPROTO_IPV6 IPV6_V6ONLY | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | SOCK_STREAM SOCK_NONBLOCK SOCK_CLOEXEC | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | SOL_SOCKET SO_ACCEPTCONN SO_ERROR SO_REUSEADDR SO_REUSEPORT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | getaddrinfo pack_sockaddr_un | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 19 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | 19 | ▶ | use Linux::Event::Error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | 19 | ▶ | use Linux::Event::Address; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 19 | ▶ | use Linux::Event::_SocketConfig (); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 19 | require XSLoader; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 19 | XSLoader::load(__PACKAGE__, $VERSION); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 19 | my %CLASS_DESCRIPTOR; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | 36 | ▶ | sub _descriptor_for ($class) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_descriptor_for: called CC=5 SCAR=16.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 36 | ▶ | return $CLASS_DESCRIPTOR{$class} if exists $CLASS_DESCRIPTOR{$class}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 20 | ▶ | croak "$class is not a Linux::Event::Listener subclass" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | if !$class->isa(__PACKAGE__); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 20 | my $accept_client = $class->can('_accept_client'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 20 | my $on_accept = $class->can('on_accept'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 20 | my $on_error = $class->can('on_error'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 20 | ▶ | croak "$class must define _accept_client()" if !$accept_client; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 20 | ▶ | croak "$class must define on_error()" if !$on_error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 20 | return $CLASS_DESCRIPTOR{$class} = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | accept_client => $accept_client, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | on_accept => $on_accept, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | on_error => $on_error, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 95 | ▶ | sub _integer ($name, $value, $minimum, $maximum = 2_147_483_647) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_integer: called CC=9 SCAR=22.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 95 | ▶ | croak "new(): $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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | if !defined($value) || ref($value) || $value !~ /\A\d+\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 94 | my $digits = "$value"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 94 | $digits =~ s/\A0+(?=\d)//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 94 | ▶ | croak "new(): $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 table50%2/4
A or B and C
A= length $digits > length "$maximum"B= length $digits == length "$maximum"C= $digits gt "$maximum"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | if length($digits) > length("$maximum") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | || (length($digits) == length("$maximum") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | && $digits gt "$maximum"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 93 | $value = 0 + $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 93 | ▶ | croak "new(): $name must be at least $minimum" if $value < $minimum; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 93 | return $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 142 | ▶ | sub _boolean ($name, $value) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_boolean: called CC=5 SCAR=19.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 142 | ▶ | croak "new(): $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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | if !defined($value) || ref($value) || $value !~ /\A[01]\z/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 142 | ▶ | return $value ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub _message ($errno) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_message: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | local $! = $errno; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | return "$!"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 26 | ▶ | sub _family_name ($family) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_family_name: called CC=4 SCAR=14.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 26 | ▶ | return 'inet' if $family == AF_INET; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | ▶ | return 'inet6' if $family == AF_INET6; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 2 | ▶ | return 'unix' if $family == AF_UNIX; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | return 'unknown'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub _setup_error (%arg) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_setup_error: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | die Linux::Event::Error->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | type => 'setup', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | fatal => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | %arg, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 4 | ▶ | sub _set_adopted_flags ($fh) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_adopted_flags: called CC=5 SCAR=17.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 4 | my $status = fcntl($fh, F_GETFL, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 4 | ▶ | _setup_error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | operation => 'fcntl', errno => 0 + $!, message => _message(0 + $!), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | ) if !defined $status; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 4 | ▶ | fcntl($fh, F_SETFL, $status | O_NONBLOCK) or _setup_error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | operation => 'fcntl', errno => 0 + $!, message => _message(0 + $!), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | 4 | my $fd_status = fcntl($fh, F_GETFD, 0); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 4 | ▶ | _setup_error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | operation => 'fcntl', errno => 0 + $!, message => _message(0 + $!), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | ) if !defined $fd_status; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 4 | ▶ | fcntl($fh, F_SETFD, $fd_status | FD_CLOEXEC) or _setup_error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | operation => 'fcntl', errno => 0 + $!, message => _message(0 + $!), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | 4 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 21 | ▶ | sub _create_inet_listener ($host, $port, $backlog, $reuseaddr, $reuseport, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_create_inet_listener: called CC=28 SCAR=52.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | $v6only, $bind_device) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 21 | ▶ | my $node = $host eq '*' ? undef : $host; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 21 | my ($resolver_error, @result) = getaddrinfo( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | $node, $port, { socktype => SOCK_STREAM, flags => AI_PASSIVE }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 21 | ▶ | _setup_error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | operation => 'resolve', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | message => "$resolver_error", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | host => $host, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | port => $port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | ) if $resolver_error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 21 | my ($last_errno, $last_operation); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 21 | my $compatible = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 21 | for my $candidate (@result) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 21 | ▶ | next if !defined($candidate->{family}) || !defined($candidate->{addr}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $candidate->{"family"} and defined $candidate->{"addr"}
MC/DC0%0/2
defined $candidate->{"family"} and defined $candidate->{"addr"}
defined $candidate->{"family"}
defined $candidate->{"addr"}
Truth table33%1/3
A and B
A= defined $candidate->{"family"}B= defined $candidate->{"addr"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | next if $candidate->{family} != AF_INET | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 21 | ▶ | && $candidate->{family} != AF_INET6; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/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 table33%1/3
A and B
A= $candidate->{"family"} != 2B= $candidate->{"family"} != 10
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 21 | ▶ | next if defined($v6only) && $candidate->{family} != AF_INET6; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $v6only and $candidate->{"family"} != 10
MC/DC50%1/2
defined $v6only and $candidate->{"family"} != 10
defined $v6only
$candidate->{"family"} != 10
Truth table66%2/3
A and B
A= defined $v6onlyB= $candidate->{"family"} != 10
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 20 | $compatible = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 20 | my $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 20 | ▶ | if (!socket( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | $fh, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | $candidate->{family}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | $candidate->{protocol} // 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | ($last_errno, $last_operation) = (0 + $!, 'socket'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 20 | ▶ | if ($reuseaddr | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$reuseaddr and not setsockopt($fh, 1, 2, "\1\0\0\0")
MC/DC0%0/2
$reuseaddr and not setsockopt($fh, 1, 2, "\1\0\0\0")
$reuseaddr
not setsockopt($fh, 1, 2, "\1\0\0\0")
Truth table33%1/3
A and not(B)
A= $reuseaddrB= not setsockopt($fh, 1, 2, "\1\0\0\0")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | && !setsockopt($fh, SOL_SOCKET, SO_REUSEADDR, pack('i', 1))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ($last_errno, $last_operation) = (0 + $!, 'setsockopt'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 20 | ▶ | if ($reuseport | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$reuseport and not setsockopt($fh, 1, 15, "\1\0\0\0")
MC/DC0%0/2
$reuseport and not setsockopt($fh, 1, 15, "\1\0\0\0")
$reuseport
not setsockopt($fh, 1, 15, "\1\0\0\0")
Truth table33%1/3
A and not(B)
A= $reuseportB= not setsockopt($fh, 1, 15, "\1\0\0\0")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | && !setsockopt($fh, SOL_SOCKET, SO_REUSEPORT, pack('i', 1))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | ($last_errno, $last_operation) = (0 + $!, 'setsockopt'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 20 | ▶ | if (defined($v6only) && $candidate->{family} == AF_INET6 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition33%2/6
defined $v6only and $candidate->{"family"} == 10 and not setsockopt($fh, 41, 26, pack("i", $v6only ? 1 : 0))
defined $v6only and $candidate->{"family"} == 10
MC/DC0%0/3
defined $v6only and $candidate->{"family"} == 10 and not setsockopt($fh, 41, 26, pack("i", $v6only ? 1 : 0))
defined $v6only
$candidate->{"family"} == 10
not setsockopt($fh, 41, 26, pack("i", $v6only ? 1 : 0))
Truth table25%1/4
A and B and not(C)
A= defined $v6onlyB= $candidate->{"family"} == 10C= not setsockopt($fh, 41, 26, pack("i", $v6only ? 1 : 0))
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | && !setsockopt( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | $fh, IPPROTO_IPV6, IPV6_V6ONLY, pack('i', $v6only ? 1 : 0), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | )) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ($last_errno, $last_operation) = (0 + $!, 'setsockopt'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 20 | ▶ | if (defined $bind_device) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | my $ok = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | Linux::Event::_SocketConfig::bind_device($fh, $bind_device); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | ▶ | if (!$ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my $error = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | die $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 20 | ▶ | if (!bind($fh, $candidate->{addr})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | ($last_errno, $last_operation) = (0 + $!, 'bind'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 20 | ▶ | if (!listen($fh, $backlog)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ($last_errno, $last_operation) = (0 + $!, 'listen'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 20 | return ($fh, $candidate->{family}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 1 | ▶ | die Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $v6only and not $compatible
MC/DC0%0/2
defined $v6only and not $compatible
defined $v6only
not $compatible
Truth table33%1/3
A and not(B)
A= defined $v6onlyB= not $compatible
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | type => 'socket_configuration', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | operation => 'setsockopt', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | option => 'v6only', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | message => 'v6only requires an IPv6 bind address', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | host => $host, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | port => $port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | ) if defined($v6only) && !$compatible; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | ▶ | $last_errno //= Errno::EADDRNOTAVAIL(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$last_errno //= 99
MC/DC0%0/1
$last_errno //= 99
$last_errno
Truth table0%0/2
A
A= $last_errno
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | $last_operation //= 'bind'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$last_operation //= "bind"
MC/DC0%0/1
$last_operation //= "bind"
$last_operation
Truth table0%0/2
A
A= $last_operation
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | _setup_error( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | operation => $last_operation, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | errno => $last_errno, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | message => _message($last_errno), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | host => $host, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | port => $port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | 2 | ▶ | sub _create_unix_listener ($path, $backlog, $unlink_existing, $permissions) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_create_unix_listener: called CC=11 SCAR=38.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 2 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | croak "new(): Unix path already exists: $path" if !$unlink_existing; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | ▶ | croak "new(): refusing to unlink non-socket path: $path" if !-S $path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | ▶ | unlink($path) or _setup_error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | operation => 'unlink', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | errno => 0 + $!, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | message => _message(0 + $!), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | path => $path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 2 | ▶ | socket(my $fh, AF_UNIX, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | SOCK_STREAM | SOCK_NONBLOCK | SOCK_CLOEXEC, 0) or _setup_error( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | operation => 'socket', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | errno => 0 + $!, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | message => _message(0 + $!), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | path => $path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 2 | ▶ | if (!bind($fh, pack_sockaddr_un($path))) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | my $errno = 0 + $!; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | _setup_error( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | operation => 'bind', errno => $errno, message => _message($errno), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | path => $path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 2 | ▶ | if (defined($permissions) && !chmod($permissions, $path)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/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 table66%2/3
A and not(B)
A= defined $permissionsB= not chmod($permissions, $path)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | my $errno = 0 + $!; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | unlink $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | _setup_error( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | operation => 'chmod', errno => $errno, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | message => _message($errno), path => $path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 2 | ▶ | if (!listen($fh, $backlog)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | my $errno = 0 + $!; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | 0 | close $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | unlink $path; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | _setup_error( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | operation => 'listen', errno => $errno, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | message => _message($errno), path => $path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | 2 | return ($fh, AF_UNIX); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 38 | ▶ | sub new ($class, %opt) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=61 SCAR=48.5
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 38 | ▶ | croak 'new(): must be called as a class method' if ref $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 38 | my $loop = delete $opt{loop}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 38 | ▶ | croak 'new(): 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')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | if defined($loop) && (!ref($loop) || !$loop->can('add') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | || !$loop->can('watch')); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | my $stream_class = delete $opt{stream_class} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 38 | ▶ | // croak 'new(): missing stream_class'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $opt{"stream_class"} // croak("new(): missing stream_class")
MC/DC0%0/1
delete $opt{"stream_class"} // croak("new(): missing stream_class")
delete $opt{"stream_class"}
Truth table50%1/2
A
A= delete $opt{"stream_class"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 38 | ▶ | croak 'new(): stream_class must name a Linux::Event::Stream subclass' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $stream_class or not $stream_class->isa("Linux::Event::Stream")
MC/DC0%0/2
ref $stream_class or not $stream_class->isa("Linux::Event::Stream")
ref $stream_class
not $stream_class->isa("Linux::Event::Stream")
Truth table33%1/3
A or not(B)
A= ref $stream_classB= not $stream_class->isa("Linux::Event::Stream")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | if ref($stream_class) || !$stream_class->isa('Linux::Event::Stream'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | 38 | $stream_class->_validate_accepted_configuration; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 36 | my $descriptor = _descriptor_for($class); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 36 | my %known = map { $_ => 1 } qw( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | loop data backlog max_accept_per_tick edge_triggered | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | reuseaddr reuseport v6only unlink unlink_on_close permissions | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | fh owns_socket host port unix bind_device | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 36 | my @unknown = sort grep { !$known{$_} } keys %opt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 36 | ▶ | croak 'new(): unknown options: ' . join(', ', @unknown) if @unknown; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 35 | my %supplied = map { $_ => exists $opt{$_} } keys %opt; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 35 | my $data = delete $opt{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 35 | ▶ | my $backlog = _integer('backlog', delete($opt{backlog}) // 4096, 1); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $opt{"backlog"} // 4096
MC/DC0%0/1
delete $opt{"backlog"} // 4096
delete $opt{"backlog"}
Truth table50%1/2
A
A= delete $opt{"backlog"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | my $maximum = _integer( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | 35 | ▶ | 'max_accept_per_tick', delete($opt{max_accept_per_tick}) // 256, 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $opt{"max_accept_per_tick"} // 256
MC/DC100%1/1
delete $opt{"max_accept_per_tick"} // 256
delete $opt{"max_accept_per_tick"}
Truth table100%2/2
A
A= delete $opt{"max_accept_per_tick"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | my $edge = _boolean( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 35 | ▶ | 'edge_triggered', delete($opt{edge_triggered}) // 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $opt{"edge_triggered"} // 0
MC/DC100%1/1
delete $opt{"edge_triggered"} // 0
delete $opt{"edge_triggered"}
Truth table100%2/2
A
A= delete $opt{"edge_triggered"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 35 | ▶ | croak 'new(): edge_triggered requires max_accept_per_tick => 0' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$edge and $maximum
MC/DC50%1/2
$edge and $maximum
$edge
$maximum
Truth table66%2/3
A and B
A= $edgeB= $maximum
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | if $edge && $maximum; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | my $reuseaddr = _boolean( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 34 | ▶ | 'reuseaddr', exists($opt{reuseaddr}) ? delete($opt{reuseaddr}) : 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 34 | ▶ | my $reuseport = _boolean('reuseport', delete($opt{reuseport}) // 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $opt{"reuseport"} // 0
MC/DC0%0/1
delete $opt{"reuseport"} // 0
delete $opt{"reuseport"}
Truth table50%1/2
A
A= delete $opt{"reuseport"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 34 | my $v6only = delete $opt{v6only}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 34 | ▶ | $v6only = _boolean('v6only', $v6only) if defined $v6only; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 34 | ▶ | my $unlink_existing = _boolean('unlink', delete($opt{unlink}) // 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
delete $opt{"unlink"} // 0
MC/DC0%0/1
delete $opt{"unlink"} // 0
delete $opt{"unlink"}
Truth table50%1/2
A
A= delete $opt{"unlink"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | my $unlink_on_close = exists($opt{unlink_on_close}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 34 | ▶ | ? _boolean('unlink_on_close', delete($opt{unlink_on_close})) : 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 34 | my $permissions = delete $opt{permissions}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 34 | ▶ | $permissions = _integer('permissions', $permissions, 0, 07777) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | if defined $permissions; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | 34 | my $bind_device = delete $opt{bind_device}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 34 | ▶ | croak 'new(): 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | if defined($bind_device) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | && (ref($bind_device) || $bind_device eq '' || $bind_device =~ /\0/); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 34 | my $fh_mode = exists $opt{fh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 34 | ▶ | my $host_mode = exists($opt{host}) || exists($opt{port}); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
exists $opt{'host'} || exists $opt{'port'}
MC/DC50%1/2
exists $opt{'host'} || exists $opt{'port'}
exists $opt{'host'}
exists $opt{'port'}
Truth table66%2/3
A || B
A= exists $opt{'host'}B= exists $opt{'port'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 34 | my $unix_mode = exists $opt{unix}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 34 | ▶ | my $mode_count = ($fh_mode ? 1 : 0) + ($host_mode ? 1 : 0) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | + ($unix_mode ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 34 | ▶ | croak 'new(): exactly one socket source is required ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | . '(fh, host/port, or unix)' if $mode_count != 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 32 | my @inapplicable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 32 | ▶ | if ($fh_mode) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 4 | @inapplicable = grep { $supplied{$_} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | qw(backlog reuseaddr reuseport v6only unlink unlink_on_close | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | permissions); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | } elsif ($host_mode) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 25 | @inapplicable = grep { $supplied{$_} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | qw(owns_socket unlink unlink_on_close permissions); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 3 | @inapplicable = grep { $supplied{$_} } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | qw(owns_socket reuseaddr reuseport v6only bind_device); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 32 | ▶ | croak 'new(): options not valid for this socket source: ' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | . join(', ', @inapplicable) if @inapplicable; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | 31 | my ($fh, $host, $port, $path, $family, $owns_socket); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | 31 | ▶ | if ($fh_mode) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | 4 | $fh = delete $opt{fh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 4 | ▶ | croak 'new(): fh must be a 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | if !defined($fh) || !defined(fileno($fh)); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 4 | my $accepting = getsockopt($fh, SOL_SOCKET, SO_ACCEPTCONN); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 4 | ▶ | croak 'new(): fh is not a listening socket' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $accepting and unpack "i", $accepting
MC/DC0%0/2
defined $accepting and unpack "i", $accepting
defined $accepting
unpack "i", $accepting
Truth table33%1/3
A and B
A= defined $acceptingB= unpack "i", $accepting
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | if !defined($accepting) || !unpack('i', $accepting); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | $owns_socket = _boolean( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 4 | ▶ | 'owns_socket', delete($opt{owns_socket}) // 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
delete $opt{"owns_socket"} // 0
MC/DC100%1/1
delete $opt{"owns_socket"} // 0
delete $opt{"owns_socket"}
Truth table100%2/2
A
A= delete $opt{"owns_socket"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 4 | my $local = Linux::Event::Address->new(getsockname($fh)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 4 | $family = $local->family_number; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 4 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | if !defined($family) || ($family != AF_INET | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | && $family != AF_INET6 && $family != AF_UNIX); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 4 | ▶ | croak 'new(): bind_device is valid only for TCP listeners' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $bind_device and $family != 2 and $family != 10
defined $bind_device and $family != 2
MC/DC0%0/3
defined $bind_device and $family != 2 and $family != 10
defined $bind_device
$family != 2
$family != 10
Truth table25%1/4
A and B and C
A= defined $bind_deviceB= $family != 2C= $family != 10
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | if defined($bind_device) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | && $family != AF_INET && $family != AF_INET6; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 4 | _set_adopted_flags($fh); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 4 | ▶ | Linux::Event::_SocketConfig::bind_device($fh, $bind_device) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | if defined $bind_device; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | 4 | $host = $local->host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | 4 | $port = $local->port; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | } elsif ($host_mode) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 24 | $host = delete $opt{host}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 24 | $port = delete $opt{port}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 24 | ▶ | croak 'new(): host is required' if !defined $host; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 24 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | if ref($host) || $host eq '' || $host =~ /\0/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | 23 | $port = _integer('port', $port, 0, 65535); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 21 | ($fh, $family) = _create_inet_listener( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | $host, $port, $backlog, $reuseaddr, $reuseport, $v6only, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | $bind_device, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 20 | my $local = Linux::Event::Address->new(getsockname($fh)); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | 20 | $host = $local->host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 20 | $port = $local->port; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 20 | $owns_socket = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 3 | $path = delete $opt{unix}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 3 | ▶ | 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
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | if !defined($path) || ref($path) || $path eq '' || $path =~ /\0/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | 2 | ($fh, $family) = _create_unix_listener( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | $path, $backlog, $unlink_existing, $permissions, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 2 | $owns_socket = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 26 | ▶ | croak 'new(): unknown options: ' . join(', ', sort keys %opt) if %opt; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 26 | ▶ | my $self = bless { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
defined $path and $unlink_on_close
MC/DC50%1/2
defined $path and $unlink_on_close
defined $path
$unlink_on_close
Truth table66%2/3
A and B
A= defined $pathB= $unlink_on_close
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | descriptor => $descriptor, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | stream_class => $stream_class, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | loop => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | data => $data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | fh => $fh, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | family => _family_name($family), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | family_number => $family, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | host => $host, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | port => $port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | unix => $path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | backlog => $backlog, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | max_accept_per_tick => $maximum, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | edge_triggered => $edge, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | owns_socket => $owns_socket ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | unlink_on_close => (defined($path) && $unlink_on_close) ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | state => 'unattached', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | watcher => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | accepted => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | last_error => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 26 | ▶ | $self->_attach_to_loop($loop) if $loop; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 26 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | sub stream_class ($self) { $self->{stream_class} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
stream_class: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 1038 | ▶ | sub _accept_client ($self, $fh, $peer) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_accept_client: called CC=10 SCAR=23.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 1038 | my $class = $self->{stream_class}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 1038 | my $stream; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 1038 | my $prepared = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 1038 | $stream = $class->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | fh => $fh, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | peer => $peer, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | data => $self->data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | _accepted => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 1038 | $stream->_attach_to_loop($self->loop); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 1037 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 1038 | ▶ | if (!$prepared) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 1 | my $failure = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 1 | ▶ | eval { $stream->close; 1 } if $stream; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 1 | ▶ | my $error = blessed($failure) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition40%2/5
builtin::blessed($failure) and $failure->isa("Linux::Event::Error")
"$failure" || 'accepted Stream setup 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" || 'accepted Stream setup failed'
"$failure"
Truth table33%1/3
A and B
A= builtin::blessed($failure)B= $failure->isa("Linux::Event::Error")
Truth table50%1/2
A
A= "$failure"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | && $failure->isa('Linux::Event::Error') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | ? $failure | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | : Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | type => 'setup', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | operation => 'accepted_stream', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | message => "$failure" || 'accepted Stream setup failed', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | fatal => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | host => $self->host, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | port => $self->port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | family => $self->family, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 1 | $self->{last_error} = $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 1 | $self->{descriptor}{on_error}->($self, $error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 1037 | ▶ | if (my $callback = $self->{descriptor}{on_accept}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | 4 | my $ok = eval { $callback->($self, $stream); 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 4 | ▶ | if (!$ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 1 | my $message = "$@"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 1 | $message =~ s/\s+\z//; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 1 | ▶ | $message = 'on_accept callback failed' if $message eq ''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 1 | eval { $stream->close; 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 1 | my $error = Linux::Event::Error->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | type => 'callback', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | operation => 'on_accept', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | message => $message, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | fatal => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | host => $self->host, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | port => $self->port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | path => $self->path, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | family => $self->family, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 1 | $self->{last_error} = $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | 1 | $self->{descriptor}{on_error}->($self, $error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | 1036 | ▶ | $stream->_fire_ready if !$stream->transport; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 1036 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 2 | ▶ | sub on_error ($self, $error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
on_error: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 2 | die "listener failed: $error\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | ▶ | sub CLONE_SKIP ($class) { 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
CLONE_SKIP: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 24 | ▶ | sub _attach_to_loop ($self, $loop) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_attach_to_loop: called CC=8 SCAR=21.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | croak 'add(): Listener is not unattached' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 24 | ▶ | if $self->{state} ne 'unattached' || $self->{loop}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"state"} ne "unattached" or $self->{"loop"}
MC/DC50%1/2
$self->{"state"} ne "unattached" or $self->{"loop"}
$self->{"state"} ne "unattached"
$self->{"loop"}
Truth table66%2/3
A or B
A= $self->{"state"} ne "unattached"B= $self->{"loop"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 23 | my $watcher = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | $loop->watch( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | fh => $self->{fh}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | _internal => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | data => $self, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | read => \&_accept_ready, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | error => \&_listener_error_ready, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 23 | ▶ | edge_triggered => $self->{edge_triggered} ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | _callback_data_arg => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 23 | ▶ | if (!$watcher) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 1 | ▶ | my $failure = $@ || 'could not register Listener socket'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$@ || 'could not register Listener socket'
MC/DC0%0/1
$@ || 'could not register Listener socket'
$@
Truth table50%1/2
A
A= $@
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 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")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | && $failure->isa('Linux::Event::Error'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | die Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | type => 'setup', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | operation => 'watch', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | fatal => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | message => "$failure", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | host => $self->{host}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | port => $self->{port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | path => $self->{unix}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | family => $self->{family}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 22 | $self->{loop} = $loop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 22 | $self->{watcher} = $watcher; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 22 | $self->{state} = 'listening'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 22 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 1065 | ▶ | sub loop ($self) { $self->{loop} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
loop: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | ▶ | sub fh ($self) { $self->{fh} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fh: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 8 | ▶ | sub fd ($self) { defined($self->{fh}) ? fileno($self->{fh}) : undef } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fd: called CC=2 SCAR=6.9
Pod
documented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | 6 | ▶ | sub host ($self) { $self->{host} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
host: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 28 | ▶ | sub port ($self) { $self->{port} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
port: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 4 | ▶ | sub path ($self) { $self->{unix} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
path: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 7 | ▶ | sub family ($self) { $self->{family} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
family: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 2 | ▶ | sub family_number ($self) { $self->{family_number} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
family_number: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 2 | ▶ | sub is_tcp ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_tcp: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 2 | ▶ | return $self->{family} eq 'inet' || $self->{family} eq 'inet6'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition66%2/3
$self->{'family'} eq 'inet' || $self->{'family'} eq 'inet6'
MC/DC50%1/2
$self->{'family'} eq 'inet' || $self->{'family'} eq 'inet6'
$self->{'family'} eq 'inet'
$self->{'family'} eq 'inet6'
Truth table66%2/3
A || B
A= $self->{'family'} eq 'inet'B= $self->{'family'} eq 'inet6'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 2 | ▶ | sub is_unix ($self) { return $self->{family} eq 'unix' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_unix: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 14 | ▶ | sub state ($self) { $self->{state} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
state: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | 5 | ▶ | sub accepted ($self) { $self->{accepted} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
accepted: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | 1 | ▶ | sub last_error ($self) { $self->{last_error} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
last_error: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 4 | ▶ | sub is_paused ($self) { $self->{state} eq 'paused' } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_paused: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 2 | ▶ | sub is_running ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_running: called CC=2 SCAR=9.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 2 | ▶ | return $self->{state} eq 'listening' || $self->{state} eq 'paused'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$self->{'state'} eq 'listening' || $self->{'state'} eq 'paused'
MC/DC0%0/2
$self->{'state'} eq 'listening' || $self->{'state'} eq 'paused'
$self->{'state'} eq 'listening'
$self->{'state'} eq 'paused'
Truth table33%1/3
A || B
A= $self->{'state'} eq 'listening'B= $self->{'state'} eq 'paused'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 71 | ▶ | sub is_terminal ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_terminal: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | return $self->{state} eq 'closed' || $self->{state} eq 'failed' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 71 | ▶ | || $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'
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 1042 | ▶ | sub data ($self, @arg) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
data: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 1042 | ▶ | $self->{data} = $arg[0] if @arg; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 1042 | return $self->{data}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 1 | ▶ | sub pause ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pause: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 1 | ▶ | return $self if $self->{state} ne 'listening'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 1 | ▶ | $self->{watcher}->disable_read if $self->{watcher}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 1 | $self->{state} = 'paused'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 1 | ▶ | sub resume ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resume: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 1 | ▶ | return $self if $self->{state} ne 'paused'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 1 | ▶ | $self->{watcher}->enable_read if $self->{watcher}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 1 | $self->{state} = 'listening'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | ▶ | sub _close_batch_tail ($batch, $at) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_close_batch_tail: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | ▶ | while ($at < @$batch) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 0 | my $fd = $batch->[$at]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | __PACKAGE__->_close_fd($fd); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | $at += 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 81 | ▶ | sub _accept_ready ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_accept_ready: called CC=8 SCAR=24.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 81 | ▶ | return if $self->{state} ne 'listening'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | my $batch = __PACKAGE__->_accept4_batch( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | fileno($self->{fh}), $self->{max_accept_per_tick}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 81 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 81 | my $errno = $batch->[0]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 81 | my $at = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 81 | ▶ | while ($at < @$batch) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | 1038 | my $fd = $batch->[$at++]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 1038 | my $sockaddr = $batch->[$at++]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 1038 | ▶ | if ($self->{state} ne 'listening') { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | __PACKAGE__->_close_fd($fd); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | _close_batch_tail($batch, $at); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | 1038 | ▶ | open(my $client, '+<&=', $fd) or do { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | my $open_errno = 0 + $!; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | __PACKAGE__->_close_fd($fd); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | _close_batch_tail($batch, $at); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | die "failed to create accepted filehandle: " | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | . _message($open_errno); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 1038 | my $peer = Linux::Event::Address->new($sockaddr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 1038 | $self->{accepted}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 1038 | my $callback = $self->{descriptor}{accept_client}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 1038 | my $ok = eval { $callback->($self, $client, $peer); 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | 1038 | my $callback_error = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 1038 | ▶ | if (!$ok) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | close $client; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | _close_batch_tail($batch, $at); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | die $callback_error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 81 | ▶ | $self->_accept_error($errno) if $errno && $self->{state} eq 'listening'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$errno and $self->{"state"} eq "listening"
MC/DC0%0/2
$errno and $self->{"state"} eq "listening"
$errno
$self->{"state"} eq "listening"
Truth table33%1/3
A and B
A= $errnoB= $self->{"state"} eq "listening"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 81 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | ▶ | sub _accept_error ($self, $errno) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_accept_error: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | ▶ | my $resource = $errno == Errno::EMFILE() || $errno == Errno::ENFILE() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/9
$errno == 24 || $errno == 23 || $errno == 105 || $errno == 12
$errno == 24 or $errno == 23 or $errno == 105
$errno == 24 or $errno == 23
MC/DC0%0/4
$errno == 24 || $errno == 23 || $errno == 105 || $errno == 12
$errno == 24
$errno == 23
$errno == 105
$errno == 12
Truth table0%0/5
A or B or C || D
A= $errno == 24B= $errno == 23C= $errno == 105D= $errno == 12
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | || $errno == Errno::ENOBUFS() || $errno == Errno::ENOMEM(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | my $error = Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | type => $resource ? 'resource' : 'accept', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | operation => 'accept', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | errno => $errno, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | message => _message($errno), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | fatal => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | host => $self->{host}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | port => $self->{port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | path => $self->{unix}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | $self->{last_error} = $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | ▶ | $self->pause if $resource; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | $self->{descriptor}{on_error}->($self, $error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 2 | ▶ | sub _listener_error_ready ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_listener_error_ready: called CC=7 SCAR=20.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 2 | ▶ | return if !$self->is_running; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 2 | my $raw = getsockopt($self->{fh}, SOL_SOCKET, SO_ERROR); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 2 | ▶ | my $errno = defined($raw) && length($raw) >= 4 ? unpack('i', $raw) : 0 + $!; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $raw and length $raw >= 4
MC/DC0%0/2
defined $raw and length $raw >= 4
defined $raw
length $raw >= 4
Truth table33%1/3
A and B
A= defined $rawB= length $raw >= 4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | my $error = Linux::Event::Error->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | type => 'listener', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | operation => 'watch', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | errno => $errno || undef, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | message => $errno ? _message($errno) : 'listener socket closed', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | fatal => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | host => $self->{host}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | port => $self->{port}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | path => $self->{unix}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 2 | ▶ | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%1/2
$errno || undef
MC/DC0%0/1
$errno || undef
$errno
Truth table50%1/2
A
A= $errno
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 2 | $self->{last_error} = $error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 2 | $self->_shutdown('failed', 1); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 2 | my $reported = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 2 | $self->{descriptor}{on_error}->($self, $error); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 2 | my $failure = $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 2 | $self->{loop} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | 2 | ▶ | die $failure if !$reported; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | 52 | ▶ | sub _shutdown ($self, $state, $retain_loop = 0) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_shutdown: called CC=10 SCAR=23.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 52 | ▶ | return if $self->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 26 | $self->{state} = $state; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 26 | ▶ | if (my $watcher = delete $self->{watcher}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 22 | $watcher->cancel; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 26 | ▶ | if (defined(my $fh = delete $self->{fh})) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 26 | ▶ | close $fh if $self->{owns_socket}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 26 | ▶ | if (defined($self->{unix}) && $self->{unlink_on_close}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $self->{"unix"} and $self->{"unlink_on_close"}
MC/DC50%1/2
defined $self->{"unix"} and $self->{"unlink_on_close"}
defined $self->{"unix"}
$self->{"unlink_on_close"}
Truth table66%2/3
A and B
A= defined $self->{"unix"}B= $self->{"unlink_on_close"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 2 | ▶ | unlink $self->{unix} if -S $self->{unix}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 26 | ▶ | $self->{loop} = undef if !$retain_loop; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | 26 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 49 | ▶ | sub close ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
close: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 49 | $self->_shutdown('closed'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 49 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 1 | ▶ | sub detach ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
detach: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 1 | ▶ | return undef if $self->is_terminal; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | 1 | my $fh = $self->{fh}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 1 | $self->{owns_socket} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 1 | $self->{unlink_on_close} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 1 | $self->_shutdown('detached'); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | 1 | $self->{fh} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | 1 | return $fh; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 26 | ▶ | sub DESTROY ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 26 | eval { $self->close }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 26 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 19 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||