| 1 | package Linux::Event::HTTP::_QUICSocket; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | 4 | ▶ | use v5.36; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use POSIX qw(isfinite); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use Scalar::Util qw(weaken refaddr looks_like_number); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use Socket qw(AF_INET6 inet_pton); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use Linux::Event::Address; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Linux::Event::IO::Sock::Dgram; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Linux::Event::Kernel::Timer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # This adapter deliberately binds one concrete address. Linux::Event's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # datagram callback has no per-packet destination address for wildcard binds. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # Net::QUIC cannot route a received packet using a wildcard local address. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 1 | ▶ | sub _concrete ($address) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_concrete: called CC=6 SCAR=26.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | return 0 unless $address && ($address->family eq 'inet' || $address->family eq 'inet6'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$address and $address->family eq "inet" || $address->family eq "inet6"
$address->family eq "inet" or $address->family eq "inet6"
MC/DC0%0/3
$address and $address->family eq "inet" || $address->family eq "inet6"
$address
$address->family eq "inet"
$address->family eq "inet6"
Truth table25%1/4
A and B or C
A= $addressB= $address->family eq "inet"C= $address->family eq "inet6"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | my $host = $address->host; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | return $host ne '0.0.0.0' if $address->family eq 'inet'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 0 | my $packed = inet_pton(AF_INET6, $host); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | 0 | ▶ | return defined($packed) && $packed ne ("\0" x 16); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
defined $packed && $packed ne "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
MC/DC0%0/2
defined $packed && $packed ne "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
defined $packed
$packed ne "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
Truth table0%0/3
A && B
A= defined $packedB= $packed ne "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | 2 | ▶ | sub new ($class, %option) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=12 SCAR=32.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | 2 | my $loop = delete $option{loop}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | 2 | my $host = delete $option{host}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | 2 | my $port = delete $option{port}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | 2 | my $on_error = delete $option{on_error}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 2 | my $on_progress = delete $option{on_progress}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 2 | ▶ | croak 'QUIC socket requires loop, host and port' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
$loop and defined $host and defined $port
$loop and defined $host
MC/DC0%0/3
$loop and defined $host and defined $port
$loop
defined $host
defined $port
Truth table25%1/4
A and B and C
A= $loopB= defined $hostC= defined $port
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | unless $loop && defined($host) && defined($port); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 2 | ▶ | croak 'QUIC socket on_error must be a coderef' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $on_error and ref $on_error ne "CODE"
MC/DC0%0/2
defined $on_error and ref $on_error ne "CODE"
defined $on_error
ref $on_error ne "CODE"
Truth table33%1/3
A and B
A= defined $on_errorB= ref $on_error ne "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | if defined($on_error) && ref($on_error) ne 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 2 | ▶ | croak 'QUIC socket on_progress must be a coderef' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $on_progress and ref $on_progress ne "CODE"
MC/DC0%0/2
defined $on_progress and ref $on_progress ne "CODE"
defined $on_progress
ref $on_progress ne "CODE"
Truth table33%1/3
A and B
A= defined $on_progressB= ref $on_progress ne "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | if defined($on_progress) && ref($on_progress) ne 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | ▶ | croak 'QUIC socket unknown options: ' . join(', ', sort keys %option) if %option; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | 2 | ▶ | croak 'QUIC socket requires a concrete local host, not a wildcard address' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$host eq "0.0.0.0" or $host eq "::"
MC/DC50%1/2
$host eq "0.0.0.0" or $host eq "::"
$host eq "0.0.0.0"
$host eq "::"
Truth table66%2/3
A or B
A= $host eq "0.0.0.0"B= $host eq "::"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | if $host eq '0.0.0.0' || $host eq '::'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | 1 | my $self = bless { loop => $loop, on_error => $on_error, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | on_progress => $on_progress }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 1 | my $weak = $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | weaken($weak); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | $self->{socket} = Linux::Event::IO::Sock::Dgram->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | loop => $loop, host => $host, port => $port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 1 | ▶ | on_datagram => sub ($socket, $bytes, $peer) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 1 | ▶ | my $owner = $weak or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 1 | ▶ | my $manager = $owner->{manager} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | $manager->receive($bytes, $owner->{local}, $peer->sockaddr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | $owner->_progress; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 0 | ▶ | on_drain => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 0 | ▶ | my $owner = $weak or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | my $manager = $owner->{manager} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 0 | $manager->writable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 0 | $owner->_progress; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 0 | ▶ | on_error => sub ($socket, $error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | my $owner = $weak or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 0 | ▶ | $owner->{on_error}->($socket, $error) if $owner->{on_error}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 1 | ▶ | on_close => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 1 | ▶ | my $owner = $weak or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 1 | $owner->close; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 1 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 1 | my $local = $self->{socket}->local; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 1 | ▶ | unless (_concrete($local)) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 0 | $self->close; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 0 | croak 'QUIC socket requires a concrete IPv4/IPv6 local address'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 1 | $self->{local} = $local->sockaddr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 2 | ▶ | sub socket ($self) { $self->{socket} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
socket: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 3 | ▶ | sub local ($self) { $self->{local} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
local: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | # A connected socket delegates hostname resolution to Linux::Event's async | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | # datagram resolver. QUIC TLS still authenticates the original HTTP origin. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | sub connect ($class, %option) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
connect: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my $loop = delete $option{loop}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | my $host = delete $option{host}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | my $port = delete $option{port}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | my $on_ready = delete $option{on_ready}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | my $on_error = delete $option{on_error}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my $on_progress = delete $option{on_progress}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | croak 'QUIC connect requires loop, host and port' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$loop and defined $host and defined $port
$loop and defined $host
MC/DC0%0/3
$loop and defined $host and defined $port
$loop
defined $host
defined $port
Truth table0%0/4
A and B and C
A= $loopB= defined $hostC= defined $port
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | unless $loop && defined($host) && defined($port); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | for my $pair ([on_ready => $on_ready], [on_error => $on_error], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | [on_progress => $on_progress]) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | ▶ | croak "QUIC connect $pair->[0] must be a coderef" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $pair->[1] and ref $pair->[1] ne "CODE"
MC/DC0%0/2
defined $pair->[1] and ref $pair->[1] ne "CODE"
defined $pair->[1]
ref $pair->[1] ne "CODE"
Truth table0%0/3
A and B
A= defined $pair->[1]B= ref $pair->[1] ne "CODE"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | if defined($pair->[1]) && ref($pair->[1]) ne 'CODE'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | ▶ | croak 'QUIC connect requires on_ready' unless $on_ready; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | croak 'QUIC connect unknown options: ' . join(', ', sort keys %option) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | if %option; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | my $self = bless { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | loop => $loop, connected => 1, on_error => $on_error, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | on_progress => $on_progress, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | my $weak = $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | weaken($weak); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | $self->{socket} = Linux::Event::IO::Sock::Dgram->connect( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | loop => $loop, host => $host, port => $port, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | on_ready => sub ($socket) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=6 SCAR=37.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | ▶ | my $owner = $weak or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | return if $owner->{closed}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | my $local = $socket->local; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | unless (_concrete($local) && $socket->peer) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
_concrete($local) and $socket->peer
MC/DC0%0/2
_concrete($local) and $socket->peer
_concrete($local)
$socket->peer
Truth table0%0/3
A and B
A= _concrete($local)B= $socket->peer
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | $owner->{on_error}->($socket, 'QUIC client needs a concrete local and peer') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | if $owner->{on_error}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $owner->close; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $owner->{local} = $local->sockaddr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | $owner->{peer} = $socket->peer->sockaddr; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $on_ready->($owner); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | on_datagram => sub ($socket, $bytes, $peer) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | my $owner = $weak or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | my $manager = $owner->{manager} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | $manager->receive($bytes, $owner->{local}, $peer->sockaddr); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | $owner->_progress; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | on_drain => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | ▶ | my $owner = $weak or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | my $manager = $owner->{manager} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $manager->writable; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | $owner->_progress; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | ▶ | on_error => sub ($socket, $error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | my $owner = $weak or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | ▶ | $owner->{on_error}->($socket, $error) if $owner->{on_error}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | on_close => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | my $owner = $weak or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | $owner->close; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | sub peer ($self) { $self->{peer} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
peer: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 4 | ▶ | sub _progress ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_progress: called CC=3 SCAR=13.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 4 | ▶ | $self->{on_progress}->($self) if !$self->{closed} && $self->{on_progress}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $self->{"closed"} and $self->{"on_progress"}
MC/DC0%0/2
not $self->{"closed"} and $self->{"on_progress"}
not $self->{"closed"}
$self->{"on_progress"}
Truth table33%1/3
not(A) and B
A= not $self->{"closed"}B= $self->{"on_progress"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 4 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 1 | ▶ | sub send_callback ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_callback: called CC=1 SCAR=0.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 1 | my $weak = $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 1 | weaken($weak); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | 3 | ▶ | return sub ($packet) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=20.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 3 | ▶ | my $owner = $weak or croak 'QUIC socket no longer exists'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 3 | ▶ | croak 'QUIC socket is closed' if $owner->{closed}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | croak 'QUIC datagram uses a different source address' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 2 | ▶ | if $packet->local ne $owner->{local}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 1 | ▶ | if ($owner->{connected}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | croak 'QUIC datagram uses a different destination address' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | if $packet->peer ne $owner->{peer}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | return $owner->{socket}->send($packet->data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | return $owner->{socket}->send( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 1 | $packet->data, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | to => Linux::Event::Address->new($packet->peer), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 1 | ▶ | sub set_timeout_callback ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_timeout_callback: called CC=1 SCAR=0.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 1 | my $weak = $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 1 | weaken($weak); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 5 | ▶ | return sub ($seconds) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=11.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 5 | ▶ | my $owner = $weak or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 5 | ▶ | return if $owner->{closed}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 5 | $owner->_set_timeout($seconds); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 1 | }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 5 | ▶ | sub _set_timeout ($self, $seconds) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_timeout: called CC=7 SCAR=21.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 5 | ▶ | if (my $old = delete $self->{timer}) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 2 | $old->cancel; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 5 | ▶ | return unless defined $seconds; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 4 | ▶ | croak 'QUIC timeout must be finite, non-negative seconds' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%3/9
not ref $seconds and &looks_like_number($seconds) and isfinite(0 + $seconds) and $seconds >= 0
not ref $seconds and &looks_like_number($seconds) and isfinite(0 + $seconds)
not ref $seconds and &looks_like_number($seconds)
MC/DC0%0/4
not ref $seconds and &looks_like_number($seconds) and isfinite(0 + $seconds) and $seconds >= 0
not ref $seconds
&looks_like_number($seconds)
isfinite(0 + $seconds)
$seconds >= 0
Truth table20%1/5
not(A) and B and C and D
A= not ref $secondsB= &looks_like_number($seconds)C= isfinite(0 + $seconds)D= $seconds >= 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | unless !ref($seconds) && looks_like_number($seconds) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | && isfinite(0 + $seconds) && $seconds >= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 4 | my $weak = $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 4 | weaken($weak); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | $self->{timer} = Linux::Event::Kernel::Timer->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | loop => $self->{loop}, after => $seconds, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 2 | ▶ | on_timer => sub ($timer) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=6 SCAR=19.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 2 | ▶ | my $owner = $weak or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 2 | ▶ | return if $owner->{closed}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 2 | ▶ | my $current = $owner->{timer} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 2 | ▶ | return unless refaddr($current) == refaddr($timer); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 2 | delete $owner->{timer}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 2 | ▶ | my $manager = $owner->{manager} or return; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 2 | $manager->timeout; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 2 | $owner->_progress; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 4 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 1 | ▶ | sub start ($self, $manager) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
start: called CC=5 SCAR=17.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 1 | ▶ | croak 'QUIC socket has been closed' if $self->{closed}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 1 | ▶ | croak 'QUIC socket already started' if $self->{manager}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | croak 'QUIC manager must implement start, receive, timeout and writable' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 1 | ▶ | unless ref($manager) && !grep { !$manager->can($_) } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $manager and not grep({not $manager->can($_);} "start", "receive", "timeout", "writable")
MC/DC0%0/2
ref $manager and not grep({not $manager->can($_);} "start", "receive", "timeout", "writable")
ref $manager
not grep({not $manager->can($_);} "start", "receive", "timeout", "writable")
Truth table33%1/3
A and not(B)
A= ref $managerB= not grep({not $manager->can($_);} "start", "receive", "timeout", "writable")
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | qw(start receive timeout writable); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 1 | $self->{manager} = $manager; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 1 | $manager->start; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 1 | $self->_progress; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | 3 | ▶ | sub close ($self) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
close: called CC=5 SCAR=16.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 3 | ▶ | return $self if $self->{closed}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 1 | my $timer = delete $self->{timer}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 1 | ▶ | $timer->cancel if $timer; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | 1 | delete $self->{manager}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 1 | delete $self->{on_progress}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 1 | delete $self->{on_error}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 1 | my $socket = delete $self->{socket}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 1 | ▶ | $socket->close if $socket && $socket->is_active; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$socket and $socket->is_active
MC/DC0%0/2
$socket and $socket->is_active
$socket
$socket->is_active
Truth table33%1/3
A and B
A= $socketB= $socket->is_active
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||