| 1 | package Unblock::HTTP1::_Engine; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 30 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 30 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 30 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 30 | ▶ | use utf8 (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 30 | ▶ | use Scalar::Util qw(weaken); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||||||||||||||||
| 9 | 119 | ▶ | sub _init_engine { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_init_engine: called CC=22 SCAR=31.8
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 119 | my ($self, %option) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 11 | 119 | my $transport = delete $option{transport}; | |||||||||||||||||||||||||||||||||||||||||
| 12 | 119 | ▶ | if (defined $transport) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 18 | ▶ | croak 'new(): transport must be an object' unless ref $transport; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 18 | for my $method (qw(unblock_send unblock_finish unblock_abort)) { | |||||||||||||||||||||||||||||||||||||||||
| 15 | 54 | ▶ | croak "new(): transport must implement $method()" | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 16 | unless $transport->can($method); | ||||||||||||||||||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||||||||||||||||
| 18 | } | ||||||||||||||||||||||||||||||||||||||||||
| 19 | 119 | my %known = map { $_ => 1 } qw( | |||||||||||||||||||||||||||||||||||||||||
| 20 | max_head_size | ||||||||||||||||||||||||||||||||||||||||||
| 21 | max_headers | ||||||||||||||||||||||||||||||||||||||||||
| 22 | max_chunk_extension_size | ||||||||||||||||||||||||||||||||||||||||||
| 23 | high_water | ||||||||||||||||||||||||||||||||||||||||||
| 24 | low_water | ||||||||||||||||||||||||||||||||||||||||||
| 25 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 26 | 119 | for my $key (sort keys %option) { | |||||||||||||||||||||||||||||||||||||||||
| 27 | 11 | ▶ | croak "new(): unknown option '$key'" unless $known{$key}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | } | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 118 | ▶ | $self->{max_head_size} = exists $option{max_head_size} ? $option{max_head_size} : 65_536; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 118 | ▶ | $self->{max_headers} = exists $option{max_headers} ? $option{max_headers} : 100; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | $self->{max_chunk_extension_size} = exists $option{max_chunk_extension_size} | ||||||||||||||||||||||||||||||||||||||||||
| 32 | 118 | ▶ | ? $option{max_chunk_extension_size} : 16_384; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 118 | ▶ | $self->{high_water} = exists $option{high_water} ? $option{high_water} : 65_536; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 118 | ▶ | $self->{low_water} = exists $option{low_water} ? $option{low_water} : 32_768; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 35 | 118 | for my $key (qw(max_head_size max_headers max_chunk_extension_size high_water low_water)) { | |||||||||||||||||||||||||||||||||||||||||
| 36 | croak "new(): $key must be a non-negative integer" | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 590 | ▶ | unless defined($self->{$key}) && !ref($self->{$key}) && $self->{$key} =~ /\A[0-9]+\z/; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $self->{$key} and not ref $self->{$key} and $self->{$key} =~ /\A[0-9]+\z/
defined $self->{$key} and not ref $self->{$key}
MC/DC0%0/3
defined $self->{$key} and not ref $self->{$key} and $self->{$key} =~ /\A[0-9]+\z/
defined $self->{$key}
not ref $self->{$key}
$self->{$key} =~ /\A[0-9]+\z/
Truth table25%1/4
A and not(B) and C
A= defined $self->{$key}B= not ref $self->{$key}C= $self->{$key} =~ /\A[0-9]+\z/
| |||||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | 118 | ▶ | croak 'new(): max_head_size must be positive' unless $self->{max_head_size} > 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 40 | croak 'new(): max_headers must be between 1 and 256' | ||||||||||||||||||||||||||||||||||||||||||
| 41 | 118 | ▶ | unless $self->{max_headers} >= 1 && $self->{max_headers} <= 256; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"max_headers"} >= 1 and $self->{"max_headers"} <= 256
MC/DC0%0/2
$self->{"max_headers"} >= 1 and $self->{"max_headers"} <= 256
$self->{"max_headers"} >= 1
$self->{"max_headers"} <= 256
Truth table33%1/3
A and B
A= $self->{"max_headers"} >= 1B= $self->{"max_headers"} <= 256
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | croak 'new(): low_water must not exceed high_water' | ||||||||||||||||||||||||||||||||||||||||||
| 43 | 118 | ▶ | if $self->{low_water} > $self->{high_water}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | 118 | $self->{transport} = $transport; | |||||||||||||||||||||||||||||||||||||||||
| 45 | 118 | ▶ | weaken($self->{transport}) if defined $transport; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 46 | 118 | ▶ | $self->{transport_attached} = defined($transport) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 118 | $self->{transport_blocked} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 48 | 118 | $self->{transport_syncing} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 49 | 118 | $self->{transport_finished} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 50 | 118 | $self->{transport_aborted} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 51 | 118 | $self->{switch_notice} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 52 | 118 | $self->{input} = ''; | |||||||||||||||||||||||||||||||||||||||||
| 53 | 118 | $self->{output} = ''; | |||||||||||||||||||||||||||||||||||||||||
| 54 | 118 | $self->{closed} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 55 | 118 | $self->{switched} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 56 | 118 | $self->{remainder} = ''; | |||||||||||||||||||||||||||||||||||||||||
| 57 | 118 | $self->{driving} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 58 | 118 | $self->{eof} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 59 | 118 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 31 | ▶ | sub is_closed { $_[0]{closed} ? 1 : 0 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_closed: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 63 | 13 | ▶ | sub is_switched { $_[0]{switched} ? 1 : 0 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_switched: called CC=2 SCAR=6.9
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | ▶ | sub want_read { !$_[0]{closed} && !$_[0]{switched} && !$_[0]{eof} ? 1 : 0 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
want_read: not called CC=4 SCAR=30.0
Pod
undocumented
Branch: 1 branch
Condition0%0/6
$_[0]{'closed'} || $_[0]{'switched'} || $_[0]{'eof'}
$_[0]{"closed"} or $_[0]{"switched"}
MC/DC0%0/3
$_[0]{'closed'} || $_[0]{'switched'} || $_[0]{'eof'}
$_[0]{"closed"}
$_[0]{"switched"}
$_[0]{'eof'}
Truth table0%0/4
A or B || C
A= $_[0]{"closed"}B= $_[0]{"switched"}C= $_[0]{'eof'}
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 2 | ▶ | sub want_write { length($_[0]{output}) ? 1 : 0 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
want_write: called CC=2 SCAR=7.6
Pod
undocumented
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | 456 | ▶ | sub input { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
input: called CC=11 SCAR=25.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 68 | 456 | my ($self, $bytes) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 69 | 456 | ▶ | croak 'input(): bytes must be a scalar' if ref($bytes); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 70 | 456 | ▶ | $bytes = '' unless defined $bytes; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 71 | 456 | my $copy = "$bytes"; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 456 | ▶ | croak 'input(): bytes must be a byte string' unless utf8::downgrade($copy, 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 73 | 456 | ▶ | return 0 unless length $copy; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | croak 'input(): cannot be called recursively from an engine callback or host send' | ||||||||||||||||||||||||||||||||||||||||||
| 75 | 456 | ▶ | if $self->{driving} || $self->{transport_syncing}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"driving"} or $self->{"transport_syncing"}
MC/DC100%2/2
$self->{"driving"} or $self->{"transport_syncing"}
$self->{"driving"}
$self->{"transport_syncing"}
Truth table100%3/3
A or B
A= $self->{"driving"}B= $self->{"transport_syncing"}
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 453 | ▶ | croak 'input(): read side is already at EOF' if $self->{eof}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 77 | 453 | ▶ | if ($self->{switched}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | $self->{remainder} .= $copy; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | return length $copy; | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | 453 | ▶ | croak 'input(): connection is closed' if $self->{closed}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 82 | 453 | $self->{input} .= $copy; | |||||||||||||||||||||||||||||||||||||||||
| 83 | { | ||||||||||||||||||||||||||||||||||||||||||
| 84 | 453 | local $self->{driving} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 85 | 453 | $self->_drive; | |||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||
| 87 | 453 | ▶ | $self->_transport_sync if $self->{transport_attached}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 453 | return length $copy; | |||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | 10 | ▶ | sub _input_borrowed { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_input_borrowed: called CC=17 SCAR=39.4
| |||||||||||||||||||||||||||||||||||||||||||
| 92 | 10 | my ($self, $window, $length, $head, $message) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 93 | croak '_input_borrowed(): cannot be called recursively from an engine callback or host send' | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 10 | ▶ | if $self->{driving} || $self->{transport_syncing}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"driving"} or $self->{"transport_syncing"}
MC/DC0%0/2
$self->{"driving"} or $self->{"transport_syncing"}
$self->{"driving"}
$self->{"transport_syncing"}
Truth table33%1/3
A or B
A= $self->{"driving"}B= $self->{"transport_syncing"}
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 10 | ▶ | return (4, 0, 0) if $self->{switched}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 10 | ▶ | return (3, 0, 0) if $self->{closed}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | 10 | ▶ | if (length $self->{input}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | croak '_input_borrowed(): buffered fallback requires a native input window' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
ref $window and $window->isa("Unblock::HTTP1::_Native::BorrowedWindow")
MC/DC0%0/2
ref $window and $window->isa("Unblock::HTTP1::_Native::BorrowedWindow")
ref $window
$window->isa("Unblock::HTTP1::_Native::BorrowedWindow")
Truth table0%0/3
A and B
A= ref $windowB= $window->isa("Unblock::HTTP1::_Native::BorrowedWindow")
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | unless ref($window) | ||||||||||||||||||||||||||||||||||||||||||
| 100 | && $window->isa('Unblock::HTTP1::_Native::BorrowedWindow'); | ||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | $self->{input} .= $window->slice(0, $length); | |||||||||||||||||||||||||||||||||||||||||
| 102 | { | ||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | local $self->{driving} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | $self->_drive; | |||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | 0 | ▶ | $self->_transport_sync if $self->{transport_attached}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | my $status = $self->{closed} ? 3 : $self->{switched} ? 4 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | return ($status, $length, $self->_borrowed_native_head_ready); | |||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | 10 | my ($status, $consumed, $head_ready); | |||||||||||||||||||||||||||||||||||||||||
| 113 | { | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 10 | local $self->{borrowed_input} = $window; | |||||||||||||||||||||||||||||||||||||||||
| 115 | 10 | local $self->{borrowed_length} = $length; | |||||||||||||||||||||||||||||||||||||||||
| 116 | 10 | local $self->{borrowed_offset} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 117 | 10 | local $self->{borrowed_head} = $head; | |||||||||||||||||||||||||||||||||||||||||
| 118 | 10 | local $self->{borrowed_message} = $message; | |||||||||||||||||||||||||||||||||||||||||
| 119 | 10 | local $self->{driving} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 120 | 10 | $self->_drive; | |||||||||||||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||||||||||||
| 122 | 10 | my $remaining = $self->_input_length; | |||||||||||||||||||||||||||||||||||||||||
| 123 | 10 | ▶ | if ($self->{closed}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | $status = 3; | |||||||||||||||||||||||||||||||||||||||||
| 125 | } elsif ($self->{switched}) { | ||||||||||||||||||||||||||||||||||||||||||
| 126 | 3 | $status = 4; | |||||||||||||||||||||||||||||||||||||||||
| 127 | ▶ | } elsif ($remaining && $self->_borrowed_should_buffer_tail) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition33%1/3
$remaining and $self->_borrowed_should_buffer_tail
MC/DC0%0/2
$remaining and $self->_borrowed_should_buffer_tail
$remaining
$self->_borrowed_should_buffer_tail
Truth table33%1/3
A and B
A= $remainingB= $self->_borrowed_should_buffer_tail
| |||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | $self->{input} .= $self->_input_take($remaining); | |||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | $status = 0; | |||||||||||||||||||||||||||||||||||||||||
| 130 | } elsif ($remaining) { | ||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $status = 1; | |||||||||||||||||||||||||||||||||||||||||
| 132 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 133 | 7 | $status = 0; | |||||||||||||||||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||||||||||||||||
| 135 | 10 | $consumed = $self->{borrowed_offset}; | |||||||||||||||||||||||||||||||||||||||||
| 136 | 10 | $head_ready = $self->_borrowed_native_head_ready; | |||||||||||||||||||||||||||||||||||||||||
| 137 | } | ||||||||||||||||||||||||||||||||||||||||||
| 138 | 10 | ▶ | $self->_transport_sync if $self->{transport_attached}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 10 | return ($status, $consumed, $head_ready); | |||||||||||||||||||||||||||||||||||||||||
| 140 | } | ||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | ▶ | sub _borrowed_input_eof { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_borrowed_input_eof: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | $self->input_eof; | |||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | return 4 if $self->{switched}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | return 3 if $self->{closed}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | 775 | ▶ | sub _input_length { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_input_length: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 775 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 152 | 775 | ▶ | if (exists $self->{borrowed_input}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | 29 | return $self->{borrowed_length} - $self->{borrowed_offset}; | |||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||
| 155 | 746 | return length $self->{input}; | |||||||||||||||||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 478 | ▶ | sub _input_window { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_input_window: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 478 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 160 | return ($self->{borrowed_input}, $self->{borrowed_offset}) | ||||||||||||||||||||||||||||||||||||||||||
| 161 | 478 | ▶ | if exists $self->{borrowed_input}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 162 | 475 | return ($self->{input}, 0); | |||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 34 | ▶ | sub _input_take { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_input_take: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 166 | 34 | my ($self, $length) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 167 | 34 | ▶ | return '' unless $length; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 34 | ▶ | if (exists $self->{borrowed_input}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 169 | 5 | my $offset = $self->{borrowed_offset}; | |||||||||||||||||||||||||||||||||||||||||
| 170 | 5 | my $bytes = $self->{borrowed_input}->slice($offset, $length); | |||||||||||||||||||||||||||||||||||||||||
| 171 | 5 | $self->{borrowed_offset} += $length; | |||||||||||||||||||||||||||||||||||||||||
| 172 | 5 | return $bytes; | |||||||||||||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||||||||||||
| 174 | 29 | return substr($self->{input}, 0, $length, ''); | |||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | 169 | ▶ | sub _input_discard { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_input_discard: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | 169 | my ($self, $length) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 179 | 169 | ▶ | return unless $length; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 180 | 169 | ▶ | if (exists $self->{borrowed_input}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 10 | $self->{borrowed_offset} += $length; | |||||||||||||||||||||||||||||||||||||||||
| 182 | 10 | return; | |||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | 159 | substr($self->{input}, 0, $length, ''); | |||||||||||||||||||||||||||||||||||||||||
| 185 | 159 | return; | |||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | 3 | ▶ | sub _input_clear { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_input_clear: called CC=2 SCAR=7.4
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 190 | 3 | ▶ | if (exists $self->{borrowed_input}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | $self->{borrowed_offset} = $self->{borrowed_length}; | |||||||||||||||||||||||||||||||||||||||||
| 192 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 193 | 3 | $self->{input} = ''; | |||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||
| 195 | 3 | return; | |||||||||||||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | 2 | ▶ | sub _input_remaining { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_input_remaining: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||
| 199 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 200 | 2 | ▶ | if (exists $self->{borrowed_input}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 201 | return $self->{borrowed_input}->slice( | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | $self->{borrowed_offset}, $self->_input_length, | |||||||||||||||||||||||||||||||||||||||||
| 203 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 204 | } | ||||||||||||||||||||||||||||||||||||||||||
| 205 | 2 | return $self->{input}; | |||||||||||||||||||||||||||||||||||||||||
| 206 | } | ||||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | sub _borrowed_should_buffer_tail { 0 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_borrowed_should_buffer_tail: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | sub _borrowed_native_head_ready { 0 } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_borrowed_native_head_ready: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | 7 | ▶ | sub input_eof { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
input_eof: called CC=5 SCAR=16.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 212 | 7 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 213 | 7 | ▶ | return $self if $self->{eof}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 214 | croak 'input_eof(): cannot be called recursively from an engine callback or host send' | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 6 | ▶ | if $self->{driving} || $self->{transport_syncing}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"driving"} or $self->{"transport_syncing"}
MC/DC0%0/2
$self->{"driving"} or $self->{"transport_syncing"}
$self->{"driving"}
$self->{"transport_syncing"}
Truth table33%1/3
A or B
A= $self->{"driving"}B= $self->{"transport_syncing"}
| |||||||||||||||||||||||||||||||||||||||||||
| 216 | 6 | $self->{eof} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 217 | { | ||||||||||||||||||||||||||||||||||||||||||
| 218 | 6 | local $self->{driving} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 219 | 6 | $self->_on_eof; | |||||||||||||||||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||||||||||||||||
| 221 | 6 | ▶ | $self->_transport_sync if $self->{transport_attached}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 222 | 6 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 111 | ▶ | sub output { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
output: called CC=9 SCAR=29.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | 111 | my ($self, $max) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 227 | croak 'output(): manual output is unavailable with an attached transport' | ||||||||||||||||||||||||||||||||||||||||||
| 228 | 111 | ▶ | if $self->{transport_attached}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 229 | 110 | ▶ | croak 'output(): cannot be called recursively from an engine callback' if $self->{driving}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | 110 | ▶ | return '' unless length $self->{output}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | 103 | my $take = length $self->{output}; | |||||||||||||||||||||||||||||||||||||||||
| 232 | 103 | ▶ | if (defined $max) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | croak 'output(): maximum must be a positive integer' | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
not ref $max and $max =~ /\A[0-9]+\z/ and $max > 0
not ref $max and $max =~ /\A[0-9]+\z/
MC/DC0%0/3
not ref $max and $max =~ /\A[0-9]+\z/ and $max > 0
not ref $max
$max =~ /\A[0-9]+\z/
$max > 0
Truth table0%0/4
not(A) and B and C
A= not ref $maxB= $max =~ /\A[0-9]+\z/C= $max > 0
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | unless !ref($max) && $max =~ /\A[0-9]+\z/ && $max > 0; | ||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | ▶ | $take = $max if $max < $take; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||||||||||||
| 237 | 103 | my $bytes = substr($self->{output}, 0, $take, ''); | |||||||||||||||||||||||||||||||||||||||||
| 238 | 103 | $self->_after_output; | |||||||||||||||||||||||||||||||||||||||||
| 239 | 103 | return $bytes; | |||||||||||||||||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 9 | ▶ | sub take_remainder { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
take_remainder: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | 9 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 244 | croak 'take_remainder(): HTTP/1 connection has not switched protocols' | ||||||||||||||||||||||||||||||||||||||||||
| 245 | 9 | ▶ | unless $self->{switched}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 9 | my $bytes = $self->{remainder}; | |||||||||||||||||||||||||||||||||||||||||
| 247 | 9 | $self->{remainder} = ''; | |||||||||||||||||||||||||||||||||||||||||
| 248 | 9 | return $bytes; | |||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | sub close { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
close: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | my ($self, $error) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 253 | 0 | ▶ | return $self if $self->{closed}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 254 | 0 | $self->{closed} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | $self->_fail_all(defined($error) && length($error) ? "$error" : 'HTTP/1 connection closed'); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $error and length $error
MC/DC0%0/2
defined $error and length $error
defined $error
length $error
Truth table0%0/3
A and B
A= defined $errorB= length $error
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | $self->_transport_sync if $self->{transport_attached}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 258 | } | ||||||||||||||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||||||||||||
| 260 | 149 | ▶ | sub _queue_output { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_queue_output: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | 149 | my ($self, $bytes) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 262 | 149 | ▶ | return unless defined $bytes && length $bytes; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $bytes and length $bytes
MC/DC50%1/2
defined $bytes and length $bytes
defined $bytes
length $bytes
Truth table66%2/3
A and B
A= defined $bytesB= length $bytes
| |||||||||||||||||||||||||||||||||||||||||||
| 263 | croak '_queue_output(): host send callback must not re-enter the engine' | ||||||||||||||||||||||||||||||||||||||||||
| 264 | 144 | ▶ | if $self->{transport_syncing}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 265 | 144 | $self->{output} .= $bytes; | |||||||||||||||||||||||||||||||||||||||||
| 266 | 144 | ▶ | $self->_transport_sync if $self->{transport_attached} && !$self->{driving}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"transport_attached"} and not $self->{"driving"}
MC/DC100%2/2
$self->{"transport_attached"} and not $self->{"driving"}
$self->{"transport_attached"}
not $self->{"driving"}
Truth table100%3/3
A and not(B)
A= $self->{"transport_attached"}B= not $self->{"driving"}
| |||||||||||||||||||||||||||||||||||||||||||
| 267 | 144 | return; | |||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||
| 270 | # Only a whole-buffer acceptance transfers ownership to the host. A false | ||||||||||||||||||||||||||||||||||||||||||
| 271 | # return indicates congestion, not rejection. The host later resumes us. | ||||||||||||||||||||||||||||||||||||||||||
| 272 | 56 | ▶ | sub _transport_sync { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_transport_sync: called CC=21 SCAR=30.8
| |||||||||||||||||||||||||||||||||||||||||||
| 273 | 56 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 274 | 56 | ▶ | return unless $self->{transport_attached}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 275 | 56 | ▶ | return if $self->{transport_syncing} || $self->{driving}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"transport_syncing"} or $self->{"driving"}
MC/DC50%1/2
$self->{"transport_syncing"} or $self->{"driving"}
$self->{"transport_syncing"}
$self->{"driving"}
Truth table66%2/3
A or B
A= $self->{"transport_syncing"}B= $self->{"driving"}
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | 43 | ▶ | return if $self->{transport_aborted} || $self->{transport_finished}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"transport_aborted"} or $self->{"transport_finished"}
MC/DC50%1/2
$self->{"transport_aborted"} or $self->{"transport_finished"}
$self->{"transport_aborted"}
$self->{"transport_finished"}
Truth table66%2/3
A or B
A= $self->{"transport_aborted"}B= $self->{"transport_finished"}
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | 41 | my $host = $self->{transport}; | |||||||||||||||||||||||||||||||||||||||||
| 278 | 41 | ▶ | return $self->transport_error('HTTP/1 transport was destroyed') unless $host; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||
| 280 | { | ||||||||||||||||||||||||||||||||||||||||||
| 281 | 40 | local $self->{transport_syncing} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 282 | 40 | ▶ | while (!$self->{transport_blocked} && length $self->{output}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $self->{"transport_blocked"} and length $self->{"output"}
MC/DC100%2/2
not $self->{"transport_blocked"} and length $self->{"output"}
not $self->{"transport_blocked"}
length $self->{"output"}
Truth table100%3/3
not(A) and B
A= not $self->{"transport_blocked"}B= length $self->{"output"}
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | # No producer may re-enter during host send. Move this complete | ||||||||||||||||||||||||||||||||||||||||||
| 284 | # buffer out once; a thrown send aborts rather than retransmits. | ||||||||||||||||||||||||||||||||||||||||||
| 285 | 21 | my $bytes = $self->{output}; | |||||||||||||||||||||||||||||||||||||||||
| 286 | 21 | $self->{output} = ''; | |||||||||||||||||||||||||||||||||||||||||
| 287 | 21 | my ($accepted, $ready); | |||||||||||||||||||||||||||||||||||||||||
| 288 | 21 | $accepted = eval { $ready = $host->unblock_send($bytes); 1 }; | |||||||||||||||||||||||||||||||||||||||||
| 289 | 21 | ▶ | if (!$accepted) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 290 | 2 | ▶ | my $error = "$@" || 'unblock_send() failed'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
"$@" || 'unblock_send() failed'
MC/DC0%0/1
"$@" || 'unblock_send() failed'
"$@"
Truth table50%1/2
A
A= "$@"
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | 2 | $self->_transport_abort($error); | |||||||||||||||||||||||||||||||||||||||||
| 292 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||
| 294 | 19 | ▶ | $self->{transport_blocked} = 1 if defined($ready) && !$ready; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $ready and not $ready
MC/DC50%1/2
defined $ready and not $ready
defined $ready
not $ready
Truth table66%2/3
A and not(B)
A= defined $readyB= not $ready
| |||||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | 38 | ▶ | if (!length($self->{output}) && $self->{switch_notice}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not length $self->{"output"} and $self->{"switch_notice"}
MC/DC100%2/2
not length $self->{"output"} and $self->{"switch_notice"}
not length $self->{"output"}
$self->{"switch_notice"}
Truth table100%3/3
not(A) and B
A= not length $self->{"output"}B= $self->{"switch_notice"}
| |||||||||||||||||||||||||||||||||||||||||||
| 299 | 3 | my $notice = delete $self->{switch_notice}; | |||||||||||||||||||||||||||||||||||||||||
| 300 | 3 | $self->_deliver_switch_notice(@$notice); | |||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 302 | 38 | ▶ | return if $self->{transport_aborted}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 303 | 37 | ▶ | if ($self->{closed} && !length($self->{output}) && !$self->{switched}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition83%5/6
$self->{"closed"} and not length $self->{"output"} and not $self->{"switched"}
$self->{"closed"} and not length $self->{"output"}
MC/DC66%2/3
$self->{"closed"} and not length $self->{"output"} and not $self->{"switched"}
$self->{"closed"}
not length $self->{"output"}
not $self->{"switched"}
Truth table75%3/4
A and not(B) and not(C)
A= $self->{"closed"}B= not length $self->{"output"}C= not $self->{"switched"}
| |||||||||||||||||||||||||||||||||||||||||||
| 304 | 3 | $self->{transport_finished} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 305 | 3 | my $ok = eval { $host->unblock_finish(); 1 }; | |||||||||||||||||||||||||||||||||||||||||
| 306 | 3 | ▶ | $self->_transport_abort("$@" || 'unblock_finish() failed') unless $ok; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/2
"$@" || 'unblock_finish() failed'
MC/DC0%0/1
"$@" || 'unblock_finish() failed'
"$@"
Truth table0%0/2
A
A= "$@"
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | } | ||||||||||||||||||||||||||||||||||||||||||
| 308 | 37 | return; | |||||||||||||||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | 4 | ▶ | sub _transport_abort { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_transport_abort: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 312 | 4 | my ($self, $reason) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 313 | 4 | ▶ | return if $self->{transport_aborted}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | 4 | $self->{transport_aborted} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 315 | 4 | $self->{output} = ''; | |||||||||||||||||||||||||||||||||||||||||
| 316 | 4 | $self->{closed} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 317 | 4 | $self->{switch_notice} = undef; | |||||||||||||||||||||||||||||||||||||||||
| 318 | 4 | $self->_fail_all($reason); | |||||||||||||||||||||||||||||||||||||||||
| 319 | 4 | ▶ | if (my $host = $self->{transport}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 320 | 3 | eval { $host->unblock_abort($reason) }; | |||||||||||||||||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||||||||||||||||
| 322 | 4 | return; | |||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | 1 | ▶ | sub transport_error { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
transport_error: called CC=3 SCAR=12.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 326 | 1 | my ($self, $reason) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 327 | 1 | ▶ | $reason = 'transport error' unless defined($reason) && length($reason); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $reason and length $reason
MC/DC0%0/2
defined $reason and length $reason
defined $reason
length $reason
Truth table33%1/3
A and B
A= defined $reasonB= length $reason
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | 1 | $self->_transport_abort("$reason"); | |||||||||||||||||||||||||||||||||||||||||
| 329 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 330 | } | ||||||||||||||||||||||||||||||||||||||||||
| 331 | |||||||||||||||||||||||||||||||||||||||||||
| 332 | 3 | ▶ | sub resume_output { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
resume_output: called CC=9 SCAR=25.4
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 334 | 3 | ▶ | croak 'resume_output(): no attached transport' unless $self->{transport_attached}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | croak 'resume_output(): cannot be called recursively from host send' | ||||||||||||||||||||||||||||||||||||||||||
| 336 | 3 | ▶ | if $self->{transport_syncing}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 337 | 3 | ▶ | return $self if $self->{transport_finished} || $self->{transport_aborted}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"transport_finished"} or $self->{"transport_aborted"}
MC/DC0%0/2
$self->{"transport_finished"} or $self->{"transport_aborted"}
$self->{"transport_finished"}
$self->{"transport_aborted"}
Truth table33%1/3
A or B
A= $self->{"transport_finished"}B= $self->{"transport_aborted"}
| |||||||||||||||||||||||||||||||||||||||||||
| 338 | 3 | $self->{transport_blocked} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 339 | 3 | ▶ | $self->_transport_sync if $self->{transport_attached}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | 3 | ▶ | if (!$self->{transport_blocked} && length($self->{output}) <= $self->{low_water}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $self->{"transport_blocked"} and length $self->{"output"} <= $self->{"low_water"}
MC/DC0%0/2
not $self->{"transport_blocked"} and length $self->{"output"} <= $self->{"low_water"}
not $self->{"transport_blocked"}
length $self->{"output"} <= $self->{"low_water"}
Truth table33%1/3
not(A) and B
A= not $self->{"transport_blocked"}B= length $self->{"output"} <= $self->{"low_water"}
| |||||||||||||||||||||||||||||||||||||||||||
| 341 | 3 | $self->_maybe_drain; | |||||||||||||||||||||||||||||||||||||||||
| 342 | 3 | ▶ | $self->_transport_sync if $self->{transport_attached}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 343 | } | ||||||||||||||||||||||||||||||||||||||||||
| 344 | 3 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | sub _deliver_switch_notice { return } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_deliver_switch_notice: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | 12 | ▶ | sub _mark_switched { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_mark_switched: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 350 | 12 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 351 | 12 | ▶ | return if $self->{switched}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 352 | 12 | $self->{switched} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 353 | 12 | ▶ | if (!exists $self->{borrowed_input}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | 9 | $self->{remainder} .= $self->{input}; | |||||||||||||||||||||||||||||||||||||||||
| 355 | 9 | $self->{input} = ''; | |||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||
| 357 | 12 | return; | |||||||||||||||||||||||||||||||||||||||||
| 358 | } | ||||||||||||||||||||||||||||||||||||||||||
| 359 | |||||||||||||||||||||||||||||||||||||||||||
| 360 | 103 | ▶ | sub _after_output { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_after_output: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||||||||||||
| 361 | 103 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 362 | 103 | ▶ | $self->_maybe_drain if length($self->{output}) <= $self->{low_water}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 363 | 103 | return; | |||||||||||||||||||||||||||||||||||||||||
| 364 | } | ||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | 15 | ▶ | sub _stream_ok { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stream_ok: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | 15 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 368 | 15 | ▶ | return 0 if $self->{transport_blocked}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 369 | 14 | ▶ | return length($self->{output}) < $self->{high_water} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||||||||||||||||
| 371 | |||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | ▶ | sub _maybe_drain { return } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_maybe_drain: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | sub _fail_all { return } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_fail_all: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||
| 375 | 30 | 1; | |||||||||||||||||||||||||||||||||||||||||