blib/lib/Linux/Event/_ByteStream.pm

filter: Statementstmt 89.7% 805 / 897 Branchbran 77.1% 506 / 656 Conditioncond 59.3% 314 / 529 MC/DCmcdc 36.9% 108 / 292 Subroutinesub 91.2% 135 / 148 Podpod 0.0% 0 / 42 totaltotal 72.8% 1868 / 2564 CC 523 SCAR 29.0
CC
523
Cov
78%
_fork_child_move
156.0
new
48.7
_xs_transport_event
44.0
CRAP 18.2
« blib/lib/Linux/Event/Framer/LengthPrefix.pm ↑ Summary bench/run-connect-microbench.pl »
1 package Linux::Event::_ByteStream;
2 127 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 127 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 127 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 127 ▶use parent 'Linux::Event::_IO';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 127 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 127 ▶use Errno ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10 127 ▶use Fcntl qw(F_GETFD F_GETFL F_SETFD F_SETFL FD_CLOEXEC O_NONBLOCK);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 127 ▶use POSIX qw(isfinite);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 127 ▶use Scalar::Util qw(looks_like_number refaddr weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 127 ▶use utf8 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 127 ▶use Linux::Event::_ByteStream::Descriptor ();
Subroutine BEGIN: called CC=1 SCAR=0.0
16 127 ▶use Linux::Event::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 127 require XSLoader;
19 127 XSLoader::load(__PACKAGE__);
20  
21 127 my @INPUT_CALLBACK = qw(on_data on_message on_messages);
22 127 my @LIFECYCLE_CALLBACK = qw(
23 on_drain on_eof on_error on_close on_ready on_transport_ready
24 );
25 127 my @APPLICATION_CALLBACK = (@INPUT_CALLBACK, @LIFECYCLE_CALLBACK);
26  
27 # Constructors and class lifecycle
28  
29 103210 ▶sub new ($class, %opt) {
Subroutine new: called CC=42 SCAR=38.9
Pod undocumented
30 103210 ▶ croak 'new(): must be called as a class method' if ref $class;
Branch: 1 branch
BranchTrueFalseTotal
if ref $class 0 103210 103210
31 103210 my $loop = delete $opt{loop};
32 103210 ▶ croak 'new(): loop must be an object implementing add() and watch_fd()'
Branch: 1 branch
BranchTrueFalseTotal
if defined $loop and not ref $loop && $loop->can("add") && $loop->can("watch_fd") 0 103210 103210
Condition44%4/9
defined $loop and not ref $loop && $loop->can("add") && $loop->can("watch_fd")
!ll&&!rl&&r
103173370
ref $loop && $loop->can('add') && $loop->can('watch_fd')
!ll&&!rl&&r
0037
ref $loop and $loop->can("add")
!ll&&!rl&&r
0037
MC/DC0%0/4
defined $loop and not ref $loop && $loop->can("add") && $loop->can("watch_fd")
defined $loop ref $loop $loop->can("add") $loop->can('watch_fd')
Truth table40%2/5
A and not(B and C && D)
A= defined $loopB= ref $loopC= $loop->can("add")D= $loop->can('watch_fd')
ABCDresult
0XXX0
11110
10XX1
110X1
11101
33 if defined($loop) && (!ref($loop) || !$loop->can('add')
34 || !$loop->can('watch_fd'));
35 103210 my $fh = delete $opt{fh};
36 103210 my $read_fh = delete $opt{read_fh};
37 103210 my $write_fh = delete $opt{write_fh};
38 103210 ▶ my $pending = delete($opt{_pending}) // 0;
Condition100%2/2
delete $opt{"_pending"} // 0
l!l
1117102093
MC/DC100%1/1
delete $opt{"_pending"} // 0
delete $opt{"_pending"}
Truth table100%2/2
A
A= delete $opt{"_pending"}
Aresult
11
00
39 103210 my $data = delete $opt{data};
40 103210 my $transport = delete $opt{_transport};
41 103210 my $owns_handles = delete $opt{_owns_handles};
42 103210 ▶ $owns_handles = 1 if !defined $owns_handles;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $owns_handles 103201 9 103210
43 103210 ▶ croak 'new(): internal owns_handles must be zero or one'
Branch: 1 branch
BranchTrueFalseTotal
if ref $owns_handles or not $owns_handles =~ /\A[01]\z/u 0 103210 103210
Condition33%1/3
ref $owns_handles or not $owns_handles =~ /\A[01]\z/u
l!l&&r!l&&!r
00103210
MC/DC0%0/2
ref $owns_handles or not $owns_handles =~ /\A[01]\z/u
ref $owns_handles not $owns_handles =~ /\A[01]\z/u
Truth table33%1/3
A or not(B)
A= ref $owns_handlesB= not $owns_handles =~ /\A[01]\z/u
ABresult
1X1
011
000
44 if ref($owns_handles) || $owns_handles !~ /\A[01]\z/;
45 103210 ▶ $owns_handles = $owns_handles ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$owns_handles ? : 103202 8 103210
46 103210 my $callback = _take_callbacks('new', \%opt);
47 103209 my %timeout_override;
48 103209 for my $name (qw(idle_timeout read_timeout write_timeout)) {
49 $timeout_override{$name} = _timeout_value('new():', $name,
50 309621 ▶ delete $opt{$name}) if exists $opt{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opt{$name} 26 309595 309621
51 }
52 my $initial_deadline = exists($opt{deadline})
53 103203 ▶ ? _deadline_spec('new', delete $opt{deadline}) : undef;
Branch: 1 branch
BranchTrueFalseTotal
exists $opt{'deadline'} ? : 12 103191 103203
54 103196 ▶ croak 'new(): unknown options: ' . join(', ', sort keys %opt) if %opt;
Branch: 1 branch
BranchTrueFalseTotal
if %opt 1 103195 103196
55 103195 ▶ croak 'new(): fh cannot be combined with read_fh or write_fh'
Branch: 1 branch
BranchTrueFalseTotal
if defined $fh and defined $read_fh || defined $write_fh 1 103194 103195
Condition83%5/6
defined $fh and defined $read_fh || defined $write_fh
!ll&&!rl&&r
11501020441
defined $read_fh or defined $write_fh
l!l&&r!l&&!r
01102044
MC/DC66%2/3
defined $fh and defined $read_fh || defined $write_fh
defined $fh defined $read_fh defined $write_fh
Truth table75%3/4
A and B or C
A= defined $fhB= defined $read_fhC= defined $write_fh
ABCresult
0XX0
1000
11X1
1011
56 if defined($fh) && (defined($read_fh) || defined($write_fh));
57 103194 ▶ if (defined $fh) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fh) 102044 1150 103194
58 102044 $read_fh = $fh;
59 102044 $write_fh = $fh;
60 }
61 103194 ▶ croak 'new(): at least one of fh, read_fh, or write_fh is required'
Branch: 1 branch
BranchTrueFalseTotal
unless $pending or defined $read_fh or defined $write_fh 1 103193 103194
Condition100%6/6
$pending or defined $read_fh or defined $write_fh
l!l&&r!l&&!r
10319031
$pending or defined $read_fh
l!l&&r!l&&!r
11171020734
MC/DC100%3/3
$pending or defined $read_fh or defined $write_fh
$pending defined $read_fh defined $write_fh
Truth table100%4/4
A or B or C
A= $pendingB= defined $read_fhC= defined $write_fh
ABCresult
1XX1
01X1
0011
0000
62 if !$pending && !defined($read_fh) && !defined($write_fh);
63 103193 ▶ croak 'new(): internal pending mode cannot have filehandles'
Branch: 1 branch
BranchTrueFalseTotal
if $pending and defined $read_fh || defined $write_fh 0 103193 103193
Condition50%3/6
$pending and defined $read_fh || defined $write_fh
!ll&&!rl&&r
10207611170
defined $read_fh or defined $write_fh
l!l&&r!l&&!r
001117
MC/DC0%0/3
$pending and defined $read_fh || defined $write_fh
$pending defined $read_fh defined $write_fh
Truth table50%2/4
A and B or C
A= $pendingB= defined $read_fhC= defined $write_fh
ABCresult
0XX0
1000
11X1
1011
64 if $pending && (defined($read_fh) || defined($write_fh));
65 103193 for my $pair ([read_fh => $read_fh], [write_fh => $write_fh]) {
66 206386 ▶ croak "new(): $pair->[0] must be a filehandle"
Branch: 1 branch
BranchTrueFalseTotal
if defined $pair->[1] and not defined fileno $pair->[1] 0 206386 206386
Condition66%2/3
defined $pair->[1] and not defined fileno $pair->[1]
!ll&&!rl&&r
22602041260
MC/DC0%0/2
defined $pair->[1] and not defined fileno $pair->[1]
defined $pair->[1] not defined fileno $pair->[1]
Truth table66%2/3
A and not(B)
A= defined $pair->[1]B= not defined fileno $pair->[1]
ABresult
0X0
100
111
67 if defined($pair->[1]) && !defined(fileno($pair->[1]));
68 }
69 103193 ▶ croak 'new(): internal transport must implement _stream_transport_bind()'
Branch: 1 branch
BranchTrueFalseTotal
if defined $transport and not ref $transport && $transport->can("_stream_transport_bind") 0 103193 103193
Condition50%3/6
defined $transport and not ref $transport && $transport->can("_stream_transport_bind")
!ll&&!rl&&r
103166270
ref $transport && $transport->can('_stream_transport_bind')
!ll&&!rl&&r
0027
MC/DC0%0/3
defined $transport and not ref $transport && $transport->can("_stream_transport_bind")
defined $transport ref $transport $transport->can('_stream_transport_bind')
Truth table50%2/4
A and not(B && C)
A= defined $transportB= ref $transportC= $transport->can('_stream_transport_bind')
ABCresult
0XX0
1110
10X1
1101
70 if defined($transport)
71 && (!ref($transport) || !$transport->can('_stream_transport_bind'));
72  
73 103193 my $descriptor = Linux::Event::_ByteStream::Descriptor::for_class($class);
74 103167 _validate_callback_modes('new', $descriptor, $callback);
75 my %lifecycle_override = map {
76 103161 ▶ exists($callback->{$_}) ? ($_ => $callback->{$_}) : ()
Branch: 1 branch
BranchTrueFalseTotal
exists $callback->{$_} ? : 14 618952 618966
77 } @LIFECYCLE_CALLBACK;
78 my %input_callback = map {
79 103161 ▶ exists($callback->{$_}) ? ($_ => $callback->{$_}) : ()
Branch: 1 branch
BranchTrueFalseTotal
exists $callback->{$_} ? : 76 309407 309483
80 } @INPUT_CALLBACK;
81 my %timeout = map {
82 103161 $_ => exists($timeout_override{$_})
83 309483 ▶ ? $timeout_override{$_} : $descriptor->{options}{$_}
Branch: 1 branch
BranchTrueFalseTotal
exists $timeout_override{$_} ? : 20 309463 309483
84 } qw(idle_timeout read_timeout write_timeout);
85 my $self = bless {
86 descriptor => $descriptor,
87 loop => undef,
88 read_fh => $read_fh,
89 write_fh => $write_fh,
90 read_capable => defined($read_fh) ? 1 : 0,
91 write_capable => defined($write_fh) ? 1 : 0,
92 owns_handles => $owns_handles,
93 borrowed_handle_flags => {},
94 read_watcher => undef,
95 write_watcher => undef,
96 data => $data,
97 callbacks => _effective_lifecycle_callbacks(
98 $descriptor, \%lifecycle_override,
99 ),
100 callback_overrides => \%lifecycle_override,
101 _input_callbacks => \%input_callback,
102 _input_callback_overrides => {
103 103161 ▶ map { $_ => 1 } keys %input_callback
Branch: 4 branches
BranchTrueFalseTotal
defined $read_fh ? : 102041 1120 103161
defined $write_fh ? : 102023 1138 103161
defined $read_fh ? : 102041 1120 103161
defined $write_fh ? : 102023 1138 103161
104 },
105 transport => $transport,
106 xs_state => undef,
107 read_paused => 0,
108 read_eof => 0,
109 read_closed => defined($read_fh) ? 0 : 1,
110 write_ending => 0,
111 write_ended => defined($write_fh) ? 0 : 1,
112 closed => 0,
113 detached => 0,
114 close_fired => 0,
115 last_error => undef,
116 transport_ready_fired => 0,
117 transport_deadline_watcher => undef,
118 transport_shutdown_started => 0,
119 timeout => \%timeout,
120 timeout_override => \%timeout_override,
121 initial_deadline => $initial_deadline,
122 operation_deadline_at => undef,
123 operation_deadline_name => undef,
124 operation_deadline_timeout => undef,
125 deadline_timer => undef,
126 deadline_started => 0,
127 deadline_tracking => 0,
128 deadline_read_started => undef,
129 deadline_write_started => undef,
130 _construction_pending => 1,
131 }, $class;
132 103161 ▶ $self->_prepare_handles if !$pending;
Branch: 1 branch
BranchTrueFalseTotal
unless $pending 102044 1117 103161
133 103155 ▶ if ($loop) {
Branch: 1 branch
BranchTrueFalseTotal
if ($loop) 36 103119 103155
134 36 my $attached = eval { $self->_attach_to_loop($loop); 1 };
135 36 ▶ if (!$attached) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($attached) 2 34 36
136 2 ▶ my $failure = $@ || 'Stream construction attachment failed';
Condition50%1/2
$@ || 'Stream construction attachment failed'
l!l
20
MC/DC0%0/1
$@ || 'Stream construction attachment failed'
$@
Truth table50%1/2
A
A= $@
Aresult
11
00
137 2 $self->_abort_failed_construction;
138 2 delete $self->{_construction_pending};
139 2 die $failure;
140 }
141 }
142 103153 delete $self->{_construction_pending};
143 103153 return $self;
144 }
145  
146 1 ▶sub connect ($class, %opt) {
Subroutine connect: called CC=1 SCAR=0.0
Pod undocumented
147 1 croak 'connect(): available only on Linux::Event::IO::Sock::Stream subclasses';
148 }
149  
150 9 ▶sub _fork_preflight ($self, $mode, $loop) {
Subroutine _fork_preflight: called CC=10 SCAR=26.2
151 croak 'fork(): ordered-byte resource is not active in this Loop'
152 if $self->{closed} || !$self->{loop}
153 9 ▶ || refaddr($self->{loop}) != refaddr($loop);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or not $self->{"loop"} or builtin::refaddr($self->{"loop"}) != builtin::refaddr($loop) 0 9 9
Condition33%2/6
$self->{"closed"} or not $self->{"loop"} or builtin::refaddr($self->{"loop"}) != builtin::refaddr($loop)
l!l&&r!l&&!r
009
$self->{"closed"} or not $self->{"loop"}
l!l&&r!l&&!r
009
MC/DC0%0/3
$self->{"closed"} or not $self->{"loop"} or builtin::refaddr($self->{"loop"}) != builtin::refaddr($loop)
$self->{"closed"} not $self->{"loop"} builtin::refaddr($self->{"loop"}) != builtin::refaddr($loop)
Truth table25%1/4
A or not(B) or C
A= $self->{"closed"}B= not $self->{"loop"}C= builtin::refaddr($self->{"loop"}) != builtin::refaddr($loop)
ABCresult
1XX1
01X1
0011
0000
154 croak 'fork(): cannot fork while an ordered-byte connection is pending'
155 9 ▶ if $self->{connection};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"connection"} 0 9 9
156 9 ▶ return 1 if $mode eq 'drop';
Branch: 1 branch
BranchTrueFalseTotal
if $mode eq "drop" 3 6 9
157 6 ▶ croak "fork(): ordered-byte resource does not support '$mode'"
Branch: 1 branch
BranchTrueFalseTotal
if $mode ne "move" 3 3 6
158 if $mode ne 'move';
159 3 ▶ croak 'fork(): only established socket Streams support move'
Branch: 1 branch
BranchTrueFalseTotal
unless $self->isa("Linux::Event::IO::Sock::Stream") 0 3 3
160 if !$self->isa('Linux::Event::IO::Sock::Stream');
161 3 ▶ croak 'fork(): only plain socket Streams support move initially'
Branch: 1 branch
BranchTrueFalseTotal
if ($self->transport_name // "plain") ne "plain" 0 3 3
Condition50%1/2
$self->transport_name // "plain"
l!l
30
MC/DC0%0/1
$self->transport_name // "plain"
$self->transport_name
Truth table50%1/2
A
A= $self->transport_name
Aresult
11
00
162 if ($self->transport_name // 'plain') ne 'plain';
163 3 return 1;
164 }
165  
166 0 ▶sub _fork_child_move ($self, $loop) {
Subroutine _fork_child_move: not called CC=12 SCAR=50.5
167 0 $self->{read_watcher} = undef;
168 0 $self->{write_watcher} = undef;
169 0 $self->{transport_deadline_watcher} = undef;
170 0 $self->{loop} = $loop;
171  
172 0 ▶ if (my $timer = $self->{deadline_timer}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $timer = $self->{"deadline_timer"}) 0 0 0
173 0 ▶ $loop->add($timer) if !$timer->is_terminal;
Branch: 1 branch
BranchTrueFalseTotal
unless $timer->is_terminal 0 0 0
174 }
175  
176 0 my $interest = 0;
177 0 ▶ if (defined($self->{read_fh}) && !$self->{read_closed} && !$self->{read_eof}
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"read_fh"} and not $self->{"read_closed"} and not $self->{"read_eof"} and not $self->{"read_paused"} and not $self->{"xs_state"} && $self->{"xs_state"}->consumer_paused && $self->{"xs_state"}->transport_ready) 0 0 0
Condition0%0/18
defined $self->{"read_fh"} and not $self->{"read_closed"} and not $self->{"read_eof"} and not $self->{"read_paused"} and not $self->{"xs_state"} && $self->{"xs_state"}->consumer_paused && $self->{"xs_state"}->transport_ready
!ll&&!rl&&r
000
defined $self->{"read_fh"} and not $self->{"read_closed"} and not $self->{"read_eof"} and not $self->{"read_paused"}
!ll&&!rl&&r
000
defined $self->{"read_fh"} and not $self->{"read_closed"} and not $self->{"read_eof"}
!ll&&!rl&&r
000
defined $self->{"read_fh"} and not $self->{"read_closed"}
!ll&&!rl&&r
000
$self->{'xs_state'} && $self->{'xs_state'}->consumer_paused && $self->{'xs_state'}->transport_ready
!ll&&!rl&&r
000
$self->{"xs_state"} and $self->{"xs_state"}->consumer_paused
!ll&&!rl&&r
000
MC/DC0%0/7
defined $self->{"read_fh"} and not $self->{"read_closed"} and not $self->{"read_eof"} and not $self->{"read_paused"} and not $self->{"xs_state"} && $self->{"xs_state"}->consumer_paused && $self->{"xs_state"}->transport_ready
defined $self->{"read_fh"} not $self->{"read_closed"} not $self->{"read_eof"} not $self->{"read_paused"} $self->{"xs_state"} $self->{"xs_state"}->consumer_paused $self->{'xs_state'}->transport_ready
Truth table0%0/8
A and not(B) and not(C) and not(D) and not(E and F && G)
A= defined $self->{"read_fh"}B= not $self->{"read_closed"}C= not $self->{"read_eof"}D= not $self->{"read_paused"}E= $self->{"xs_state"}F= $self->{"xs_state"}->consumer_pausedG= $self->{'xs_state'}->transport_ready
ABCDEFGresult
0XXXXXX0
10XXXXX0
110XXXX0
1110XXX0
11111110
11110XX1
111110X1
11111101
178 && !$self->{read_paused}
179 && !($self->{xs_state} && $self->{xs_state}->consumer_paused
180 && $self->{xs_state}->transport_ready)) {
181 0 $interest |= 0x01;
182 }
183 $interest |= 0x02
184 0 ▶ if defined($self->{write_fh}) && $self->pending_bytes > 0;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"write_fh"} and $self->pending_bytes > 0 0 0 0
Condition0%0/3
defined $self->{"write_fh"} and $self->pending_bytes > 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $self->{"write_fh"} and $self->pending_bytes > 0
defined $self->{"write_fh"} $self->pending_bytes > 0
Truth table0%0/3
A and B
A= defined $self->{"write_fh"}B= $self->pending_bytes > 0
ABresult
0X0
100
111
185 0 $self->{initial_interest} = $interest;
186 0 $self->_register_handles;
187 0 return;
188 }
189  
190 0 ▶sub _fork_child_drop ($self, $loop) {
Subroutine _fork_child_drop: not called CC=4 SCAR=30.0
191 0 $self->{read_watcher} = undef;
192 0 $self->{write_watcher} = undef;
193 0 $self->{transport_deadline_watcher} = undef;
194 0 ▶ if (my $timer = delete $self->{deadline_timer}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $timer = delete $self->{"deadline_timer"}) 0 0 0
195 0 ▶ eval { $timer->cancel; 1 } if !$timer->is_terminal;
Branch: 1 branch
BranchTrueFalseTotal
unless $timer->is_terminal 0 0 0
196 }
197 0 delete $self->{xs_state};
198 0 ▶ if ($self->{owns_handles}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'owns_handles'}) { } 0 0 0
199 0 $self->_close_handles;
200 } else {
201 # Borrowed descriptor status flags belong to the same open-file
202 # descriptions inherited by the parent. Restoring them in the child
203 # would therefore change the still-active parent TTY as well.
204 0 delete $self->{borrowed_handle_flags};
205 0 $self->{read_fh} = undef;
206 0 $self->{write_fh} = undef;
207 }
208 0 $self->{loop} = undef;
209 0 $self->{closed} = 1;
210 0 $self->{fork_state} = 'not_inherited';
211 0 return;
212 }
213  
214 3 ▶sub _fork_parent_move ($self, $child_pid) {
Subroutine _fork_parent_move: called CC=3 SCAR=11.7
215 3 ▶ if (my $timer = delete $self->{deadline_timer}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $timer = delete $self->{"deadline_timer"}) 0 3 3
216 0 ▶ $timer->cancel if !$timer->is_terminal;
Branch: 1 branch
BranchTrueFalseTotal
unless $timer->is_terminal 0 0 0
217 }
218 3 $self->{transport_deadline_watcher} = undef;
219 3 $self->_cancel_io_watchers;
220 3 delete $self->{xs_state};
221 3 $self->_close_handles;
222 3 $self->{loop} = undef;
223 3 $self->{closed} = 1;
224 3 $self->{fork_state} = 'moved';
225 3 return;
226 }
227  
228 0 ▶sub CLONE ($class) {
Subroutine CLONE: not called CC=1 SCAR=6.9
229 0 Linux::Event::_ByteStream::Descriptor::clear_cache();
230 0 return;
231 }
232  
233 0 ▶sub CLONE_SKIP ($class) { 1 }
Subroutine CLONE_SKIP: not called CC=1 SCAR=6.9
234  
235 103040 ▶sub DESTROY ($self) {
Subroutine DESTROY: called CC=2 SCAR=6.9
236 103040 ▶ $self->_abort_failed_construction if $self->{_construction_pending};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_construction_pending"} 6 103034 103040
237 103040 return;
238 }
239  
240 # Accessors
241  
242 41654 ▶sub fh ($self) {
Subroutine fh: called CC=4 SCAR=13.9
Pod undocumented
243 41654 ▶ return undef if !defined($self->{read_fh}) || !defined($self->{write_fh});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"read_fh"} and defined $self->{"write_fh"} 5 41649 41654
Condition66%2/3
defined $self->{"read_fh"} and defined $self->{"write_fh"}
!ll&&!rl&&r
0541649
MC/DC50%1/2
defined $self->{"read_fh"} and defined $self->{"write_fh"}
defined $self->{"read_fh"} defined $self->{"write_fh"}
Truth table66%2/3
A and B
A= defined $self->{"read_fh"}B= defined $self->{"write_fh"}
ABresult
0X0
100
111
244 return fileno($self->{read_fh}) == fileno($self->{write_fh})
245 41649 ▶ ? $self->{read_fh} : undef;
Branch: 1 branch
BranchTrueFalseTotal
fileno $self->{'read_fh'} == fileno $self->{'write_fh'} ? : 41648 1 41649
246 }
247  
248 0 ▶sub read_fh ($self) { $self->{read_fh} }
Subroutine read_fh: not called CC=1 SCAR=6.9
Pod undocumented
249  
250 0 ▶sub write_fh ($self) { $self->{write_fh} }
Subroutine write_fh: not called CC=1 SCAR=6.9
Pod undocumented
251  
252 20 ▶sub read_fd ($self) {
Subroutine read_fd: called CC=2 SCAR=7.6
Pod undocumented
253 20 ▶ return defined($self->{read_fh}) ? fileno($self->{read_fh}) : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'read_fh'} ? : 20 0 20
254 }
255  
256 13 ▶sub write_fd ($self) {
Subroutine write_fd: called CC=2 SCAR=6.9
Pod undocumented
257 13 ▶ return defined($self->{write_fh}) ? fileno($self->{write_fh}) : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'write_fh'} ? : 8 5 13
258 }
259  
260 3 ▶sub has_read ($self) { !!$self->{read_capable} }
Subroutine has_read: called CC=1 SCAR=0.0
Pod undocumented
261  
262 3 ▶sub has_write ($self) { !!$self->{write_capable} }
Subroutine has_write: called CC=1 SCAR=0.0
Pod undocumented
263  
264 131 ▶sub loop ($self) { $self->{loop} }
Subroutine loop: called CC=1 SCAR=0.0
Pod undocumented
265  
266 36 ▶sub state ($self) {
Subroutine state: called CC=8 SCAR=20.8
Pod undocumented
267 36 ▶ return $self->{fork_state} if $self->{closed} && $self->{fork_state};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} and $self->{"fork_state"} 3 33 36
Condition100%3/3
$self->{"closed"} and $self->{"fork_state"}
!ll&&!rl&&r
22113
MC/DC100%2/2
$self->{"closed"} and $self->{"fork_state"}
$self->{"closed"} $self->{"fork_state"}
Truth table100%3/3
A and B
A= $self->{"closed"}B= $self->{"fork_state"}
ABresult
0X0
100
111
268 33 ▶ return 'detached' if $self->{closed} && $self->{detached};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} and $self->{"detached"} 2 31 33
Condition100%3/3
$self->{"closed"} and $self->{"detached"}
!ll&&!rl&&r
2292
MC/DC100%2/2
$self->{"closed"} and $self->{"detached"}
$self->{"closed"} $self->{"detached"}
Truth table100%3/3
A and B
A= $self->{"closed"}B= $self->{"detached"}
ABresult
0X0
100
111
269 31 ▶ return 'closed' if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 9 22 31
270 22 ▶ return 'unattached' if !$self->{loop};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"loop"} 6 16 22
271 16 ▶ return 'connecting' if $self->{connection};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"connection"} 4 12 16
272 12 return 'active';
273 }
274  
275 1 ▶sub last_error ($self) { $self->{last_error} }
Subroutine last_error: called CC=1 SCAR=0.0
Pod undocumented
276  
277 1113 ▶sub transport ($self) { $self->{transport} }
Subroutine transport: called CC=1 SCAR=0.0
Pod undocumented
278  
279 138 ▶sub is_closed ($self) { !!$self->{closed} }
Subroutine is_closed: called CC=1 SCAR=0.0
Pod undocumented
280  
281 92 ▶sub is_terminal ($self) { !!$self->{closed} }
Subroutine is_terminal: called CC=1 SCAR=0.0
Pod undocumented
282  
283 14 ▶sub is_read_paused ($self) { !!$self->{read_paused} }
Subroutine is_read_paused: called CC=1 SCAR=0.0
Pod undocumented
284  
285 13 ▶sub is_read_eof ($self) { !!$self->{read_eof} }
Subroutine is_read_eof: called CC=1 SCAR=0.0
Pod undocumented
286  
287 14 ▶sub is_read_closed ($self) { !!$self->{read_closed} }
Subroutine is_read_closed: called CC=1 SCAR=0.0
Pod undocumented
288  
289 18 ▶sub is_write_ended ($self) { !!$self->{write_ended} }
Subroutine is_write_ended: called CC=1 SCAR=0.0
Pod undocumented
290  
291 18 ▶sub is_write_blocked ($self) {
Subroutine is_write_blocked: called CC=2 SCAR=9.2
Pod undocumented
292 18 ▶ return !!$self->{xs_state}->is_write_blocked if $self->{xs_state};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"xs_state"} 18 0 18
293 0 return !!$self->{preconnect_write_blocked};
294 }
295  
296 213372 ▶sub data ($self, @arg) {
Subroutine data: called CC=2 SCAR=6.9
Pod undocumented
297 213372 ▶ $self->{data} = $arg[0] if @arg;
Branch: 1 branch
BranchTrueFalseTotal
if @arg 1 213371 213372
298 213372 return $self->{data};
299 }
300  
301 150078 ▶sub pending_bytes ($self) {
Subroutine pending_bytes: called CC=3 SCAR=11.0
Pod undocumented
302 150078 ▶ my $pending = $self->{preconnect_bytes} // 0;
Condition100%2/2
$self->{"preconnect_bytes"} // 0
l!l
11150067
MC/DC100%1/1
$self->{"preconnect_bytes"} // 0
$self->{"preconnect_bytes"}
Truth table100%2/2
A
A= $self->{"preconnect_bytes"}
Aresult
11
00
303 150078 ▶ $pending += $self->{xs_state}->pending_bytes if $self->{xs_state};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"xs_state"} 150076 2 150078
304 150078 return $pending;
305 }
306  
307 100549 ▶sub transport_name ($self) {
Subroutine transport_name: called CC=2 SCAR=6.9
Pod undocumented
308 100549 ▶ return $self->{xs_state}->transport_name if $self->{xs_state};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"xs_state"} 100548 1 100549
309 1 return undef;
310 }
311  
312 8 ▶sub is_transport_ready ($self) {
Subroutine is_transport_ready: called CC=2 SCAR=9.2
Pod undocumented
313 8 ▶ return !!$self->{xs_state}->transport_ready if $self->{xs_state};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"xs_state"} 8 0 8
314 0 return 0;
315 }
316  
317 8 ▶sub idle_timeout ($self) { $self->{timeout}{idle_timeout} }
Subroutine idle_timeout: called CC=1 SCAR=0.0
Pod undocumented
318  
319 4 ▶sub read_timeout ($self) { $self->{timeout}{read_timeout} }
Subroutine read_timeout: called CC=1 SCAR=0.0
Pod undocumented
320  
321 4 ▶sub write_timeout ($self) { $self->{timeout}{write_timeout} }
Subroutine write_timeout: called CC=1 SCAR=0.0
Pod undocumented
322  
323 7 ▶sub deadline ($self) {
Subroutine deadline: called CC=4 SCAR=13.9
Pod undocumented
324 return $self->{operation_deadline_at}
325 7 ▶ if defined $self->{operation_deadline_at};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"operation_deadline_at"} 4 3 7
326 3 ▶ my $spec = $self->{initial_deadline} or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $spec = $self->{"initial_deadline"} or return undef 1 2 3
327 1 ▶ return $spec->{seconds} if $spec->{absolute};
Branch: 1 branch
BranchTrueFalseTotal
if $spec->{"absolute"} 0 1 1
328 1 return undef;
329 }
330  
331 5 ▶sub deadline_operation ($self) {
Subroutine deadline_operation: called CC=3 SCAR=11.1
Pod undocumented
332 return $self->{operation_deadline_name}
333 5 ▶ // ($self->{initial_deadline} && $self->{initial_deadline}{operation});
Condition83%5/6
$self->{"operation_deadline_name"} // $self->{"initial_deadline"} && $self->{"initial_deadline"}{"operation"}
l!l&&r!l&&!r
122
$self->{"initial_deadline"} and $self->{"initial_deadline"}{"operation"}
!ll&&!rl&&r
202
MC/DC66%2/3
$self->{"operation_deadline_name"} // $self->{"initial_deadline"} && $self->{"initial_deadline"}{"operation"}
$self->{"operation_deadline_name"} $self->{"initial_deadline"} $self->{"initial_deadline"}{"operation"}
Truth table75%3/4
A // B and C
A= $self->{"operation_deadline_name"}B= $self->{"initial_deadline"}C= $self->{"initial_deadline"}{"operation"}
ABCresult
1XX1
0111
00X0
0100
334 }
335  
336 # Methods
337  
338 6 ▶sub set_deadline ($self, %option) {
Subroutine set_deadline: called CC=5 SCAR=16.3
Pod undocumented
339 6 ▶ croak 'set_deadline(): stream is closed' if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 1 5 6
340 5 my $spec = _deadline_spec('set_deadline', \%option);
341 5 ▶ if (!$self->{deadline_started}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"deadline_started"}) 0 5 5
342 0 $self->{initial_deadline} = $spec;
343 0 return $self;
344 }
345 5 my $now = _deadline_now();
346 $self->{operation_deadline_at} = $spec->{absolute}
347 5 ▶ ? $spec->{seconds} : $now + $spec->{seconds};
Branch: 1 branch
BranchTrueFalseTotal
$spec->{'absolute'} ? : 1 4 5
348 5 $self->{operation_deadline_name} = $spec->{operation};
349 $self->{operation_deadline_timeout} = $spec->{absolute}
350 5 ▶ ? undef : $spec->{seconds};
Branch: 1 branch
BranchTrueFalseTotal
$spec->{'absolute'} ? : 1 4 5
351 5 $self->_rearm_stream_deadline;
352 5 return $self;
353 }
354  
355 2 ▶sub clear_deadline ($self) {
Subroutine clear_deadline: called CC=3 SCAR=11.2
Pod undocumented
356 2 ▶ croak 'clear_deadline(): stream is closed' if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 2 2
357 2 $self->{initial_deadline} = undef;
358 2 $self->{operation_deadline_at} = undef;
359 2 $self->{operation_deadline_name} = undef;
360 2 $self->{operation_deadline_timeout} = undef;
361 2 ▶ $self->_rearm_stream_deadline if $self->{deadline_started};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"deadline_started"} 2 0 2
362 2 return $self;
363 }
364  
365 11 ▶sub tune ($self, %override) {
Subroutine tune: called CC=20 SCAR=33.4
Pod undocumented
366 11 ▶ Carp::croak('tune(): stream is closed') if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 1 10 11
367 my $xs_state = $self->{xs_state}
368 10 ▶ // Carp::croak('tune(): Stream must be established before live tuning');
Condition50%1/2
$self->{"xs_state"} // Carp::croak("tune(): Stream must be established before live tuning")
l!l
100
MC/DC0%0/1
$self->{"xs_state"} // Carp::croak("tune(): Stream must be established before live tuning")
$self->{"xs_state"}
Truth table50%1/2
A
A= $self->{"xs_state"}
Aresult
11
00
369 10 my $descriptor = $self->{descriptor};
370 10 ▶ my $current = $self->{_effective_tuning} // $descriptor->{options};
Condition66%2/3
$self->{"_effective_tuning"} // $descriptor->{"options"}
l!l&&r!l&&!r
370
MC/DC0%0/2
$self->{"_effective_tuning"} // $descriptor->{"options"}
$self->{"_effective_tuning"} $descriptor->{"options"}
Truth table66%2/3
A // B
A= $self->{"_effective_tuning"}B= $descriptor->{"options"}
ABresult
1X1
011
000
371 10 my $effective = Linux::Event::_ByteStream::Descriptor::merge_tuning(
372 'tune():', $current, \%override,
373 );
374 9 Linux::Event::_ByteStream::Descriptor::validate_modes(
375 'tune():', $descriptor, $effective, {},
376 );
377  
378 9 my %native = map { $_ => $effective->{$_} }
379 Linux::Event::_ByteStream::Descriptor::native_tuning_names();
380  
381 9 ▶ if ($effective->{message_batch_size} != $current->{message_batch_size}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($effective->{"message_batch_size"} != $current->{"message_batch_size"}) 2 7 9
382 2 ▶ my $recipe = $self->{_recipe_input_callbacks} // {};
Condition50%1/2
$self->{"_recipe_input_callbacks"} // {}
l!l
02
MC/DC0%0/1
$self->{"_recipe_input_callbacks"} // {}
$self->{"_recipe_input_callbacks"}
Truth table50%1/2
A
A= $self->{"_recipe_input_callbacks"}
Aresult
11
00
383 2 my $callback = Linux::Event::_ByteStream::Descriptor::effective_input_callback(
384 $descriptor, $effective, $recipe,
385 );
386 Carp::croak(
387 'tune(): changing message_batch_size requires the corresponding '
388 . 'on_message/on_messages callback',
389 2 ▶ ) if $self->{read_capable} && !$descriptor->{consumer} && !$callback;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"read_capable"} and not $descriptor->{"consumer"} and not $callback 0 2 2
Condition33%2/6
$self->{"read_capable"} and not $descriptor->{"consumer"} and not $callback
!ll&&!rl&&r
020
$self->{"read_capable"} and not $descriptor->{"consumer"}
!ll&&!rl&&r
002
MC/DC0%0/3
$self->{"read_capable"} and not $descriptor->{"consumer"} and not $callback
$self->{"read_capable"} not $descriptor->{"consumer"} not $callback
Truth table25%1/4
A and not(B) and not(C)
A= $self->{"read_capable"}B= not $descriptor->{"consumer"}C= not $callback
ABCresult
0XX0
10X0
1100
1111
390 2 $native{input_cb} = $callback;
391 }
392  
393 9 $xs_state->_transition_validated($descriptor->{native}, \%native);
394 9 ▶ return $self if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 9 9
395  
396 9 $self->{_effective_tuning} = $effective;
397 9 for my $name (qw(idle_timeout read_timeout write_timeout)) {
398 27 $self->{timeout}{$name} = $effective->{$name};
399 $self->{timeout_override}{$name} = $effective->{$name}
400 27 ▶ if exists $override{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $override{$name} 2 25 27
401 }
402  
403 9 ▶ if ($self->{deadline_started}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"deadline_started"}) 9 0 9
404 9 my $needs_tracking = $self->_needs_activity_tracking;
405 9 ▶ if ($needs_tracking && !$self->{deadline_tracking}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($needs_tracking and not $self->{'deadline_tracking'}) { } 1 8 9
elsif (not $needs_tracking and $self->{'deadline_tracking'}) { } 0 9 9
Condition100%3/3
$needs_tracking and not $self->{"deadline_tracking"}
!ll&&!rl&&r
711
MC/DC100%2/2
$needs_tracking and not $self->{"deadline_tracking"}
$needs_tracking not $self->{"deadline_tracking"}
Truth table100%3/3
A and not(B)
A= $needs_trackingB= not $self->{"deadline_tracking"}
ABresult
0X0
100
111
406 1 $xs_state->_set_activity_tracking(1);
407 1 $self->{deadline_tracking} = 1;
408 ▶ } elsif (!$needs_tracking && $self->{deadline_tracking}) {
Condition66%2/3
not $needs_tracking and $self->{"deadline_tracking"}
!ll&&!rl&&r
170
MC/DC0%0/2
not $needs_tracking and $self->{"deadline_tracking"}
not $needs_tracking $self->{"deadline_tracking"}
Truth table66%2/3
not(A) and B
A= not $needs_trackingB= $self->{"deadline_tracking"}
ABresult
0X0
100
111
409 0 $xs_state->_set_activity_tracking(0);
410 0 $self->{deadline_tracking} = 0;
411 }
412 9 ▶ if (exists $override{read_timeout}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $override{"read_timeout"}) 0 9 9
413 $self->{deadline_read_started}
414 0 = Linux::Event::_ByteStream::_deadline_now();
415 }
416 9 ▶ if (exists $override{write_timeout}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $override{"write_timeout"}) 0 9 9
417 0 ▶ $self->{deadline_write_started} = $self->pending_bytes > 0
Branch: 1 branch
BranchTrueFalseTotal
$self->pending_bytes > 0 ? : 0 0 0
418 ? Linux::Event::_ByteStream::_deadline_now() : undef;
419 }
420 9 $self->_rearm_stream_deadline;
421 }
422  
423 9 return $self;
424 }
425  
426 49171 ▶sub write ($self, $bytes) {
Subroutine write: called CC=23 SCAR=33.3
Pod undocumented
427 49171 ▶ croak 'write(): stream is closed' if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 49171 49171
428 croak 'write(): stream has no writable side'
429 49171 ▶ if !defined $self->{write_fh} && !$self->{connection};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"write_fh"} or $self->{"connection"} 0 49171 49171
Condition66%2/3
defined $self->{"write_fh"} or $self->{"connection"}
l!l&&r!l&&!r
4916650
MC/DC0%0/2
defined $self->{"write_fh"} or $self->{"connection"}
defined $self->{"write_fh"} $self->{"connection"}
Truth table66%2/3
A or B
A= defined $self->{"write_fh"}B= $self->{"connection"}
ABresult
1X1
011
000
430 croak 'write(): writable side has ended'
431 49171 ▶ if $self->{write_ending} || $self->{write_ended};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"write_ending"} or $self->{"write_ended"} 1 49170 49171
Condition66%2/3
$self->{"write_ending"} or $self->{"write_ended"}
l!l&&r!l&&!r
0149170
MC/DC50%1/2
$self->{"write_ending"} or $self->{"write_ended"}
$self->{"write_ending"} $self->{"write_ended"}
Truth table66%2/3
A or B
A= $self->{"write_ending"}B= $self->{"write_ended"}
ABresult
1X1
011
000
432 49170 ▶ return 1 if !defined $bytes;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $bytes 0 49170 49170
433 49170 ▶ croak 'write(): bytes must be a scalar byte string' if ref $bytes;
Branch: 1 branch
BranchTrueFalseTotal
if ref $bytes 0 49170 49170
434 49170 $bytes = "$bytes";
435 49170 ▶ croak 'write(): bytes must be a scalar byte string'
Branch: 1 branch
BranchTrueFalseTotal
unless utf8::downgrade($bytes, 1) 1 49169 49170
436 if !utf8::downgrade($bytes, 1);
437 49169 ▶ return 1 if $bytes eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $bytes eq "" 1 49168 49169
438  
439 49168 ▶ if (!$self->{xs_state}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"xs_state"}) 5 49163 49168
440 croak 'write(): stream has no pending or active transport'
441 5 ▶ if !$self->{connection};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"connection"} 0 5 5
442 5 ▶ my $pending = ($self->{preconnect_bytes} // 0) + length($bytes);
Condition50%1/2
$self->{"preconnect_bytes"} // 0
l!l
50
MC/DC0%0/1
$self->{"preconnect_bytes"} // 0
$self->{"preconnect_bytes"}
Truth table50%1/2
A
A= $self->{"preconnect_bytes"}
Aresult
11
00
443 5 my $limit = $self->{descriptor}{options}{max_pending_bytes};
444 5 ▶ if ($limit && $pending > $limit) {
Branch: 1 branch
BranchTrueFalseTotal
if ($limit and $pending > $limit) 0 5 5
Condition33%1/3
$limit and $pending > $limit
!ll&&!rl&&r
500
MC/DC0%0/2
$limit and $pending > $limit
$limit $pending > $limit
Truth table33%1/3
A and B
A= $limitB= $pending > $limit
ABresult
0X0
100
111
445 0 my $error = Linux::Event::Error->new(
446 type => 'output_limit',
447 operation => 'write',
448 message => "pending output would exceed $limit bytes",
449 pending_bytes => $pending,
450 limit => $limit,
451 );
452 0 $self->_fail($error);
453 0 return 0;
454 }
455 5 ▶ push @{ $self->{preconnect_output} //= [] }, "$bytes";
Condition50%1/2
$self->{"preconnect_output"} //= []
l!l
50
MC/DC0%0/1
$self->{"preconnect_output"} //= []
$self->{"preconnect_output"}
Truth table50%1/2
A
A= $self->{"preconnect_output"}
Aresult
11
00
456 5 $self->{preconnect_bytes} = $pending;
457 5 ▶ if ($pending > $self->{descriptor}{options}{high_watermark}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pending > $self->{"descriptor"}{"options"}{"high_watermark"}) 1 4 5
458 1 $self->{preconnect_write_blocked} = 1;
459 1 return 0;
460 }
461 4 return 1;
462 }
463  
464 49163 my $was_pending = $self->pending_bytes;
465 49163 my $status = $self->{xs_state}->_write($bytes);
466 49163 ▶ $self->_request_write_ready if $status & 0x02;
Branch: 1 branch
BranchTrueFalseTotal
if $status & 2 31 49132 49163
467 49163 ▶ if ($self->{deadline_started} && $self->{timeout}{write_timeout} > 0
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"deadline_started"} and $self->{"timeout"}{"write_timeout"} > 0 and not $was_pending and $self->pending_bytes > 0) 1 49162 49163
Condition77%7/9
$self->{"deadline_started"} and $self->{"timeout"}{"write_timeout"} > 0 and not $was_pending and $self->pending_bytes > 0
!ll&&!rl&&r
4916201
$self->{"deadline_started"} and $self->{"timeout"}{"write_timeout"} > 0 and not $was_pending
!ll&&!rl&&r
4916201
$self->{"deadline_started"} and $self->{"timeout"}{"write_timeout"} > 0
!ll&&!rl&&r
5491571
MC/DC50%2/4
$self->{"deadline_started"} and $self->{"timeout"}{"write_timeout"} > 0 and not $was_pending and $self->pending_bytes > 0
$self->{"deadline_started"} $self->{"timeout"}{"write_timeout"} > 0 not $was_pending $self->pending_bytes > 0
Truth table60%3/5
A and B and not(C) and D
A= $self->{"deadline_started"}B= $self->{"timeout"}{"write_timeout"} > 0C= not $was_pendingD= $self->pending_bytes > 0
ABCDresult
0XXX0
10XX0
110X0
11100
11111
468 && !$was_pending && $self->pending_bytes > 0) {
469 1 $self->{deadline_write_started} = _deadline_now();
470 1 $self->_rearm_stream_deadline;
471 }
472 49163 ▶ return $status & 0x01 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$status & 1 ? : 49137 26 49163
473 }
474  
475 16361 ▶sub send ($self, $payload) {
Subroutine send: called CC=2 SCAR=7.1
Pod undocumented
476 my $framer = $self->{descriptor}{framer}
477 16361 ▶ // croak 'send(): requires a framed Stream subclass';
Condition50%1/2
$self->{"descriptor"}{"framer"} // croak("send(): requires a framed Stream subclass")
l!l
163610
MC/DC0%0/1
$self->{"descriptor"}{"framer"} // croak("send(): requires a framed Stream subclass")
$self->{"descriptor"}{"framer"}
Truth table50%1/2
A
A= $self->{"descriptor"}{"framer"}
Aresult
11
00
478 16361 my $bytes = $framer->{frame}->($framer->{native}, $payload);
479 16357 return $self->write($bytes);
480 }
481  
482 22 ▶sub end ($self, $final_bytes = undef) {
Subroutine end: called CC=11 SCAR=30.4
Pod undocumented
483 return $self
484 if $self->{closed} || $self->{write_ending} || $self->{write_ended}
485 22 ▶ || (!defined($self->{write_fh}) && !$self->{connection});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or $self->{"write_ending"} or $self->{"write_ended"} or not defined $self->{"write_fh"} || $self->{"connection"} 0 22 22
Condition33%4/12
$self->{"closed"} or $self->{"write_ending"} or $self->{"write_ended"} or not defined $self->{"write_fh"} || $self->{"connection"}
l!l&&r!l&&!r
0022
$self->{"closed"} or $self->{"write_ending"} or $self->{"write_ended"}
l!l&&r!l&&!r
0022
$self->{"closed"} or $self->{"write_ending"}
l!l&&r!l&&!r
0022
defined $self->{'write_fh'} || $self->{'connection'}
l!l&&r!l&&!r
2200
MC/DC0%0/5
$self->{"closed"} or $self->{"write_ending"} or $self->{"write_ended"} or not defined $self->{"write_fh"} || $self->{"connection"}
$self->{"closed"} $self->{"write_ending"} $self->{"write_ended"} defined $self->{'write_fh'} $self->{'connection'}
Truth table16%1/6
A or B or C or not(D || E)
A= $self->{"closed"}B= $self->{"write_ending"}C= $self->{"write_ended"}D= defined $self->{'write_fh'}E= $self->{'connection'}
ABCDEresult
1XXXX1
01XXX1
001XX1
000001
0001X0
000010
486 22 ▶ $self->write($final_bytes) if defined($final_bytes) && $final_bytes ne '';
Branch: 1 branch
BranchTrueFalseTotal
if defined $final_bytes and $final_bytes ne "" 0 22 22
Condition33%1/3
defined $final_bytes and $final_bytes ne ""
!ll&&!rl&&r
2200
MC/DC0%0/2
defined $final_bytes and $final_bytes ne ""
defined $final_bytes $final_bytes ne ""
Truth table33%1/3
A and B
A= defined $final_bytesB= $final_bytes ne ""
ABresult
0X0
100
111
487 22 $self->{write_ending} = 1;
488 $self->_finish_write_side
489 22 ▶ if $self->{xs_state} && $self->pending_bytes == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"xs_state"} and $self->pending_bytes == 0 15 7 22
Condition66%2/3
$self->{"xs_state"} and $self->pending_bytes == 0
!ll&&!rl&&r
0715
MC/DC50%1/2
$self->{"xs_state"} and $self->pending_bytes == 0
$self->{"xs_state"} $self->pending_bytes == 0
Truth table66%2/3
A and B
A= $self->{"xs_state"}B= $self->pending_bytes == 0
ABresult
0X0
100
111
490 22 return $self;
491 }
492  
493 18 ▶sub pause_read ($self) {
Subroutine pause_read: called CC=10 SCAR=24.9
Pod undocumented
494 18 ▶ return $self if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 18 18
495 croak 'pause_read(): stream has no readable side'
496 18 ▶ if !$self->{read_capable};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"read_capable"} 0 18 18
497 return $self
498 18 ▶ if $self->{read_eof} || $self->{read_closed} || $self->{read_paused};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"read_eof"} or $self->{"read_closed"} or $self->{"read_paused"} 0 18 18
Condition33%2/6
$self->{"read_eof"} or $self->{"read_closed"} or $self->{"read_paused"}
l!l&&r!l&&!r
0018
$self->{"read_eof"} or $self->{"read_closed"}
l!l&&r!l&&!r
0018
MC/DC0%0/3
$self->{"read_eof"} or $self->{"read_closed"} or $self->{"read_paused"}
$self->{"read_eof"} $self->{"read_closed"} $self->{"read_paused"}
Truth table25%1/4
A or B or C
A= $self->{"read_eof"}B= $self->{"read_closed"}C= $self->{"read_paused"}
ABCresult
1XX1
01X1
0011
0000
499 18 $self->{read_paused} = 1;
500 18 ▶ $self->{xs_state}->_pause if $self->{xs_state};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"xs_state"} 18 0 18
501 18 ▶ $self->{read_watcher}->disable_read if $self->{read_watcher};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"read_watcher"} 17 1 18
502 $self->_rearm_stream_deadline
503 18 ▶ if $self->{deadline_started} && $self->{timeout}{read_timeout} > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"deadline_started"} and $self->{"timeout"}{"read_timeout"} > 0 3 15 18
Condition100%3/3
$self->{"deadline_started"} and $self->{"timeout"}{"read_timeout"} > 0
!ll&&!rl&&r
2133
MC/DC100%2/2
$self->{"deadline_started"} and $self->{"timeout"}{"read_timeout"} > 0
$self->{"deadline_started"} $self->{"timeout"}{"read_timeout"} > 0
Truth table100%3/3
A and B
A= $self->{"deadline_started"}B= $self->{"timeout"}{"read_timeout"} > 0
ABresult
0X0
100
111
504 18 return $self;
505 }
506  
507 17 ▶sub resume_read ($self) {
Subroutine resume_read: called CC=13 SCAR=29.8
Pod undocumented
508 17 ▶ return $self if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 17 17
509 croak 'resume_read(): stream has no readable side'
510 17 ▶ if !$self->{read_capable};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"read_capable"} 0 17 17
511 return $self
512 17 ▶ if $self->{read_eof} || $self->{read_closed} || !$self->{read_paused};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"read_eof"} or $self->{"read_closed"} or not $self->{"read_paused"} 0 17 17
Condition33%2/6
$self->{"read_eof"} or $self->{"read_closed"} or not $self->{"read_paused"}
l!l&&r!l&&!r
0017
$self->{"read_eof"} or $self->{"read_closed"}
l!l&&r!l&&!r
0017
MC/DC0%0/3
$self->{"read_eof"} or $self->{"read_closed"} or not $self->{"read_paused"}
$self->{"read_eof"} $self->{"read_closed"} not $self->{"read_paused"}
Truth table25%1/4
A or B or not(C)
A= $self->{"read_eof"}B= $self->{"read_closed"}C= not $self->{"read_paused"}
ABCresult
1XX1
01X1
0011
0000
513 17 $self->{read_paused} = 0;
514 $self->{deadline_read_started} = _deadline_now()
515 17 ▶ if $self->{deadline_started} && $self->{timeout}{read_timeout} > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"deadline_started"} and $self->{"timeout"}{"read_timeout"} > 0 2 15 17
Condition66%2/3
$self->{"deadline_started"} and $self->{"timeout"}{"read_timeout"} > 0
!ll&&!rl&&r
0152
MC/DC50%1/2
$self->{"deadline_started"} and $self->{"timeout"}{"read_timeout"} > 0
$self->{"deadline_started"} $self->{"timeout"}{"read_timeout"} > 0
Truth table66%2/3
A and B
A= $self->{"deadline_started"}B= $self->{"timeout"}{"read_timeout"} > 0
ABresult
0X0
100
111
516 17 ▶ $self->{xs_state}->_resume if $self->{xs_state};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"xs_state"} 17 0 17
517 $self->{read_watcher}->enable_read
518 17 ▶ if $self->{read_watcher} && !$self->{xs_state}->consumer_paused;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"read_watcher"} and not $self->{"xs_state"}->consumer_paused 17 0 17
Condition33%1/3
$self->{"read_watcher"} and not $self->{"xs_state"}->consumer_paused
!ll&&!rl&&r
0017
MC/DC0%0/2
$self->{"read_watcher"} and not $self->{"xs_state"}->consumer_paused
$self->{"read_watcher"} not $self->{"xs_state"}->consumer_paused
Truth table33%1/3
A and not(B)
A= $self->{"read_watcher"}B= not $self->{"xs_state"}->consumer_paused
ABresult
0X0
100
111
519 $self->_rearm_stream_deadline
520 17 ▶ if $self->{deadline_started} && $self->{timeout}{read_timeout} > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"deadline_started"} and $self->{"timeout"}{"read_timeout"} > 0 2 15 17
Condition66%2/3
$self->{"deadline_started"} and $self->{"timeout"}{"read_timeout"} > 0
!ll&&!rl&&r
0152
MC/DC50%1/2
$self->{"deadline_started"} and $self->{"timeout"}{"read_timeout"} > 0
$self->{"deadline_started"} $self->{"timeout"}{"read_timeout"} > 0
Truth table66%2/3
A and B
A= $self->{"deadline_started"}B= $self->{"timeout"}{"read_timeout"} > 0
ABresult
0X0
100
111
521 17 return $self;
522 }
523  
524 155 ▶sub transition_to ($self, $class, %opt) {
Subroutine transition_to: called CC=24 SCAR=33.0
Pod undocumented
525 155 ▶ croak 'transition_to(): stream is closed' if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 1 154 155
526 154 ▶ croak 'transition_to(): target class is required'
Branch: 1 branch
BranchTrueFalseTotal
if not defined $class or ref $class or $class eq "" 0 154 154
Condition33%2/6
not defined $class or ref $class or $class eq ""
l!l&&r!l&&!r
00154
not defined $class or ref $class
l!l&&r!l&&!r
00154
MC/DC0%0/3
not defined $class or ref $class or $class eq ""
not defined $class ref $class $class eq ""
Truth table25%1/4
not(A) or B or C
A= not defined $classB= ref $classC= $class eq ""
ABCresult
1XX1
01X1
0011
0000
527 if !defined($class) || ref($class) || $class eq '';
528 154 ▶ croak "transition_to(): $class is already active"
Branch: 1 branch
BranchTrueFalseTotal
if ref $self eq $class 1 153 154
529 if ref($self) eq $class;
530 153 Linux::Event::_IO::_guard_transition_resource_kind($self, $class);
531  
532 145 my $input = delete $opt{input};
533 145 ▶ croak 'transition_to(): input must be a byte string'
Branch: 1 branch
BranchTrueFalseTotal
if defined $input and ref $input 0 145 145
Condition66%2/3
defined $input and ref $input
!ll&&!rl&&r
13780
MC/DC0%0/2
defined $input and ref $input
defined $input ref $input
Truth table66%2/3
A and B
A= defined $inputB= ref $input
ABresult
0X0
100
111
534 if defined($input) && ref($input);
535 145 ▶ if (defined $input) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $input) 8 137 145
536 8 $input = "$input";
537 8 ▶ croak 'transition_to(): input must be a byte string'
Branch: 1 branch
BranchTrueFalseTotal
unless utf8::downgrade($input, 1) 0 8 8
538 if !utf8::downgrade($input, 1);
539 }
540 145 ▶ croak 'transition_to(): unknown options: ' . join(', ', sort keys %opt)
Branch: 1 branch
BranchTrueFalseTotal
if %opt 1 144 145
541 if %opt;
542  
543 144 my $descriptor = Linux::Event::_ByteStream::Descriptor::for_class($class);
544 my $xs_state = $self->{xs_state}
545 144 ▶ // croak 'transition_to(): stream has no native state';
Condition50%1/2
$self->{"xs_state"} // croak("transition_to(): stream has no native state")
l!l
1440
MC/DC0%0/1
$self->{"xs_state"} // croak("transition_to(): stream has no native state")
$self->{"xs_state"}
Truth table50%1/2
A
A= $self->{"xs_state"}
Aresult
11
00
546 144 my $source_consumer = $self->{descriptor}{consumer};
547 144 my $target_consumer = $descriptor->{consumer};
548 my $source_ops = $source_consumer
549 144 ▶ ? $source_consumer->{operations_address} : 0;
Branch: 1 branch
BranchTrueFalseTotal
$source_consumer ? : 10 134 144
550 my $target_ops = $target_consumer
551 144 ▶ ? $target_consumer->{operations_address} : 0;
Branch: 1 branch
BranchTrueFalseTotal
$target_consumer ? : 7 137 144
552 144 ▶ croak 'transition_to(): cannot add a native consumer provider'
Branch: 1 branch
BranchTrueFalseTotal
if not $source_ops and $target_ops 1 143 144
Condition100%3/3
not $source_ops and $target_ops
!ll&&!rl&&r
101331
MC/DC100%2/2
not $source_ops and $target_ops
not $source_ops $target_ops
Truth table100%3/3
not(A) and B
A= not $source_opsB= $target_ops
ABresult
0X0
100
111
553 if !$source_ops && $target_ops;
554 _require_read_sink(
555 $descriptor,
556 $self->{_input_callback_overrides},
557 $self->{read_capable} && !$self->{read_closed} && !$self->{read_eof},
558 143 ▶ 'transition_to(): target readable raw Stream has no on_data callback',
Condition33%2/6
$self->{'read_capable'} && !$self->{'read_closed'} && !$self->{'read_eof'}
!ll&&!rl&&r
00143
$self->{"read_capable"} and not $self->{"read_closed"}
!ll&&!rl&&r
00143
MC/DC0%0/3
$self->{'read_capable'} && !$self->{'read_closed'} && !$self->{'read_eof'}
$self->{"read_capable"} not $self->{"read_closed"} !$self->{'read_eof'}
Truth table25%1/4
A and not(B) && not(C)
A= $self->{"read_capable"}B= not $self->{"read_closed"}C= !$self->{'read_eof'}
ABCresult
0XX0
10X0
1100
1111
559 'transition_to(): target readable framed Stream has no message sink',
560 );
561  
562 141 ▶ my $input_bytes = defined($input) ? length($input) : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $input ? : 8 133 141
563 141 ▶ if ($descriptor->{framer} && $descriptor->{options}{max_buffer}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($descriptor->{"framer"} and $descriptor->{"options"}{"max_buffer"}) 64 77 141
Condition66%2/3
$descriptor->{"framer"} and $descriptor->{"options"}{"max_buffer"}
!ll&&!rl&&r
77064
MC/DC50%1/2
$descriptor->{"framer"} and $descriptor->{"options"}{"max_buffer"}
$descriptor->{"framer"} $descriptor->{"options"}{"max_buffer"}
Truth table66%2/3
A and B
A= $descriptor->{"framer"}B= $descriptor->{"options"}{"max_buffer"}
ABresult
0X0
100
111
564 64 my $preserved = $xs_state->_input_buffered_bytes + $input_bytes;
565 croak 'transition_to(): preserved input exceeds target max_buffer'
566 64 ▶ if $preserved > $descriptor->{options}{max_buffer};
Branch: 1 branch
BranchTrueFalseTotal
if $preserved > $descriptor->{"options"}{"max_buffer"} 1 63 64
567 }
568 140 my $pending_limit = $descriptor->{options}{max_pending_bytes};
569 140 ▶ croak 'transition_to(): queued output exceeds target max_pending_bytes'
Branch: 1 branch
BranchTrueFalseTotal
if $pending_limit and $xs_state->pending_bytes > $pending_limit 1 139 140
Condition66%2/3
$pending_limit and $xs_state->pending_bytes > $pending_limit
!ll&&!rl&&r
13901
MC/DC50%1/2
$pending_limit and $xs_state->pending_bytes > $pending_limit
$pending_limit $xs_state->pending_bytes > $pending_limit
Truth table66%2/3
A and B
A= $pending_limitB= $xs_state->pending_bytes > $pending_limit
ABresult
0X0
100
111
570 if $pending_limit && $xs_state->pending_bytes > $pending_limit;
571  
572 # XS validates and swaps the immutable descriptor without invoking a
573 # callback. Update the Perl object's type before buffered input is allowed
574 # to enter the new callback set.
575 my $callbacks = _effective_lifecycle_callbacks(
576 $descriptor, $self->{callback_overrides},
577 139 );
578 139 $xs_state->_transition_validated($descriptor->{native}, $input);
579 138 $self->{descriptor} = $descriptor;
580 138 $self->{callbacks} = $callbacks;
581 138 bless $self, $class;
582 138 $self->_apply_transition_timeouts($descriptor);
583 138 $xs_state->_transition_ready;
584 138 return $self;
585 }
586  
587 2582 ▶sub close ($self) {
Subroutine close: called CC=1 SCAR=0.0
Pod undocumented
588 2582 $self->_close_now(1);
589 2579 return $self;
590 }
591  
592 7 ▶sub close_read ($self) {
Subroutine close_read: called CC=6 SCAR=18.7
Pod undocumented
593 7 ▶ return $self if $self->{closed} || $self->{read_closed} || $self->{read_eof};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or $self->{"read_closed"} or $self->{"read_eof"} 0 7 7
Condition33%2/6
$self->{"closed"} or $self->{"read_closed"} or $self->{"read_eof"}
l!l&&r!l&&!r
007
$self->{"closed"} or $self->{"read_closed"}
l!l&&r!l&&!r
007
MC/DC0%0/3
$self->{"closed"} or $self->{"read_closed"} or $self->{"read_eof"}
$self->{"closed"} $self->{"read_closed"} $self->{"read_eof"}
Truth table25%1/4
A or B or C
A= $self->{"closed"}B= $self->{"read_closed"}C= $self->{"read_eof"}
ABCresult
1XX1
01X1
0011
0000
594 7 $self->{read_closed} = 1;
595 7 my $failure;
596 7 ▶ _teardown_step(\$failure, sub {
Subroutine __ANON__: called CC=2 SCAR=7.6
597 7 ▶ $self->{xs_state}->_close_read(6) if $self->{xs_state};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"xs_state"} 7 0 7
598 7 });
599 7 ▶ _teardown_step(\$failure, sub { $self->_release_read_side });
Subroutine __ANON__: called CC=1 SCAR=0.0
600 3 ▶ _teardown_step(\$failure, sub { $self->_close_now(1) })
Subroutine __ANON__: called CC=1 SCAR=0.0
601 7 ▶ if $self->{write_ended};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"write_ended"} 3 4 7
602 7 ▶ die $failure if defined $failure;
Branch: 1 branch
BranchTrueFalseTotal
if defined $failure 2 5 7
603 5 return $self;
604 }
605  
606 4 ▶sub close_write ($self) {
Subroutine close_write: called CC=6 SCAR=18.3
Pod undocumented
607 4 ▶ return $self if $self->{closed} || $self->{write_ended};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or $self->{"write_ended"} 0 4 4
Condition33%1/3
$self->{"closed"} or $self->{"write_ended"}
l!l&&r!l&&!r
004
MC/DC0%0/2
$self->{"closed"} or $self->{"write_ended"}
$self->{"closed"} $self->{"write_ended"}
Truth table33%1/3
A or B
A= $self->{"closed"}B= $self->{"write_ended"}
ABresult
1X1
011
000
608 4 my $failure;
609 4 ▶ _teardown_step(\$failure, sub {
Subroutine __ANON__: called CC=2 SCAR=7.6
610 4 ▶ $self->{xs_state}->_close_write if $self->{xs_state};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"xs_state"} 4 0 4
611 4 });
612 4 $self->{write_ending} = 0;
613 4 $self->{write_ended} = 1;
614 4 ▶ _teardown_step(\$failure, sub { $self->_release_write_side });
Subroutine __ANON__: called CC=1 SCAR=0.0
615 3 ▶ _teardown_step(\$failure, sub { $self->_close_now(1) })
Subroutine __ANON__: called CC=1 SCAR=0.0
616 4 ▶ if $self->{read_eof} || $self->{read_closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"read_eof"} or $self->{"read_closed"} 3 1 4
Condition66%2/3
$self->{"read_eof"} or $self->{"read_closed"}
l!l&&r!l&&!r
031
MC/DC50%1/2
$self->{"read_eof"} or $self->{"read_closed"}
$self->{"read_eof"} $self->{"read_closed"}
Truth table66%2/3
A or B
A= $self->{"read_eof"}B= $self->{"read_closed"}
ABresult
1X1
011
000
617 4 ▶ die $failure if defined $failure;
Branch: 1 branch
BranchTrueFalseTotal
if defined $failure 1 3 4
618 3 return $self;
619 }
620  
621 100497 ▶sub detach ($self) {
Subroutine detach: called CC=10 SCAR=23.3
Pod undocumented
622 100497 ▶ croak 'detach(): stream is already closed' if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 100497 100497
623 croak 'detach(): stream is not established'
624 100497 ▶ if !defined($self->{read_fh}) && !defined($self->{write_fh});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"read_fh"} or defined $self->{"write_fh"} 0 100497 100497
Condition33%1/3
defined $self->{"read_fh"} or defined $self->{"write_fh"}
l!l&&r!l&&!r
10049700
MC/DC0%0/2
defined $self->{"read_fh"} or defined $self->{"write_fh"}
defined $self->{"read_fh"} defined $self->{"write_fh"}
Truth table33%1/3
A or B
A= defined $self->{"read_fh"}B= defined $self->{"write_fh"}
ABresult
1X1
011
000
625 100497 ▶ croak 'detach(): pending output must drain before detach'
Branch: 1 branch
BranchTrueFalseTotal
if $self->pending_bytes 1 100496 100497
626 if $self->pending_bytes;
627 100496 ▶ croak 'detach(): cannot detach a non-plain transport'
Branch: 1 branch
BranchTrueFalseTotal
if ($self->transport_name // "plain") ne "plain" 1 100495 100496
Condition50%1/2
$self->transport_name // "plain"
l!l
1004960
MC/DC0%0/1
$self->transport_name // "plain"
$self->transport_name
Truth table50%1/2
A
A= $self->transport_name
Aresult
11
00
628 if ($self->transport_name // 'plain') ne 'plain';
629 my $handles = {
630 read_fh => $self->{read_fh},
631 write_fh => $self->{write_fh},
632 100495 };
633 100495 my $failure;
634 100495 ▶ _teardown_step(\$failure, sub { $self->_cancel_stream_deadline });
Subroutine __ANON__: called CC=1 SCAR=0.0
635 100495 ▶ if (my $xs_state = delete $self->{xs_state}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $xs_state = delete $self->{"xs_state"}) 100495 0 100495
636 100495 ▶ _teardown_step(\$failure, sub { $xs_state->_close(5) });
Subroutine __ANON__: called CC=1 SCAR=0.0
637 }
638 100495 ▶ _teardown_step(\$failure, sub { $self->_cancel_io_watchers });
Subroutine __ANON__: called CC=1 SCAR=0.0
639 1 ▶ _teardown_step(\$failure, sub { $self->_restore_borrowed_handles })
Subroutine __ANON__: called CC=1 SCAR=0.0
640 100495 ▶ if !$self->{owns_handles};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"owns_handles"} 1 100494 100495
641 100495 $self->{closed} = 1;
642 100495 delete @$self{qw(
643 callbacks callback_overrides _input_callbacks
644 _input_callback_overrides
645 )};
646 100495 $self->{detached} = 1;
647 100495 ▶ if (defined $failure) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $failure) { } 1 100494 100495
648 1 ▶ _teardown_step(\$failure, sub { $self->_close_handles });
Subroutine __ANON__: called CC=1 SCAR=0.0
649 1 die $failure;
650 } else {
651 100494 $self->{read_fh} = undef;
652 100494 $self->{write_fh} = undef;
653 }
654 100494 return $handles;
655 }
656  
657 # Private helpers and internal overrides
658  
659 1145 ▶sub _callback_names () { @APPLICATION_CALLBACK }
Subroutine _callback_names: called CC=1 SCAR=0.0
660  
661 103210 ▶sub _take_callbacks ($method, $option) {
Subroutine _take_callbacks: called CC=4 SCAR=13.9
662 103210 my %callback;
663 103210 for my $name (@APPLICATION_CALLBACK) {
664 928882 ▶ next if !exists $option->{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $option->{$name} 928784 98 928882
665 98 my $value = delete $option->{$name};
666 98 ▶ croak "$method(): $name must be a coderef" if ref($value) ne 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $value ne "CODE" 1 97 98
667 97 $callback{$name} = $value;
668 }
669 103209 return \%callback;
670 }
671  
672 103167 ▶sub _validate_callback_modes ($method, $descriptor, $callback) {
Subroutine _validate_callback_modes: called CC=13 SCAR=25.7
673 103167 ▶ if (!$descriptor->{framer}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($descriptor->{"framer"}) 52728 50439 103167
674 croak "$method(): on_message requires a framed ordered-byte class"
675 52728 ▶ if $callback->{on_message};
Branch: 1 branch
BranchTrueFalseTotal
if $callback->{"on_message"} 1 52727 52728
676 croak "$method(): on_messages requires a framed ordered-byte class"
677 52727 ▶ if $callback->{on_messages};
Branch: 1 branch
BranchTrueFalseTotal
if $callback->{"on_messages"} 0 52727 52727
678 croak "$method(): on_data cannot be combined with a native consumer"
679 52727 ▶ if $descriptor->{consumer} && $callback->{on_data};
Branch: 1 branch
BranchTrueFalseTotal
if $descriptor->{"consumer"} and $callback->{"on_data"} 1 52726 52727
Condition100%3/3
$descriptor->{"consumer"} and $callback->{"on_data"}
!ll&&!rl&&r
52715111
MC/DC100%2/2
$descriptor->{"consumer"} and $callback->{"on_data"}
$descriptor->{"consumer"} $callback->{"on_data"}
Truth table100%3/3
A and B
A= $descriptor->{"consumer"}B= $callback->{"on_data"}
ABresult
0X0
100
111
680 52726 return;
681 }
682  
683 croak "$method(): on_data requires a raw ordered-byte class"
684 50439 ▶ if $callback->{on_data};
Branch: 1 branch
BranchTrueFalseTotal
if $callback->{"on_data"} 1 50438 50439
685 50438 ▶ if ($descriptor->{consumer}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($descriptor->{"consumer"}) 39 50399 50438
686 croak "$method(): on_message cannot be combined with a native consumer"
687 39 ▶ if $callback->{on_message};
Branch: 1 branch
BranchTrueFalseTotal
if $callback->{"on_message"} 1 38 39
688 croak "$method(): on_messages cannot be combined with a native consumer"
689 38 ▶ if $callback->{on_messages};
Branch: 1 branch
BranchTrueFalseTotal
if $callback->{"on_messages"} 0 38 38
690 38 return;
691 }
692 50399 ▶ if ($descriptor->{options}{message_batch_size}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($descriptor->{'options'}{'message_batch_size'}) { } 21 50378 50399
693 croak "$method(): on_message cannot be combined with message_batch_size"
694 21 ▶ if $callback->{on_message};
Branch: 1 branch
BranchTrueFalseTotal
if $callback->{"on_message"} 1 20 21
695 } else {
696 croak "$method(): on_messages requires message_batch_size"
697 50378 ▶ if $callback->{on_messages};
Branch: 1 branch
BranchTrueFalseTotal
if $callback->{"on_messages"} 1 50377 50378
698 }
699 50397 return;
700 }
701  
702 103300 ▶sub _effective_lifecycle_callbacks ($descriptor, $override) {
Subroutine _effective_lifecycle_callbacks: called CC=2 SCAR=6.9
703 return {
704 map {
705 103300 $_ => exists($override->{$_})
706 619800 ▶ ? $override->{$_} : $descriptor->{callbacks}{$_}
Branch: 1 branch
BranchTrueFalseTotal
exists $override->{$_} ? : 14 619786 619800
707 } @LIFECYCLE_CALLBACK
708 };
709 }
710  
711 6 ▶sub _declare_framer ($base, $target, $definition) {
Subroutine _declare_framer: called CC=1 SCAR=0.0
712 6 return Linux::Event::_ByteStream::Descriptor::declare_framer(
713 $base, $target, $definition,
714 );
715 }
716  
717 24 ▶sub _declare_consumer ($base, $target, $definition) {
Subroutine _declare_consumer: called CC=1 SCAR=0.0
718 24 return Linux::Event::_ByteStream::Descriptor::declare_consumer(
719 $base, $target, $definition,
720 );
721 }
722  
723 1018 ▶sub _timeout_value ($target, $name, $value) {
Subroutine _timeout_value: called CC=8 SCAR=20.8
724 1018 ▶ my $seconds = !defined($value) || ref($value) || !looks_like_number($value)
Branch: 1 branch
BranchTrueFalseTotal
!defined($value) || ref $value || !&looks_like_number($value) ? : 2 1016 1018
Condition83%5/6
not defined $value or ref $value or not &looks_like_number($value)
l!l&&r!l&&!r
111016
not defined $value or ref $value
l!l&&r!l&&!r
011017
MC/DC66%2/3
not defined $value or ref $value or not &looks_like_number($value)
not defined $value ref $value not &looks_like_number($value)
Truth table75%3/4
not(A) or B or not(C)
A= not defined $valueB= ref $valueC= not &looks_like_number($value)
ABCresult
1XX1
01X1
0011
0000
725 ? undef : 0 + $value;
726 1018 ▶ croak "$target $name must be a non-negative number of seconds"
Branch: 1 branch
BranchTrueFalseTotal
if not defined $seconds && isfinite($seconds) or $seconds < 0 7 1011 1018
Condition100%6/6
not defined $seconds && isfinite($seconds) or $seconds < 0
l!l&&r!l&&!r
431011
defined $seconds && isfinite($seconds)
!ll&&!rl&&r
221014
MC/DC100%3/3
not defined $seconds && isfinite($seconds) or $seconds < 0
defined $seconds isfinite($seconds) $seconds < 0
Truth table100%4/4
not(A && B) or C
A= defined $secondsB= isfinite($seconds)C= $seconds < 0
ABCresult
0XX1
10X1
1111
1100
727 if !defined($seconds) || !isfinite($seconds) || $seconds < 0;
728 1011 ▶ croak "$target $name exceeds the supported timer range"
Branch: 1 branch
BranchTrueFalseTotal
if $seconds > 2147483647 2 1009 1011
729 if $seconds > 2_147_483_647;
730 1009 return $seconds;
731 }
732  
733 17 ▶sub _deadline_spec ($method, $value) {
Subroutine _deadline_spec: called CC=9 SCAR=22.0
734 17 ▶ croak "$method(): deadline must be a hash reference"
Branch: 1 branch
BranchTrueFalseTotal
if ref $value ne "HASH" 1 16 17
735 if ref($value) ne 'HASH';
736 16 my %option = %$value;
737 16 my $has_after = exists $option{after};
738 16 my $has_at = exists $option{at};
739 16 ▶ croak "$method(): deadline requires exactly one of after or at"
Branch: 1 branch
BranchTrueFalseTotal
if $has_after == $has_at 2 14 16
740 if $has_after == $has_at;
741 14 my $operation = delete $option{operation};
742 14 ▶ croak "$method(): deadline operation must be a non-empty string"
Branch: 1 branch
BranchTrueFalseTotal
if not defined $operation or ref $operation or $operation eq "" 1 13 14
Condition66%4/6
not defined $operation or ref $operation or $operation eq ""
l!l&&r!l&&!r
1013
not defined $operation or ref $operation
l!l&&r!l&&!r
1013
MC/DC33%1/3
not defined $operation or ref $operation or $operation eq ""
not defined $operation ref $operation $operation eq ""
Truth table50%2/4
not(A) or B or C
A= not defined $operationB= ref $operationC= $operation eq ""
ABCresult
1XX1
01X1
0011
0000
743 if !defined($operation) || ref($operation) || $operation eq '';
744 13 ▶ my $name = $has_after ? 'after' : 'at';
Branch: 1 branch
BranchTrueFalseTotal
$has_after ? : 12 1 13
745 my $seconds = _timeout_value("$method(): deadline", $name,
746 13 delete $option{$name});
747 11 ▶ croak "$method(): unknown deadline options: "
Branch: 1 branch
BranchTrueFalseTotal
if %option 1 10 11
748 . join(', ', sort keys %option) if %option;
749 return {
750 10 ▶ absolute => $has_at ? 1 : 0,
Branch: 1 branch
BranchTrueFalseTotal
$has_at ? : 1 9 10
751 seconds => $seconds,
752 operation => "$operation",
753 };
754 }
755  
756 17 ▶sub _xs_framing_error ($self, $message) {
Subroutine _xs_framing_error: called CC=1 SCAR=0.0
757 17 $self->_fail_framing($message);
758 17 return;
759 }
760  
761 62 ▶sub _xs_read_eof ($self) {
Subroutine _xs_read_eof: called CC=1 SCAR=0.0
762 62 $self->_mark_eof;
763 62 return;
764 }
765  
766 0 ▶sub _xs_read_error ($self, $errno) {
Subroutine _xs_read_error: not called CC=1 SCAR=6.9
767 0 local $! = $errno;
768 0 $self->_fail_io('read', $errno);
769 0 return;
770 }
771  
772 1 ▶sub _xs_write_error ($self, $errno) {
Subroutine _xs_write_error: called CC=1 SCAR=0.0
773 1 local $! = $errno;
774 1 $self->_fail_io('write', $errno);
775 1 return;
776 }
777  
778 4 ▶sub _xs_output_limit ($self, $pending_bytes, $limit) {
Subroutine _xs_output_limit: called CC=1 SCAR=0.0
779 4 my $error = Linux::Event::Error->new(
780 type => 'output_limit',
781 operation => 'write',
782 message => "pending output would exceed $limit bytes",
783 pending_bytes => $pending_bytes,
784 limit => $limit,
785 );
786 4 $self->_fail($error);
787 4 return;
788 }
789  
790 17 ▶sub _xs_write_empty ($self) {
Subroutine _xs_write_empty: called CC=7 SCAR=21.2
791 17 ▶ return if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 17 17
792 17 $self->{deadline_write_started} = undef;
793 $self->_rearm_stream_deadline
794 17 ▶ if $self->{deadline_started} && $self->{timeout}{write_timeout} > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"deadline_started"} and $self->{"timeout"}{"write_timeout"} > 0 0 17 17
Condition33%1/3
$self->{"deadline_started"} and $self->{"timeout"}{"write_timeout"} > 0
!ll&&!rl&&r
0170
MC/DC0%0/2
$self->{"deadline_started"} and $self->{"timeout"}{"write_timeout"} > 0
$self->{"deadline_started"} $self->{"timeout"}{"write_timeout"} > 0
Truth table33%1/3
A and B
A= $self->{"deadline_started"}B= $self->{"timeout"}{"write_timeout"} > 0
ABresult
0X0
100
111
795 17 ▶ $self->{write_watcher}->disable_write if $self->{write_watcher};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"write_watcher"} 17 0 17
796 17 ▶ $self->_finish_write_side if $self->{write_ending} && !$self->{write_ended};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"write_ending"} and not $self->{"write_ended"} 6 11 17
Condition66%2/3
$self->{"write_ending"} and not $self->{"write_ended"}
!ll&&!rl&&r
1106
MC/DC50%1/2
$self->{"write_ending"} and not $self->{"write_ended"}
$self->{"write_ending"} not $self->{"write_ended"}
Truth table66%2/3
A and not(B)
A= $self->{"write_ending"}B= not $self->{"write_ended"}
ABresult
0X0
100
111
797 17 return;
798 }
799  
800 12 ▶sub _xs_drain ($self) {
Subroutine _xs_drain: called CC=5 SCAR=17.8
801 12 ▶ return if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 12 12
802 12 ▶ if ($self->{preconnect_write_blocked}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"preconnect_write_blocked"} and not $self->{"transport_ready_fired"} & 2) 0 12 12
Condition66%2/3
$self->{"preconnect_write_blocked"} and not $self->{"transport_ready_fired"} & 2
!ll&&!rl&&r
1110
MC/DC0%0/2
$self->{"preconnect_write_blocked"} and not $self->{"transport_ready_fired"} & 2
$self->{"preconnect_write_blocked"} not $self->{"transport_ready_fired"} & 2
Truth table66%2/3
A and not(B)
A= $self->{"preconnect_write_blocked"}B= not $self->{"transport_ready_fired"} & 2
ABresult
0X0
100
111
803 && !($self->{transport_ready_fired} & 0x02)) {
804 0 $self->{preconnect_drain_reached} = 1;
805 0 return;
806 }
807 12 delete $self->{preconnect_write_blocked};
808 12 delete $self->{preconnect_drain_reached};
809 12 my $callback = $self->{callbacks}{on_drain};
810 12 ▶ $callback->($self) if $callback;
Branch: 1 branch
BranchTrueFalseTotal
if $callback 12 0 12
811 12 return;
812 }
813  
814 28 ▶sub _xs_consumer_paused ($self) {
Subroutine _xs_consumer_paused: called CC=4 SCAR=16.1
815 28 ▶ return if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 28 28
816 $self->{read_watcher}->disable_read
817 28 ▶ if $self->{read_watcher} && $self->{xs_state}->transport_ready;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"read_watcher"} and $self->{"xs_state"}->transport_ready 28 0 28
Condition33%1/3
$self->{"read_watcher"} and $self->{"xs_state"}->transport_ready
!ll&&!rl&&r
0028
MC/DC0%0/2
$self->{"read_watcher"} and $self->{"xs_state"}->transport_ready
$self->{"read_watcher"} $self->{"xs_state"}->transport_ready
Truth table33%1/3
A and B
A= $self->{"read_watcher"}B= $self->{"xs_state"}->transport_ready
ABresult
0X0
100
111
818 28 return;
819 }
820  
821 61 ▶sub _xs_consumer_resumed ($self) {
Subroutine _xs_consumer_resumed: called CC=6 SCAR=19.6
822 61 ▶ return if $self->{closed} || $self->{read_paused} || $self->{read_eof};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or $self->{"read_paused"} or $self->{"read_eof"} 1 60 61
Condition66%4/6
$self->{"closed"} or $self->{"read_paused"} or $self->{"read_eof"}
l!l&&r!l&&!r
1060
$self->{"closed"} or $self->{"read_paused"}
l!l&&r!l&&!r
0160
MC/DC33%1/3
$self->{"closed"} or $self->{"read_paused"} or $self->{"read_eof"}
$self->{"closed"} $self->{"read_paused"} $self->{"read_eof"}
Truth table50%2/4
A or B or C
A= $self->{"closed"}B= $self->{"read_paused"}C= $self->{"read_eof"}
ABCresult
1XX1
01X1
0011
0000
823 $self->{read_watcher}->enable_read
824 60 ▶ if $self->{read_watcher} && !$self->{xs_state}->consumer_paused;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"read_watcher"} and not $self->{"xs_state"}->consumer_paused 60 0 60
Condition33%1/3
$self->{"read_watcher"} and not $self->{"xs_state"}->consumer_paused
!ll&&!rl&&r
0060
MC/DC0%0/2
$self->{"read_watcher"} and not $self->{"xs_state"}->consumer_paused
$self->{"read_watcher"} not $self->{"xs_state"}->consumer_paused
Truth table33%1/3
A and not(B)
A= $self->{"read_watcher"}B= not $self->{"xs_state"}->consumer_paused
ABresult
0X0
100
111
825 60 return;
826 }
827  
828 0 ▶sub _xs_consumer_close ($self) {
Subroutine _xs_consumer_close: not called CC=2 SCAR=17.9
829 0 ▶ $self->close if !$self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"closed"} 0 0 0
830 0 return;
831 }
832  
833 11952 ▶sub _xs_transport_event ($self, $status, $operation, $message) {
Subroutine _xs_transport_event: called CC=26 SCAR=37.9
834 11952 ▶ return if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 11952 11952
835  
836 11952 ▶ if ($status == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status == 2) 11864 88 11952
837 # Transport handshakes and shutdowns must make progress even when the
838 # application-facing consumer is paused.
839 11864 ▶ $self->{read_watcher}->enable_read if $self->{read_watcher};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"read_watcher"} 11864 0 11864
840 11864 return;
841 }
842 88 ▶ if ($status == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status == 3) 0 88 88
843 0 ▶ $self->{write_watcher}->enable_write if $self->{write_watcher};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"write_watcher"} 0 0 0
844 0 return;
845 }
846 88 ▶ if ($status == 5) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status == 5) 3 85 88
847 3 ▶ my $error = Linux::Event::Error->new(
Condition50%2/4
$self->transport_name // "transport"
l!l
30
$message || 'transport error'
l!l
30
MC/DC0%0/1
$self->transport_name // "transport"
$self->transport_name
MC/DC0%0/1
$message || 'transport error'
$message
Truth table50%1/2
A
A= $self->transport_name
Aresult
11
00
Truth table50%1/2
A
A= $message
Aresult
11
00
848 type => $self->transport_name // 'transport',
849 operation => $operation,
850 message => $message || 'transport error',
851 );
852 3 $self->_fail($error);
853 3 return;
854 }
855  
856 85 ▶ if ($self->{xs_state} && $self->{xs_state}->transport_ready
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"xs_state"} and $self->{"xs_state"}->transport_ready and not $self->{"transport_ready_fired"} & 1) 21 64 85
Condition50%3/6
$self->{"xs_state"} and $self->{"xs_state"}->transport_ready and not $self->{"transport_ready_fired"} & 1
!ll&&!rl&&r
06421
$self->{"xs_state"} and $self->{"xs_state"}->transport_ready
!ll&&!rl&&r
0085
MC/DC33%1/3
$self->{"xs_state"} and $self->{"xs_state"}->transport_ready and not $self->{"transport_ready_fired"} & 1
$self->{"xs_state"} $self->{"xs_state"}->transport_ready not $self->{"transport_ready_fired"} & 1
Truth table50%2/4
A and B and not(C)
A= $self->{"xs_state"}B= $self->{"xs_state"}->transport_readyC= not $self->{"transport_ready_fired"} & 1
ABCresult
0XX0
10X0
1100
1111
857 && !($self->{transport_ready_fired} & 0x01)) {
858 21 $self->{transport_ready_fired} |= 0x01;
859 21 $self->_start_stream_deadlines;
860 21 ▶ if ($self->{transport}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"transport"} and $self->{"transport"}->can("_stream_transport_ready")) 20 1 21
Condition66%2/3
$self->{"transport"} and $self->{"transport"}->can("_stream_transport_ready")
!ll&&!rl&&r
1020
MC/DC50%1/2
$self->{"transport"} and $self->{"transport"}->can("_stream_transport_ready")
$self->{"transport"} $self->{"transport"}->can("_stream_transport_ready")
Truth table66%2/3
A and B
A= $self->{"transport"}B= $self->{"transport"}->can("_stream_transport_ready")
ABresult
0X0
100
111
861 && $self->{transport}->can('_stream_transport_ready')) {
862 20 $self->{transport}->_stream_transport_ready($self);
863 }
864 21 ▶ if (($self->{read_paused} || $self->{xs_state}->consumer_paused)
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"read_paused"} || $self->{"xs_state"}->consumer_paused and $self->{"read_watcher"}) 2 19 21
Condition83%5/6
$self->{"read_paused"} || $self->{"xs_state"}->consumer_paused and $self->{"read_watcher"}
!ll&&!rl&&r
1902
$self->{"read_paused"} or $self->{"xs_state"}->consumer_paused
l!l&&r!l&&!r
1119
MC/DC66%2/3
$self->{"read_paused"} || $self->{"xs_state"}->consumer_paused and $self->{"read_watcher"}
$self->{"read_paused"} $self->{"xs_state"}->consumer_paused $self->{"read_watcher"}
Truth table60%3/5
A or B and C
A= $self->{"read_paused"}B= $self->{"xs_state"}->consumer_pausedC= $self->{"read_watcher"}
ABCresult
00X0
1X00
0100
1X11
0111
865 && $self->{read_watcher}) {
866 2 $self->{read_watcher}->disable_read;
867 }
868 21 ▶ if (my $callback = $self->{callbacks}{on_transport_ready}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $callback = $self->{"callbacks"}{"on_transport_ready"}) 14 7 21
869 14 $callback->($self);
870 }
871 21 $self->_fire_ready;
872 }
873 85 ▶ if (($status == 0 || $status == 1) && $self->{write_ending}
Branch: 1 branch
BranchTrueFalseTotal
if ($status == 0 || $status == 1 and $self->{"write_ending"} and not $self->pending_bytes) 0 85 85
Condition44%4/9
$status == 0 || $status == 1 and $self->{"write_ending"} and not $self->pending_bytes
!ll&&!rl&&r
8500
$status == 0 || $status == 1 and $self->{"write_ending"}
!ll&&!rl&&r
0850
$status == 0 or $status == 1
l!l&&r!l&&!r
8320
MC/DC0%0/4
$status == 0 || $status == 1 and $self->{"write_ending"} and not $self->pending_bytes
$status == 0 $status == 1 $self->{"write_ending"} not $self->pending_bytes
Truth table28%2/7
A or B and C and not(D)
A= $status == 0B= $status == 1C= $self->{"write_ending"}D= not $self->pending_bytes
ABCDresult
00XX0
1X0X0
010X0
1X100
01100
1X111
01111
874 && !$self->pending_bytes) {
875 0 $self->_finish_write_side;
876 0 ▶ return if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 0 0
877 }
878 85 ▶ if ($self->{write_watcher} && !$self->pending_bytes
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"write_watcher"} and not $self->pending_bytes and not $self->{"write_ending"}) 83 2 85
Condition66%4/6
$self->{"write_watcher"} and not $self->pending_bytes and not $self->{"write_ending"}
!ll&&!rl&&r
2083
$self->{"write_watcher"} and not $self->pending_bytes
!ll&&!rl&&r
0283
MC/DC33%1/3
$self->{"write_watcher"} and not $self->pending_bytes and not $self->{"write_ending"}
$self->{"write_watcher"} not $self->pending_bytes not $self->{"write_ending"}
Truth table50%2/4
A and not(B) and not(C)
A= $self->{"write_watcher"}B= not $self->pending_bytesC= not $self->{"write_ending"}
ABCresult
0XX0
10X0
1100
1111
879 && !$self->{write_ending}) {
880 83 $self->{write_watcher}->disable_write;
881 }
882 85 return;
883 }
884  
885 40528 ▶sub _watch_read_terminal_xs_cb ($state) {
Subroutine _watch_read_terminal_xs_cb: called CC=2 SCAR=7.2
886 40528 ▶ my $self = $state->object or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = $state->object or return 40528 0 40528
887 40528 $self->_on_read_terminal_ready;
888 }
889  
890 0 ▶sub _watch_write_terminal_xs_cb ($state) {
Subroutine _watch_write_terminal_xs_cb: not called CC=2 SCAR=17.9
891 0 ▶ my $self = $state->object or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = $state->object or return 0 0 0
892 0 $self->_on_write_terminal_ready;
893 }
894  
895 103282 ▶sub _require_read_sink ($descriptor, $instance, $readable, $raw_error,
Subroutine _require_read_sink: called CC=11 SCAR=24.0
896 $framed_error) {
897 103282 ▶ return if !$readable;
Branch: 1 branch
BranchTrueFalseTotal
unless $readable 3 103279 103282
898 103279 ▶ return if $descriptor->{consumer};
Branch: 1 branch
BranchTrueFalseTotal
if $descriptor->{"consumer"} 55 103224 103279
899 103224 ▶ if (!$descriptor->{framer}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($descriptor->{"framer"}) 52766 50458 103224
900 croak $raw_error
901 52766 ▶ if !$instance->{on_data} && !$descriptor->{callbacks}{on_data};
Branch: 1 branch
BranchTrueFalseTotal
unless $instance->{"on_data"} or $descriptor->{"callbacks"}{"on_data"} 2 52764 52766
Condition100%3/3
$instance->{"on_data"} or $descriptor->{"callbacks"}{"on_data"}
l!l&&r!l&&!r
66526982
MC/DC100%2/2
$instance->{"on_data"} or $descriptor->{"callbacks"}{"on_data"}
$instance->{"on_data"} $descriptor->{"callbacks"}{"on_data"}
Truth table100%3/3
A or B
A= $instance->{"on_data"}B= $descriptor->{"callbacks"}{"on_data"}
ABresult
1X1
011
000
902 52764 return;
903 }
904 50458 ▶ if ($descriptor->{options}{message_batch_size}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($descriptor->{'options'}{'message_batch_size'}) { } 20 50438 50458
905 croak $framed_error
906 if !$instance->{on_messages}
907 20 ▶ && !$descriptor->{callbacks}{on_messages};
Branch: 1 branch
BranchTrueFalseTotal
unless $instance->{"on_messages"} or $descriptor->{"callbacks"}{"on_messages"} 1 19 20
Condition100%3/3
$instance->{"on_messages"} or $descriptor->{"callbacks"}{"on_messages"}
l!l&&r!l&&!r
1181
MC/DC100%2/2
$instance->{"on_messages"} or $descriptor->{"callbacks"}{"on_messages"}
$instance->{"on_messages"} $descriptor->{"callbacks"}{"on_messages"}
Truth table100%3/3
A or B
A= $instance->{"on_messages"}B= $descriptor->{"callbacks"}{"on_messages"}
ABresult
1X1
011
000
908 } else {
909 croak $framed_error
910 if !$instance->{on_message}
911 50438 ▶ && !$descriptor->{callbacks}{on_message};
Branch: 1 branch
BranchTrueFalseTotal
unless $instance->{"on_message"} or $descriptor->{"callbacks"}{"on_message"} 3 50435 50438
Condition100%3/3
$instance->{"on_message"} or $descriptor->{"callbacks"}{"on_message"}
l!l&&r!l&&!r
10504253
MC/DC100%2/2
$instance->{"on_message"} or $descriptor->{"callbacks"}{"on_message"}
$instance->{"on_message"} $descriptor->{"callbacks"}{"on_message"}
Truth table100%3/3
A or B
A= $instance->{"on_message"}B= $descriptor->{"callbacks"}{"on_message"}
ABresult
1X1
011
000
912 }
913 50454 return;
914 }
915  
916 103139 ▶sub _prepare_handles ($self) {
Subroutine _prepare_handles: called CC=19 SCAR=31.4
917 103139 my ($read_fh, $write_fh) = @$self{qw(read_fh write_fh)};
918 103139 my %prepared;
919 103139 for my $handle (grep { defined } ($read_fh, $write_fh)) {
920 206254 my $fd = fileno($handle);
921 206254 ▶ next if $prepared{$fd}++;
Branch: 1 branch
BranchTrueFalseTotal
if $prepared{$fd}++ 103109 103145 206254
922 103145 my ($status_flags, $descriptor_flags) = _set_nonblocking($handle);
923 103145 ▶ if (!$self->{owns_handles}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"owns_handles"}) 8 103137 103145
924 8 $self->{borrowed_handle_flags}{$fd} = {
925 fh => $handle,
926 status_flags => $status_flags,
927 descriptor_flags => $descriptor_flags,
928 };
929 }
930 }
931 103139 my $descriptor = $self->{descriptor};
932 103139 ▶ my $read_fd = defined($read_fh) ? fileno($read_fh) : -1;
Branch: 1 branch
BranchTrueFalseTotal
defined $read_fh ? : 103136 3 103139
933 103139 ▶ my $write_fd = defined($write_fh) ? fileno($write_fh) : -1;
Branch: 1 branch
BranchTrueFalseTotal
defined $write_fh ? : 103118 21 103139
934 _require_read_sink(
935 $descriptor,
936 $self->{_input_callback_overrides},
937 103139 $read_fd >= 0,
938 'readable raw Stream requires on_data callback',
939 'readable framed Stream requires on_message or a native consumer',
940 );
941 103135 ▶ if ($read_fd < 0 && $descriptor->{consumer}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($read_fd < 0 and $descriptor->{"consumer"}) 0 103135 103135
Condition66%2/3
$read_fd < 0 and $descriptor->{"consumer"}
!ll&&!rl&&r
10313230
MC/DC0%0/2
$read_fd < 0 and $descriptor->{"consumer"}
$read_fd < 0 $descriptor->{"consumer"}
Truth table66%2/3
A and B
A= $read_fd < 0B= $descriptor->{"consumer"}
ABresult
0X0
100
111
942 0 croak 'native Stream consumer requires a readable side';
943 }
944 my $xs_state = Linux::Event::_ByteStream::State->_new_validated(
945 $self,
946 $read_fd,
947 $write_fd,
948 $descriptor->{native},
949 $self->{_input_callbacks}{on_data}
950 // $self->{_input_callbacks}{on_message}
951 // $self->{_input_callbacks}{on_messages},
952 $self->{callback_overrides}{on_drain}
953 103135 ▶ ? \&Linux::Event::_ByteStream::_xs_drain : undef,
Branch: 1 branch
BranchTrueFalseTotal
$self->{'callback_overrides'}{'on_drain'} ? : 1 103134 103135
Condition100%6/6
($self->{"_input_callbacks"}{"on_data"} // $self->{"_input_callbacks"}{"on_message"}) // $self->{"_input_callbacks"}{"on_messages"}
l!l&&r!l&&!r
741103060
$self->{"_input_callbacks"}{"on_data"} // $self->{"_input_callbacks"}{"on_message"}
l!l&&r!l&&!r
659103061
MC/DC100%3/3
($self->{"_input_callbacks"}{"on_data"} // $self->{"_input_callbacks"}{"on_message"}) // $self->{"_input_callbacks"}{"on_messages"}
$self->{"_input_callbacks"}{"on_data"} $self->{"_input_callbacks"}{"on_message"} $self->{"_input_callbacks"}{"on_messages"}
Truth table100%4/4
A // B // C
A= $self->{"_input_callbacks"}{"on_data"}B= $self->{"_input_callbacks"}{"on_message"}C= $self->{"_input_callbacks"}{"on_messages"}
ABCresult
1XX1
01X1
0011
0000
954 );
955 103133 $self->{xs_state} = $xs_state;
956 103133 delete $self->{_input_callbacks};
957  
958 103133 my $initial_interest = 0x01;
959 103133 my $transport = $self->{transport};
960 103133 ▶ if (defined $transport) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $transport) 25 103108 103133
961 25 ▶ croak 'new(): a native transport requires one shared read/write fh'
Branch: 1 branch
BranchTrueFalseTotal
if not defined $read_fh && defined $write_fh or fileno $read_fh != fileno $write_fh 0 25 25
Condition33%2/6
not defined $read_fh && defined $write_fh or fileno $read_fh != fileno $write_fh
l!l&&r!l&&!r
0025
defined $read_fh && defined $write_fh
!ll&&!rl&&r
0025
MC/DC0%0/3
not defined $read_fh && defined $write_fh or fileno $read_fh != fileno $write_fh
defined $read_fh defined $write_fh fileno $read_fh != fileno $write_fh
Truth table25%1/4
not(A && B) or C
A= defined $read_fhB= defined $write_fhC= fileno $read_fh != fileno $write_fh
ABCresult
0XX1
10X1
1111
1100
962 if !defined($read_fh) || !defined($write_fh)
963 || fileno($read_fh) != fileno($write_fh);
964 25 my @binding;
965 25 my $attached = eval {
966 25 @binding = $transport->_stream_transport_bind(fileno($read_fh));
967 25 $xs_state->_attach_transport(
968 $transport, @binding[0, 1, 2],
969 );
970 25 1;
971 };
972 25 ▶ if (!$attached) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($attached) 0 25 25
973 0 ▶ my $error = $@ || 'transport attachment failed';
Condition0%0/2
$@ || 'transport attachment failed'
l!l
00
MC/DC0%0/1
$@ || 'transport attachment failed'
$@
Truth table0%0/2
A
A= $@
Aresult
11
00
974 0 $xs_state->_close;
975 0 $self->{xs_state} = undef;
976 0 $self->_close_handles;
977 0 die $error;
978 }
979 25 ▶ $initial_interest = $binding[3] // 0;
Condition50%1/2
$binding[3] // 0
l!l
250
MC/DC0%0/1
$binding[3] // 0
$binding[3]
Truth table50%1/2
A
A= $binding[3]
Aresult
11
00
980 }
981  
982 103133 ▶ $self->{initial_interest} = $initial_interest
Branch: 1 branch
BranchTrueFalseTotal
if $initial_interest != 1 14 103119 103133
983 if $initial_interest != 0x01;
984 103133 return;
985 }
986  
987 103107 ▶sub _register_handles ($self) {
Subroutine _register_handles: called CC=17 SCAR=28.3
988 103107 my ($read_fh, $write_fh) = @$self{qw(read_fh write_fh)};
989 103107 ▶ my $read_fd = defined($read_fh) ? fileno($read_fh) : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $read_fh ? : 103106 1 103107
990 103107 ▶ my $write_fd = defined($write_fh) ? fileno($write_fh) : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $write_fh ? : 103090 17 103107
991 103107 ▶ my $initial_interest = delete($self->{initial_interest}) // 0x01;
Condition100%2/2
delete $self->{"initial_interest"} // 1
l!l
15103092
MC/DC100%1/1
delete $self->{"initial_interest"} // 1
delete $self->{"initial_interest"}
Truth table100%2/2
A
A= delete $self->{"initial_interest"}
Aresult
11
00
992 103107 my $state = $self->{xs_state};
993  
994 103107 ▶ if (defined($read_fd) && defined($write_fd) && $read_fd == $write_fd) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $read_fd and defined $write_fd and $read_fd == $write_fd) { } 103083 24 103107
Condition100%6/6
defined $read_fd and defined $write_fd and $read_fd == $write_fd
!ll&&!rl&&r
186103083
defined $read_fd and defined $write_fd
!ll&&!rl&&r
117103089
MC/DC100%3/3
defined $read_fd and defined $write_fd and $read_fd == $write_fd
defined $read_fd defined $write_fd $read_fd == $write_fd
Truth table100%4/4
A and B and C
A= defined $read_fdB= defined $write_fdC= $read_fd == $write_fd
ABCresult
0XX0
10X0
1100
1111
995 my $watcher = $self->{loop}->watch_fd(
996 103083 $read_fd, _internal => 1, fh => $read_fh, data => $state,
997 read => \&Linux::Event::_ByteStream::State::_read_ready,
998 write => \&Linux::Event::_ByteStream::State::_write_ready,
999 error => \&_watch_read_terminal_xs_cb,
1000 _callback_data_arg => 1,
1001 );
1002 103081 $self->{read_watcher} = $watcher;
1003 103081 $self->{write_watcher} = $watcher;
1004 103081 ▶ $watcher->disable_write if !($initial_interest & 0x02);
Branch: 1 branch
BranchTrueFalseTotal
unless $initial_interest & 2 103067 14 103081
1005 103081 ▶ $watcher->disable_read if !($initial_interest & 0x01);
Branch: 1 branch
BranchTrueFalseTotal
unless $initial_interest & 1 14 103067 103081
1006 } else {
1007 24 ▶ if (defined $read_fd) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $read_fd) 23 1 24
1008 $self->{read_watcher} = $self->{loop}->watch_fd(
1009 23 $read_fd, _internal => 1, fh => $read_fh, data => $state,
1010 read => \&Linux::Event::_ByteStream::State::_read_ready,
1011 error => \&_watch_read_terminal_xs_cb,
1012 _callback_data_arg => 1,
1013 );
1014 22 ▶ $self->{read_watcher}->disable_read if !($initial_interest & 0x01);
Branch: 1 branch
BranchTrueFalseTotal
unless $initial_interest & 1 0 22 22
1015 }
1016 23 ▶ if (defined $write_fd) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $write_fd) 7 16 23
1017 $self->{write_watcher} = $self->{loop}->watch_fd(
1018 7 $write_fd, _internal => 1, fh => $write_fh, data => $state,
1019 write => \&Linux::Event::_ByteStream::State::_write_ready,
1020 error => \&_watch_write_terminal_xs_cb,
1021 _callback_data_arg => 1,
1022 );
1023 $self->{write_watcher}->disable_write
1024 6 ▶ if !($initial_interest & 0x02);
Branch: 1 branch
BranchTrueFalseTotal
unless $initial_interest & 2 5 1 6
1025 }
1026 }
1027 $self->{read_watcher}->disable_read
1028 if $self->{read_watcher} && ($self->{read_paused}
1029 103103 ▶ || ($state->consumer_paused && $state->transport_ready));
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"read_watcher"} and $self->{"read_paused"} || $state->consumer_paused && $state->transport_ready 45 103058 103103
Condition100%9/9
$self->{"read_watcher"} and $self->{"read_paused"} || $state->consumer_paused && $state->transport_ready
!ll&&!rl&&r
110305745
$self->{"read_paused"} or $state->consumer_paused and $state->transport_ready
l!l&&r!l&&!r
144103057
$state->consumer_paused and $state->transport_ready
!ll&&!rl&&r
103056144
MC/DC100%4/4
$self->{"read_watcher"} and $self->{"read_paused"} || $state->consumer_paused && $state->transport_ready
$self->{"read_watcher"} $self->{"read_paused"} $state->consumer_paused $state->transport_ready
Truth table100%5/5
A and B or C and D
A= $self->{"read_watcher"}B= $self->{"read_paused"}C= $state->consumer_pausedD= $state->transport_ready
ABCDresult
0XXX0
100X0
10100
11XX1
10111
1030 103103 return;
1031 }
1032  
1033 103115 ▶sub _attach_to_loop ($self, $loop) {
Subroutine _attach_to_loop: called CC=16 SCAR=30.1
1034 croak 'add(): Stream is not unattached'
1035 103115 ▶ if $self->{closed} || $self->{loop};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or $self->{"loop"} 1 103114 103115
Condition66%2/3
$self->{"closed"} or $self->{"loop"}
l!l&&r!l&&!r
01103114
MC/DC50%1/2
$self->{"closed"} or $self->{"loop"}
$self->{"closed"} $self->{"loop"}
Truth table66%2/3
A or B
A= $self->{"closed"}B= $self->{"loop"}
ABresult
1X1
011
000
1036 103114 $self->{loop} = $loop;
1037 103114 ▶ if (!defined($self->{read_fh}) && !defined($self->{write_fh})) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $self->{"read_fh"} or defined $self->{"write_fh"}) 1102 102012 103114
Condition100%3/3
defined $self->{"read_fh"} or defined $self->{"write_fh"}
l!l&&r!l&&!r
10201111102
MC/DC100%2/2
defined $self->{"read_fh"} or defined $self->{"write_fh"}
defined $self->{"read_fh"} defined $self->{"write_fh"}
Truth table100%3/3
A or B
A= defined $self->{"read_fh"}B= defined $self->{"write_fh"}
ABresult
1X1
011
000
1038 1102 my $attached = eval { $self->_attach_pending($loop); 1 };
1039 1102 ▶ if (!$attached) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($attached) 0 1102 1102
1040 0 ▶ my $failure = $@ || 'connection attachment failed';
Condition0%0/2
$@ || 'connection attachment failed'
l!l
00
MC/DC0%0/1
$@ || 'connection attachment failed'
$@
Truth table0%0/2
A
A= $@
Aresult
11
00
1041 0 $self->{loop} = undef;
1042 0 die $failure;
1043 }
1044 1102 return $self;
1045 }
1046  
1047 102012 my $saved_interest = $self->{initial_interest};
1048 102012 my $registered = eval { $self->_register_handles; 1 };
1049 102012 ▶ if (!$registered) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($registered) 4 102008 102012
1050 4 ▶ my $failure = $@ || 'Stream registration failed';
Condition50%1/2
$@ || 'Stream registration failed'
l!l
40
MC/DC0%0/1
$@ || 'Stream registration failed'
$@
Truth table50%1/2
A
A= $@
Aresult
11
00
1051 4 $self->_cancel_io_watchers;
1052 4 ▶ $self->{initial_interest} = $saved_interest
Branch: 1 branch
BranchTrueFalseTotal
if defined $saved_interest 0 4 4
1053 if defined $saved_interest;
1054 4 $self->{loop} = undef;
1055 4 die $failure;
1056 }
1057 102008 my $transport = $self->{transport};
1058 102008 ▶ if ($transport && $transport->can('_stream_transport_start')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($transport and $transport->can("_stream_transport_start")) 24 101984 102008
Condition66%2/3
$transport and $transport->can("_stream_transport_start")
!ll&&!rl&&r
101984024
MC/DC50%1/2
$transport and $transport->can("_stream_transport_start")
$transport $transport->can("_stream_transport_start")
Truth table66%2/3
A and B
A= $transportB= $transport->can("_stream_transport_start")
ABresult
0X0
100
111
1059 24 my $started = eval { $transport->_stream_transport_start($self); 1 };
1060 24 ▶ if (!$started) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($started) 0 24 24
1061 0 ▶ my $error = $@ || 'transport startup failed';
Condition0%0/2
$@ || 'transport startup failed'
l!l
00
MC/DC0%0/1
$@ || 'transport startup failed'
$@
Truth table0%0/2
A
A= $@
Aresult
11
00
1062 0 $self->_close_now(1);
1063 0 die $error;
1064 }
1065 }
1066 102008 ▶ $self->_flush_preconnect_output if exists $self->{preconnect_output};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"preconnect_output"} 0 102008 102008
1067 102008 ▶ $self->_start_stream_deadlines if !$transport;
Branch: 1 branch
BranchTrueFalseTotal
unless $transport 101984 24 102008
1068 102008 return $self;
1069 }
1070  
1071 0 ▶sub _attach_pending ($self, $loop) {
Subroutine _attach_pending: not called CC=1 SCAR=6.9
1072 0 croak 'add(): Stream has no filehandle';
1073 }
1074  
1075 8 ▶sub _abort_failed_construction ($self) {
Subroutine _abort_failed_construction: called CC=2 SCAR=6.9
1076 8 my $ignored;
1077 8 $self->{closed} = 1;
1078 8 $self->{loop} = undef;
1079 8 ▶ if (my $xs_state = delete $self->{xs_state}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $xs_state = delete $self->{"xs_state"}) 2 6 8
1080 2 ▶ _teardown_step(\$ignored, sub { $xs_state->_close });
Subroutine __ANON__: called CC=1 SCAR=0.0
1081 }
1082 8 ▶ _teardown_step(\$ignored, sub { $self->_cancel_io_watchers });
Subroutine __ANON__: called CC=1 SCAR=0.0
1083 8 ▶ _teardown_step(\$ignored, sub { $self->_close_handles });
Subroutine __ANON__: called CC=1 SCAR=0.0
1084 8 delete @$self{qw(
1085 callbacks callback_overrides _input_callbacks
1086 _input_callback_overrides
1087 )};
1088 8 return;
1089 }
1090  
1091 2223 ▶sub _fire_ready ($self) {
Subroutine _fire_ready: called CC=8 SCAR=21.1
1092 2223 ▶ return if $self->{closed} || ($self->{transport_ready_fired} & 0x02);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or $self->{"transport_ready_fired"} & 2 1 2222 2223
Condition66%2/3
$self->{"closed"} or $self->{"transport_ready_fired"} & 2
l!l&&r!l&&!r
102222
MC/DC50%1/2
$self->{"closed"} or $self->{"transport_ready_fired"} & 2
$self->{"closed"} $self->{"transport_ready_fired"} & 2
Truth table66%2/3
A or B
A= $self->{"closed"}B= $self->{"transport_ready_fired"} & 2
ABresult
1X1
011
000
1093 2222 $self->{transport_ready_fired} |= 0x02;
1094 2222 ▶ if (my $callback = $self->{callbacks}{on_ready}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $callback = $self->{"callbacks"}{"on_ready"}) 2197 25 2222
1095 2197 $callback->($self);
1096 }
1097 2222 ▶ return if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 2178 44 2222
1098 44 ▶ if ($self->{preconnect_write_blocked}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"preconnect_write_blocked"} and $self->{"preconnect_drain_reached"} || !$self->{"xs_state"}->is_write_blocked) 1 43 44
Condition50%3/6
$self->{"preconnect_write_blocked"} and $self->{"preconnect_drain_reached"} || !$self->{"xs_state"}->is_write_blocked
!ll&&!rl&&r
4301
$self->{"preconnect_drain_reached"} or not $self->{"xs_state"}->is_write_blocked
l!l&&r!l&&!r
010
MC/DC33%1/3
$self->{"preconnect_write_blocked"} and $self->{"preconnect_drain_reached"} || !$self->{"xs_state"}->is_write_blocked
$self->{"preconnect_write_blocked"} $self->{"preconnect_drain_reached"} not $self->{"xs_state"}->is_write_blocked
Truth table50%2/4
A and B or not(C)
A= $self->{"preconnect_write_blocked"}B= $self->{"preconnect_drain_reached"}C= not $self->{"xs_state"}->is_write_blocked
ABCresult
0XX0
1000
11X1
1011
1099 && ($self->{preconnect_drain_reached}
1100 || !$self->{xs_state}->is_write_blocked)) {
1101 1 $self->_xs_drain;
1102 }
1103 44 return;
1104 }
1105  
1106 48 ▶sub _request_write_ready ($self) {
Subroutine _request_write_ready: called CC=3 SCAR=11.0
1107 48 ▶ if (my $watcher = $self->{write_watcher}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $watcher = $self->{'write_watcher'}) { } 44 4 48
1108 44 $watcher->enable_write;
1109 } else {
1110 $self->{initial_interest}
1111 4 ▶ = ($self->{initial_interest} // 0x01) | 0x02;
Condition50%1/2
$self->{"initial_interest"} // 1
l!l
04
MC/DC0%0/1
$self->{"initial_interest"} // 1
$self->{"initial_interest"}
Truth table50%1/2
A
A= $self->{"initial_interest"}
Aresult
11
00
1112 }
1113 48 return;
1114 }
1115  
1116 1095 ▶sub _flush_preconnect_output ($self) {
Subroutine _flush_preconnect_output: called CC=8 SCAR=23.4
1117 1095 ▶ my $queued = delete $self->{preconnect_output} // [];
Condition50%1/2
delete $self->{"preconnect_output"} // []
l!l
10950
MC/DC0%0/1
delete $self->{"preconnect_output"} // []
delete $self->{"preconnect_output"}
Truth table50%1/2
A
A= delete $self->{"preconnect_output"}
Aresult
11
00
1118 1095 $self->{preconnect_output} = [];
1119 1095 $self->{preconnect_bytes} = 0;
1120 1095 for my $bytes (@$queued) {
1121 5 my $status = $self->{xs_state}->_write($bytes);
1122 5 ▶ $self->_request_write_ready if $status & 0x02;
Branch: 1 branch
BranchTrueFalseTotal
if $status & 2 1 4 5
1123 5 ▶ last if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 5 5
1124 }
1125 1095 ▶ if ($self->{write_ending} && !$self->{closed} && !$self->pending_bytes) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"write_ending"} and not $self->{"closed"} and not $self->pending_bytes) 0 1095 1095
Condition33%2/6
$self->{"write_ending"} and not $self->{"closed"} and not $self->pending_bytes
!ll&&!rl&&r
109500
$self->{"write_ending"} and not $self->{"closed"}
!ll&&!rl&&r
109500
MC/DC0%0/3
$self->{"write_ending"} and not $self->{"closed"} and not $self->pending_bytes
$self->{"write_ending"} not $self->{"closed"} not $self->pending_bytes
Truth table25%1/4
A and not(B) and not(C)
A= $self->{"write_ending"}B= not $self->{"closed"}C= not $self->pending_bytes
ABCresult
0XX0
10X0
1100
1111
1126 0 $self->_finish_write_side;
1127 }
1128 1095 return;
1129 }
1130  
1131 210 ▶sub _deadline_now () {
Subroutine _deadline_now: called CC=1 SCAR=0.0
1132 210 require Linux::Event::Kernel::Timer;
1133 210 return Linux::Event::_ByteStream::_Deadline->now;
1134 }
1135  
1136 103293 ▶sub _needs_activity_tracking ($self) {
Subroutine _needs_activity_tracking: called CC=3 SCAR=11.0
1137 return $self->{timeout}{idle_timeout} > 0
1138 || $self->{timeout}{read_timeout} > 0
1139 103293 ▶ || $self->{timeout}{write_timeout} > 0;
Condition100%6/6
$self->{'timeout'}{'idle_timeout'} > 0 || $self->{'timeout'}{'read_timeout'} > 0 || $self->{'timeout'}{'write_timeout'} > 0
l!l&&r!l&&!r
974103192
$self->{"timeout"}{"idle_timeout"} > 0 or $self->{"timeout"}{"read_timeout"} > 0
l!l&&r!l&&!r
8215103196
MC/DC100%3/3
$self->{'timeout'}{'idle_timeout'} > 0 || $self->{'timeout'}{'read_timeout'} > 0 || $self->{'timeout'}{'write_timeout'} > 0
$self->{"timeout"}{"idle_timeout"} > 0 $self->{"timeout"}{"read_timeout"} > 0 $self->{'timeout'}{'write_timeout'} > 0
Truth table100%4/4
A or B || C
A= $self->{"timeout"}{"idle_timeout"} > 0B= $self->{"timeout"}{"read_timeout"} > 0C= $self->{'timeout'}{'write_timeout'} > 0
ABCresult
1XX1
01X1
0011
0000
1140 }
1141  
1142 103099 ▶sub _start_stream_deadlines ($self) {
Subroutine _start_stream_deadlines: called CC=12 SCAR=25.4
1143 103099 ▶ return if $self->{closed} || $self->{deadline_started};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or $self->{"deadline_started"} 1 103098 103099
Condition66%2/3
$self->{"closed"} or $self->{"deadline_started"}
l!l&&r!l&&!r
01103098
MC/DC50%1/2
$self->{"closed"} or $self->{"deadline_started"}
$self->{"closed"} $self->{"deadline_started"}
Truth table66%2/3
A or B
A= $self->{"closed"}B= $self->{"deadline_started"}
ABresult
1X1
011
000
1144 103098 ▶ return if !$self->{loop} || !$self->{xs_state};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"loop"} and $self->{"xs_state"} 0 103098 103098
Condition33%1/3
$self->{"loop"} and $self->{"xs_state"}
!ll&&!rl&&r
00103098
MC/DC0%0/2
$self->{"loop"} and $self->{"xs_state"}
$self->{"loop"} $self->{"xs_state"}
Truth table33%1/3
A and B
A= $self->{"loop"}B= $self->{"xs_state"}
ABresult
0X0
100
111
1145 103098 $self->{deadline_started} = 1;
1146 return if !$self->_needs_activity_tracking
1147 103098 ▶ && !$self->{initial_deadline};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_needs_activity_tracking or $self->{"initial_deadline"} 103047 51 103098
Condition100%3/3
$self->_needs_activity_tracking or $self->{"initial_deadline"}
l!l&&r!l&&!r
492103047
MC/DC100%2/2
$self->_needs_activity_tracking or $self->{"initial_deadline"}
$self->_needs_activity_tracking $self->{"initial_deadline"}
Truth table100%3/3
A or B
A= $self->_needs_activity_trackingB= $self->{"initial_deadline"}
ABresult
1X1
011
000
1148 51 my $now = _deadline_now();
1149 51 ▶ if ($self->_needs_activity_tracking) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_needs_activity_tracking) 49 2 51
1150 49 $self->{xs_state}->_set_activity_tracking(1);
1151 49 $self->{deadline_tracking} = 1;
1152 }
1153 51 $self->{deadline_read_started} = $now;
1154 51 ▶ $self->{deadline_write_started} = $now if $self->pending_bytes > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->pending_bytes > 0 0 51 51
1155 51 ▶ if (my $spec = delete $self->{initial_deadline}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $spec = delete $self->{"initial_deadline"}) 3 48 51
1156 $self->{operation_deadline_at} = $spec->{absolute}
1157 3 ▶ ? $spec->{seconds} : $now + $spec->{seconds};
Branch: 1 branch
BranchTrueFalseTotal
$spec->{'absolute'} ? : 0 3 3
1158 3 $self->{operation_deadline_name} = $spec->{operation};
1159 $self->{operation_deadline_timeout} = $spec->{absolute}
1160 3 ▶ ? undef : $spec->{seconds};
Branch: 1 branch
BranchTrueFalseTotal
$spec->{'absolute'} ? : 0 3 3
1161 }
1162 51 $self->_rearm_stream_deadline;
1163 51 return;
1164 }
1165  
1166 230 ▶sub _deadline_candidates ($self) {
Subroutine _deadline_candidates: called CC=18 SCAR=29.2
1167 230 my @candidate;
1168 230 ▶ if (defined $self->{operation_deadline_at}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"operation_deadline_at"}) 13 217 230
1169 push @candidate, {
1170 at => $self->{operation_deadline_at},
1171 operation => $self->{operation_deadline_name},
1172 timeout => $self->{operation_deadline_timeout},
1173 13 priority => 0,
1174 };
1175 }
1176  
1177 230 my ($last_read, $last_write);
1178 230 ▶ if ($self->{deadline_tracking} && $self->{xs_state}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"deadline_tracking"} and $self->{"xs_state"}) 77 153 230
Condition66%2/3
$self->{"deadline_tracking"} and $self->{"xs_state"}
!ll&&!rl&&r
153077
MC/DC50%1/2
$self->{"deadline_tracking"} and $self->{"xs_state"}
$self->{"deadline_tracking"} $self->{"xs_state"}
Truth table66%2/3
A and B
A= $self->{"deadline_tracking"}B= $self->{"xs_state"}
ABresult
0X0
100
111
1179 ($last_read, $last_write)
1180 77 = $self->{xs_state}->_activity_snapshot;
1181 }
1182 230 my $idle = $self->{timeout}{idle_timeout};
1183 230 ▶ if ($idle > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($idle > 0) 52 178 230
1184 52 ▶ my $last = $last_read > $last_write ? $last_read : $last_write;
Branch: 1 branch
BranchTrueFalseTotal
$last_read > $last_write ? : 2 50 52
1185 52 push @candidate, {
1186 at => $last + $idle, operation => 'idle', timeout => $idle,
1187 priority => 3,
1188 };
1189 }
1190 230 my $read = $self->{timeout}{read_timeout};
1191 230 ▶ if ($read > 0 && defined($self->{read_fh}) && !$self->{read_paused}
Branch: 1 branch
BranchTrueFalseTotal
if ($read > 0 and defined $self->{"read_fh"} and not $self->{"read_paused"} and not $self->{"read_eof"} and not $self->{"read_closed"}) 17 213 230
Condition83%10/12
$read > 0 and defined $self->{"read_fh"} and not $self->{"read_paused"} and not $self->{"read_eof"} and not $self->{"read_closed"}
!ll&&!rl&&r
213017
$read > 0 and defined $self->{"read_fh"} and not $self->{"read_paused"} and not $self->{"read_eof"}
!ll&&!rl&&r
212117
$read > 0 and defined $self->{"read_fh"} and not $self->{"read_paused"}
!ll&&!rl&&r
208418
$read > 0 and defined $self->{"read_fh"}
!ll&&!rl&&r
208022
MC/DC60%3/5
$read > 0 and defined $self->{"read_fh"} and not $self->{"read_paused"} and not $self->{"read_eof"} and not $self->{"read_closed"}
$read > 0 defined $self->{"read_fh"} not $self->{"read_paused"} not $self->{"read_eof"} not $self->{"read_closed"}
Truth table66%4/6
A and B and not(C) and not(D) and not(E)
A= $read > 0B= defined $self->{"read_fh"}C= not $self->{"read_paused"}D= not $self->{"read_eof"}E= not $self->{"read_closed"}
ABCDEresult
0XXXX0
10XXX0
110XX0
1110X0
111100
111111
1192 && !$self->{read_eof} && !$self->{read_closed}) {
1193 17 my $last = $last_read;
1194 $last = $self->{deadline_read_started}
1195 if defined($self->{deadline_read_started})
1196 17 ▶ && $self->{deadline_read_started} > $last;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"deadline_read_started"} and $self->{"deadline_read_started"} > $last 3 14 17
Condition66%2/3
defined $self->{"deadline_read_started"} and $self->{"deadline_read_started"} > $last
!ll&&!rl&&r
0143
MC/DC50%1/2
defined $self->{"deadline_read_started"} and $self->{"deadline_read_started"} > $last
defined $self->{"deadline_read_started"} $self->{"deadline_read_started"} > $last
Truth table66%2/3
A and B
A= defined $self->{"deadline_read_started"}B= $self->{"deadline_read_started"} > $last
ABresult
0X0
100
111
1197 17 push @candidate, {
1198 at => $last + $read, operation => 'read', timeout => $read,
1199 priority => 2,
1200 };
1201 }
1202 230 my $write = $self->{timeout}{write_timeout};
1203 230 ▶ if ($write > 0 && !$self->{write_ended} && $self->pending_bytes > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($write > 0 and not $self->{"write_ended"} and $self->pending_bytes > 0) 4 226 230
Condition83%5/6
$write > 0 and not $self->{"write_ended"} and $self->pending_bytes > 0
!ll&&!rl&&r
21974
$write > 0 and not $self->{"write_ended"}
!ll&&!rl&&r
219011
MC/DC66%2/3
$write > 0 and not $self->{"write_ended"} and $self->pending_bytes > 0
$write > 0 not $self->{"write_ended"} $self->pending_bytes > 0
Truth table75%3/4
A and not(B) and C
A= $write > 0B= not $self->{"write_ended"}C= $self->pending_bytes > 0
ABCresult
0XX0
10X0
1100
1111
1204 4 my $last = $last_write;
1205 $last = $self->{deadline_write_started}
1206 if defined($self->{deadline_write_started})
1207 4 ▶ && $self->{deadline_write_started} > $last;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"deadline_write_started"} and $self->{"deadline_write_started"} > $last 4 0 4
Condition33%1/3
defined $self->{"deadline_write_started"} and $self->{"deadline_write_started"} > $last
!ll&&!rl&&r
004
MC/DC0%0/2
defined $self->{"deadline_write_started"} and $self->{"deadline_write_started"} > $last
defined $self->{"deadline_write_started"} $self->{"deadline_write_started"} > $last
Truth table33%1/3
A and B
A= defined $self->{"deadline_write_started"}B= $self->{"deadline_write_started"} > $last
ABresult
0X0
100
111
1208 4 push @candidate, {
1209 at => $last + $write, operation => 'write', timeout => $write,
1210 priority => 1,
1211 };
1212 }
1213 230 return @candidate;
1214 }
1215  
1216 213 ▶sub _rearm_stream_deadline ($self) {
Subroutine _rearm_stream_deadline: called CC=8 SCAR=21.2
1217 213 ▶ return if !$self->{deadline_started} || $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if not $self->{"deadline_started"} or $self->{"closed"} 0 213 213
Condition33%1/3
not $self->{"deadline_started"} or $self->{"closed"}
l!l&&r!l&&!r
00213
MC/DC0%0/2
not $self->{"deadline_started"} or $self->{"closed"}
not $self->{"deadline_started"} $self->{"closed"}
Truth table33%1/3
not(A) or B
A= not $self->{"deadline_started"}B= $self->{"closed"}
ABresult
1X1
011
000
1218 my @candidate = sort {
1219 213 $a->{at} <=> $b->{at} || $a->{priority} <=> $b->{priority}
1220 3 ▶ } $self->_deadline_candidates;
Condition33%1/3
$Linux::Event::_ByteStream::a->{'at'} <=> $Linux::Event::_ByteStream::b->{'at'} || $Linux::Event::_ByteStream::a->{'priority'} <=> $Linux::Event::_ByteStream::b->{'priority'}
l!l&&r!l&&!r
300
MC/DC0%0/2
$Linux::Event::_ByteStream::a->{'at'} <=> $Linux::Event::_ByteStream::b->{'at'} || $Linux::Event::_ByteStream::a->{'priority'} <=> $Linux::Event::_ByteStream::b->{'priority'}
$Linux::Event::_ByteStream::a->{'at'} <=> $Linux::Event::_ByteStream::b->{'at'} $Linux::Event::_ByteStream::a->{'priority'} <=> $Linux::Event::_ByteStream::b->{'priority'}
Truth table33%1/3
A || B
A= $Linux::Event::_ByteStream::a->{'at'} <=> $Linux::Event::_ByteStream::b->{'at'}B= $Linux::Event::_ByteStream::a->{'priority'} <=> $Linux::Event::_ByteStream::b->{'priority'}
ABresult
1X1
011
000
1221 213 ▶ if (!@candidate) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@candidate) 147 66 213
1222 147 ▶ if (my $timer = delete $self->{deadline_timer}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $timer = delete $self->{"deadline_timer"}) 4 143 147
1223 4 $timer->cancel;
1224 }
1225 147 return;
1226 }
1227  
1228 66 my $at = $candidate[0]{at};
1229 66 ▶ if (my $timer = $self->{deadline_timer}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $timer = $self->{"deadline_timer"}) 8 58 66
1230 8 ▶ if ($timer->is_active) {
Branch: 1 branch
BranchTrueFalseTotal
if ($timer->is_active) 8 0 8
1231 8 $timer->reschedule(at => $at);
1232 8 return;
1233 }
1234 }
1235  
1236 58 my $state = { stream => $self };
1237 58 weaken($state->{stream});
1238 58 my $timer = Linux::Event::_ByteStream::_Deadline->new(
1239 at => $at, data => $state,
1240 );
1241 58 $self->{deadline_timer} = $timer;
1242 58 $self->{loop}->add($timer);
1243 58 return;
1244 }
1245  
1246 17 ▶sub _stream_deadline_fired ($self, $timer) {
Subroutine _stream_deadline_fired: called CC=5 SCAR=17.4
1247 17 ▶ return if $self->{closed} || $self->{deadline_timer} != $timer;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or $self->{"deadline_timer"} != $timer 0 17 17
Condition33%1/3
$self->{"closed"} or $self->{"deadline_timer"} != $timer
l!l&&r!l&&!r
0017
MC/DC0%0/2
$self->{"closed"} or $self->{"deadline_timer"} != $timer
$self->{"closed"} $self->{"deadline_timer"} != $timer
Truth table33%1/3
A or B
A= $self->{"closed"}B= $self->{"deadline_timer"} != $timer
ABresult
1X1
011
000
1248 17 my $now = _deadline_now();
1249 my @candidate = sort {
1250 17 $a->{at} <=> $b->{at} || $a->{priority} <=> $b->{priority}
1251 0 ▶ } $self->_deadline_candidates;
Condition0%0/3
$Linux::Event::_ByteStream::a->{'at'} <=> $Linux::Event::_ByteStream::b->{'at'} || $Linux::Event::_ByteStream::a->{'priority'} <=> $Linux::Event::_ByteStream::b->{'priority'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Linux::Event::_ByteStream::a->{'at'} <=> $Linux::Event::_ByteStream::b->{'at'} || $Linux::Event::_ByteStream::a->{'priority'} <=> $Linux::Event::_ByteStream::b->{'priority'}
$Linux::Event::_ByteStream::a->{'at'} <=> $Linux::Event::_ByteStream::b->{'at'} $Linux::Event::_ByteStream::a->{'priority'} <=> $Linux::Event::_ByteStream::b->{'priority'}
Truth table0%0/3
A || B
A= $Linux::Event::_ByteStream::a->{'at'} <=> $Linux::Event::_ByteStream::b->{'at'}B= $Linux::Event::_ByteStream::a->{'priority'} <=> $Linux::Event::_ByteStream::b->{'priority'}
ABresult
1X1
011
000
1252 17 my ($expired) = grep { $_->{at} <= $now } @candidate;
1253 17 ▶ if (!$expired) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($expired) 3 14 17
1254 3 $self->_rearm_stream_deadline;
1255 3 return;
1256 }
1257  
1258 14 my $operation = $expired->{operation};
1259 my $error = Linux::Event::Error->new(
1260 type => 'timeout',
1261 operation => $operation,
1262 message => "$operation deadline expired",
1263 timeout => $expired->{timeout},
1264 deadline => $expired->{at},
1265 14 );
1266 14 $self->_fail($error);
1267 14 return;
1268 }
1269  
1270 103131 ▶sub _cancel_stream_deadline ($self) {
Subroutine _cancel_stream_deadline: called CC=4 SCAR=13.9
1271 103131 ▶ if (my $timer = delete $self->{deadline_timer}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $timer = delete $self->{"deadline_timer"}) 53 103078 103131
1272 53 $timer->cancel;
1273 }
1274 103131 ▶ if ($self->{deadline_tracking} && $self->{xs_state}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"deadline_tracking"} and $self->{"xs_state"}) 49 103082 103131
Condition66%2/3
$self->{"deadline_tracking"} and $self->{"xs_state"}
!ll&&!rl&&r
103082049
MC/DC50%1/2
$self->{"deadline_tracking"} and $self->{"xs_state"}
$self->{"deadline_tracking"} $self->{"xs_state"}
Truth table66%2/3
A and B
A= $self->{"deadline_tracking"}B= $self->{"xs_state"}
ABresult
0X0
100
111
1275 49 $self->{xs_state}->_set_activity_tracking(0);
1276 }
1277 103131 $self->{deadline_tracking} = 0;
1278 103131 $self->{deadline_started} = 0;
1279 103131 return;
1280 }
1281  
1282 138 ▶sub _apply_transition_timeouts ($self, $descriptor) {
Subroutine _apply_transition_timeouts: called CC=8 SCAR=20.8
1283 138 for my $name (qw(idle_timeout read_timeout write_timeout)) {
1284 $self->{timeout}{$name} = $descriptor->{options}{$name}
1285 414 ▶ if !exists $self->{timeout_override}{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"timeout_override"}{$name} 413 1 414
1286 }
1287 138 ▶ return if !$self->{deadline_started} || !$self->{xs_state};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"deadline_started"} and $self->{"xs_state"} 3 135 138
Condition66%2/3
$self->{"deadline_started"} and $self->{"xs_state"}
!ll&&!rl&&r
30135
MC/DC50%1/2
$self->{"deadline_started"} and $self->{"xs_state"}
$self->{"deadline_started"} $self->{"xs_state"}
Truth table66%2/3
A and B
A= $self->{"deadline_started"}B= $self->{"xs_state"}
ABresult
0X0
100
111
1288 $self->{xs_state}->_set_activity_tracking(0)
1289 135 ▶ if $self->{deadline_tracking};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"deadline_tracking"} 1 134 135
1290 135 $self->{deadline_tracking} = 0;
1291 135 my $now = _deadline_now();
1292 135 ▶ if ($self->_needs_activity_tracking) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_needs_activity_tracking) 1 134 135
1293 1 $self->{xs_state}->_set_activity_tracking(1);
1294 1 $self->{deadline_tracking} = 1;
1295 }
1296 135 $self->{deadline_read_started} = $now;
1297 135 ▶ $self->{deadline_write_started} = $self->pending_bytes > 0 ? $now : undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->pending_bytes > 0 ? : 2 133 135
1298 135 $self->_rearm_stream_deadline;
1299 135 return;
1300 }
1301  
1302 7 ▶sub _release_read_side ($self) {
Subroutine _release_read_side: called CC=8 SCAR=20.8
1303 7 my $read_watcher = delete $self->{read_watcher};
1304 7 ▶ if ($read_watcher) {
Branch: 1 branch
BranchTrueFalseTotal
if ($read_watcher) 5 2 7
1305 5 ▶ if ($self->{write_watcher}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'write_watcher'} and builtin::refaddr($read_watcher) == builtin::refaddr($self->{'write_watcher'})) { } 1 4 5
Condition100%3/3
$self->{"write_watcher"} and builtin::refaddr($read_watcher) == builtin::refaddr($self->{"write_watcher"})
!ll&&!rl&&r
221
MC/DC100%2/2
$self->{"write_watcher"} and builtin::refaddr($read_watcher) == builtin::refaddr($self->{"write_watcher"})
$self->{"write_watcher"} builtin::refaddr($read_watcher) == builtin::refaddr($self->{"write_watcher"})
Truth table100%3/3
A and B
A= $self->{"write_watcher"}B= builtin::refaddr($read_watcher) == builtin::refaddr($self->{"write_watcher"})
ABresult
0X0
100
111
1306 && refaddr($read_watcher) == refaddr($self->{write_watcher})) {
1307 1 $read_watcher->disable_read;
1308 } else {
1309 4 $read_watcher->cancel;
1310 }
1311 }
1312 7 my $read_fh = $self->{read_fh};
1313 7 ▶ if (defined($read_fh) && (!$self->{write_fh}
Branch: 1 branch
BranchTrueFalseTotal
if (defined $read_fh and !$self->{"write_fh"} || fileno $read_fh != fileno $self->{"write_fh"}) 4 3 7
Condition100%6/6
defined $read_fh and !$self->{"write_fh"} || fileno $read_fh != fileno $self->{"write_fh"}
!ll&&!rl&&r
124
not $self->{"write_fh"} or fileno $read_fh != fileno $self->{"write_fh"}
l!l&&r!l&&!r
222
MC/DC100%3/3
defined $read_fh and !$self->{"write_fh"} || fileno $read_fh != fileno $self->{"write_fh"}
defined $read_fh not $self->{"write_fh"} fileno $read_fh != fileno $self->{"write_fh"}
Truth table100%4/4
A and not(B) or C
A= defined $read_fhB= not $self->{"write_fh"}C= fileno $read_fh != fileno $self->{"write_fh"}
ABCresult
0XX0
1000
11X1
1011
1314 || fileno($read_fh) != fileno($self->{write_fh}))) {
1315 4 ▶ CORE::close($read_fh) if $self->{owns_handles};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"owns_handles"} 4 0 4
1316 4 $self->{read_fh} = undef;
1317 }
1318 7 return;
1319 }
1320  
1321 4 ▶sub _release_write_side ($self) {
Subroutine _release_write_side: called CC=8 SCAR=24.2
1322 4 my $write_watcher = delete $self->{write_watcher};
1323 4 ▶ if ($write_watcher) {
Branch: 1 branch
BranchTrueFalseTotal
if ($write_watcher) 2 2 4
1324 2 ▶ if ($self->{read_watcher}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'read_watcher'} and builtin::refaddr($write_watcher) == builtin::refaddr($self->{'read_watcher'})) { } 1 1 2
Condition66%2/3
$self->{"read_watcher"} and builtin::refaddr($write_watcher) == builtin::refaddr($self->{"read_watcher"})
!ll&&!rl&&r
101
MC/DC50%1/2
$self->{"read_watcher"} and builtin::refaddr($write_watcher) == builtin::refaddr($self->{"read_watcher"})
$self->{"read_watcher"} builtin::refaddr($write_watcher) == builtin::refaddr($self->{"read_watcher"})
Truth table66%2/3
A and B
A= $self->{"read_watcher"}B= builtin::refaddr($write_watcher) == builtin::refaddr($self->{"read_watcher"})
ABresult
0X0
100
111
1325 && refaddr($write_watcher) == refaddr($self->{read_watcher})) {
1326 1 $write_watcher->disable_write;
1327 } else {
1328 1 $write_watcher->cancel;
1329 }
1330 }
1331 4 my $write_fh = $self->{write_fh};
1332 4 ▶ if (defined($write_fh) && (!$self->{read_fh}
Branch: 1 branch
BranchTrueFalseTotal
if (defined $write_fh and !$self->{"read_fh"} || fileno $write_fh != fileno $self->{"read_fh"}) 0 4 4
Condition33%2/6
defined $write_fh and !$self->{"read_fh"} || fileno $write_fh != fileno $self->{"read_fh"}
!ll&&!rl&&r
040
not $self->{"read_fh"} or fileno $write_fh != fileno $self->{"read_fh"}
l!l&&r!l&&!r
004
MC/DC0%0/3
defined $write_fh and !$self->{"read_fh"} || fileno $write_fh != fileno $self->{"read_fh"}
defined $write_fh not $self->{"read_fh"} fileno $write_fh != fileno $self->{"read_fh"}
Truth table25%1/4
A and not(B) or C
A= defined $write_fhB= not $self->{"read_fh"}C= fileno $write_fh != fileno $self->{"read_fh"}
ABCresult
0XX0
1000
11X1
1011
1333 || fileno($write_fh) != fileno($self->{read_fh}))) {
1334 0 ▶ CORE::close($write_fh) if $self->{owns_handles};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"owns_handles"} 0 0 0
1335 0 $self->{write_fh} = undef;
1336 }
1337 4 return;
1338 }
1339  
1340 40528 ▶sub _on_read_terminal_ready ($self) {
Subroutine _on_read_terminal_ready: called CC=5 SCAR=16.8
1341 40528 ▶ return if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 40528 40528
1342 $self->{xs_state}->_read_ready
1343 40528 ▶ if !$self->{read_paused} && !$self->{read_eof} && $self->{xs_state};
Branch: 1 branch
BranchTrueFalseTotal
if not $self->{"read_paused"} || $self->{"read_eof"} and $self->{"xs_state"} 34 40494 40528
Condition66%4/6
not $self->{"read_paused"} || $self->{"read_eof"} and $self->{"xs_state"}
!ll&&!rl&&r
40494034
$self->{'read_paused'} || $self->{'read_eof'}
l!l&&r!l&&!r
04049434
MC/DC33%1/3
not $self->{"read_paused"} || $self->{"read_eof"} and $self->{"xs_state"}
$self->{'read_paused'} $self->{'read_eof'} $self->{"xs_state"}
Truth table50%2/4
not(A || B) and C
A= $self->{'read_paused'}B= $self->{'read_eof'}C= $self->{"xs_state"}
ABCresult
1XX0
01X0
0000
0011
1344 }
1345  
1346 0 ▶sub _on_write_terminal_ready ($self) {
Subroutine _on_write_terminal_ready: not called CC=6 SCAR=37.4
1347 0 ▶ return if $self->{closed} || $self->{write_ended};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or $self->{"write_ended"} 0 0 0
Condition0%0/3
$self->{"closed"} or $self->{"write_ended"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"closed"} or $self->{"write_ended"}
$self->{"closed"} $self->{"write_ended"}
Truth table0%0/3
A or B
A= $self->{"closed"}B= $self->{"write_ended"}
ABresult
1X1
011
000
1348 0 ▶ if ($self->pending_bytes) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->pending_bytes) 0 0 0
1349 0 $self->{xs_state}->_write_ready;
1350 0 ▶ return if $self->{closed} || !$self->pending_bytes;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or not $self->pending_bytes 0 0 0
Condition0%0/3
$self->{"closed"} or not $self->pending_bytes
l!l&&r!l&&!r
000
MC/DC0%0/2
$self->{"closed"} or not $self->pending_bytes
$self->{"closed"} not $self->pending_bytes
Truth table0%0/3
A or not(B)
A= $self->{"closed"}B= not $self->pending_bytes
ABresult
1X1
011
000
1351 }
1352 0 local $! = Errno::EPIPE();
1353 0 $self->_fail_io('write', 0 + $!);
1354 }
1355  
1356 21 ▶sub _finish_write_side ($self) {
Subroutine _finish_write_side: called CC=12 SCAR=25.3
1357 21 ▶ return if $self->{closed} || $self->{write_ended};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or $self->{"write_ended"} 0 21 21
Condition33%1/3
$self->{"closed"} or $self->{"write_ended"}
l!l&&r!l&&!r
0021
MC/DC0%0/2
$self->{"closed"} or $self->{"write_ended"}
$self->{"closed"} $self->{"write_ended"}
Truth table33%1/3
A or B
A= $self->{"closed"}B= $self->{"write_ended"}
ABresult
1X1
011
000
1358 21 ▶ return if $self->pending_bytes > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->pending_bytes > 0 0 21 21
1359  
1360 21 ▶ return if !$self->_finish_transport_write;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_finish_transport_write 1 20 21
1361  
1362 20 $self->{write_ending} = 0;
1363 20 $self->{write_ended} = 1;
1364 20 ▶ if (defined($self->{write_fh}) && (!$self->{read_fh}
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"write_fh"} and !$self->{"read_fh"} || fileno $self->{"write_fh"} != fileno $self->{"read_fh"}) 5 15 20
Condition66%4/6
defined $self->{"write_fh"} and !$self->{"read_fh"} || fileno $self->{"write_fh"} != fileno $self->{"read_fh"}
!ll&&!rl&&r
0155
not $self->{"read_fh"} or fileno $self->{"write_fh"} != fileno $self->{"read_fh"}
l!l&&r!l&&!r
5015
MC/DC33%1/3
defined $self->{"write_fh"} and !$self->{"read_fh"} || fileno $self->{"write_fh"} != fileno $self->{"read_fh"}
defined $self->{"write_fh"} not $self->{"read_fh"} fileno $self->{"write_fh"} != fileno $self->{"read_fh"}
Truth table50%2/4
A and not(B) or C
A= defined $self->{"write_fh"}B= not $self->{"read_fh"}C= fileno $self->{"write_fh"} != fileno $self->{"read_fh"}
ABCresult
0XX0
1000
11X1
1011
1365 || fileno($self->{write_fh}) != fileno($self->{read_fh}))) {
1366 5 my $watcher = delete $self->{write_watcher};
1367 5 ▶ $watcher->cancel if $watcher;
Branch: 1 branch
BranchTrueFalseTotal
if $watcher 3 2 5
1368 5 ▶ CORE::close($self->{write_fh}) if $self->{owns_handles};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"owns_handles"} 4 1 5
1369 5 $self->{write_fh} = undef;
1370 }
1371 20 $self->_clear_transport_deadline;
1372 20 ▶ $self->_close_now(1) if $self->{read_eof} || $self->{read_closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"read_eof"} or $self->{"read_closed"} 7 13 20
Condition100%3/3
$self->{"read_eof"} or $self->{"read_closed"}
l!l&&r!l&&!r
4313
MC/DC100%2/2
$self->{"read_eof"} or $self->{"read_closed"}
$self->{"read_eof"} $self->{"read_closed"}
Truth table100%3/3
A or B
A= $self->{"read_eof"}B= $self->{"read_closed"}
ABresult
1X1
011
000
1373 }
1374  
1375 5 ▶sub _finish_transport_write ($self) { 1 }
Subroutine _finish_transport_write: called CC=1 SCAR=0.0
1376  
1377 25 ▶sub _set_transport_deadline_watcher ($self, $watcher) {
Subroutine _set_transport_deadline_watcher: called CC=2 SCAR=7.1
1378 25 ▶ return if $self->{transport_deadline_watcher};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_deadline_watcher"} 0 25 25
1379 25 $self->{transport_deadline_watcher} = $watcher;
1380 25 return;
1381 }
1382  
1383 27 ▶sub _has_transport_deadline_watcher ($self) {
Subroutine _has_transport_deadline_watcher: called CC=1 SCAR=0.0
1384 27 return !!$self->{transport_deadline_watcher};
1385 }
1386  
1387 40 ▶sub _clear_transport_deadline ($self) {
Subroutine _clear_transport_deadline: called CC=3 SCAR=11.0
1388 40 ▶ if ($self->{transport}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"transport"} and $self->{"transport"}->can("_stream_transport_cancel_deadline")) 22 18 40
Condition66%2/3
$self->{"transport"} and $self->{"transport"}->can("_stream_transport_cancel_deadline")
!ll&&!rl&&r
18022
MC/DC50%1/2
$self->{"transport"} and $self->{"transport"}->can("_stream_transport_cancel_deadline")
$self->{"transport"} $self->{"transport"}->can("_stream_transport_cancel_deadline")
Truth table66%2/3
A and B
A= $self->{"transport"}B= $self->{"transport"}->can("_stream_transport_cancel_deadline")
ABresult
0X0
100
111
1389 && $self->{transport}->can('_stream_transport_cancel_deadline')) {
1390 22 $self->{transport}->_stream_transport_cancel_deadline;
1391 }
1392 40 return;
1393 }
1394  
1395 2636 ▶sub _destroy_transport_deadline ($self) {
Subroutine _destroy_transport_deadline: called CC=4 SCAR=13.9
1396 2636 ▶ if (my $watcher = delete $self->{transport_deadline_watcher}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $watcher = delete $self->{"transport_deadline_watcher"}) 24 2612 2636
1397 24 $watcher->cancel;
1398 }
1399 2636 ▶ if ($self->{transport}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"transport"} and $self->{"transport"}->can("_stream_transport_close_deadline")) 25 2611 2636
Condition100%3/3
$self->{"transport"} and $self->{"transport"}->can("_stream_transport_close_deadline")
!ll&&!rl&&r
2610125
MC/DC100%2/2
$self->{"transport"} and $self->{"transport"}->can("_stream_transport_close_deadline")
$self->{"transport"} $self->{"transport"}->can("_stream_transport_close_deadline")
Truth table100%3/3
A and B
A= $self->{"transport"}B= $self->{"transport"}->can("_stream_transport_close_deadline")
ABresult
0X0
100
111
1400 && $self->{transport}->can('_stream_transport_close_deadline')) {
1401 25 $self->{transport}->_stream_transport_close_deadline;
1402 }
1403 2636 return;
1404 }
1405  
1406 3 ▶sub _transport_deadline_expired ($self, $operation, $message) {
Subroutine _transport_deadline_expired: called CC=3 SCAR=11.4
1407 3 ▶ return if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 3 3
1408 3 ▶ my $error = Linux::Event::Error->new(
Condition50%1/2
$self->transport_name // "transport"
l!l
30
MC/DC0%0/1
$self->transport_name // "transport"
$self->transport_name
Truth table50%1/2
A
A= $self->transport_name
Aresult
11
00
1409 type => $self->transport_name // 'transport',
1410 operation => $operation,
1411 message => $message,
1412 );
1413 3 $self->_fail($error);
1414 3 return;
1415 }
1416  
1417 63 ▶sub _mark_eof ($self) {
Subroutine _mark_eof: called CC=14 SCAR=26.5
1418 63 ▶ return if $self->{read_eof} || $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"read_eof"} or $self->{"closed"} 0 63 63
Condition33%1/3
$self->{"read_eof"} or $self->{"closed"}
l!l&&r!l&&!r
0063
MC/DC0%0/2
$self->{"read_eof"} or $self->{"closed"}
$self->{"read_eof"} $self->{"closed"}
Truth table33%1/3
A or B
A= $self->{"read_eof"}B= $self->{"closed"}
ABresult
1X1
011
000
1419 63 $self->{read_eof} = 1;
1420 63 ▶ if (my $watcher = delete $self->{read_watcher}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $watcher = delete $self->{"read_watcher"}) 62 1 63
1421 62 ▶ if (!$self->{write_watcher}
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{'write_watcher'} or builtin::refaddr($watcher) != builtin::refaddr($self->{'write_watcher'})) { } 5 57 62
Condition100%3/3
not $self->{"write_watcher"} or builtin::refaddr($watcher) != builtin::refaddr($self->{"write_watcher"})
l!l&&r!l&&!r
3257
MC/DC100%2/2
not $self->{"write_watcher"} or builtin::refaddr($watcher) != builtin::refaddr($self->{"write_watcher"})
not $self->{"write_watcher"} builtin::refaddr($watcher) != builtin::refaddr($self->{"write_watcher"})
Truth table100%3/3
not(A) or B
A= not $self->{"write_watcher"}B= builtin::refaddr($watcher) != builtin::refaddr($self->{"write_watcher"})
ABresult
1X1
011
000
1422 || refaddr($watcher) != refaddr($self->{write_watcher})) {
1423 5 $watcher->cancel;
1424 } else {
1425 57 $watcher->disable_read;
1426 }
1427 }
1428 63 ▶ if (defined($self->{read_fh}) && (!$self->{write_fh}
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"read_fh"} and !$self->{"write_fh"} || fileno $self->{"read_fh"} != fileno $self->{"write_fh"}) 6 57 63
Condition83%5/6
defined $self->{"read_fh"} and !$self->{"write_fh"} || fileno $self->{"read_fh"} != fileno $self->{"write_fh"}
!ll&&!rl&&r
0576
not $self->{"write_fh"} or fileno $self->{"read_fh"} != fileno $self->{"write_fh"}
l!l&&r!l&&!r
4257
MC/DC66%2/3
defined $self->{"read_fh"} and !$self->{"write_fh"} || fileno $self->{"read_fh"} != fileno $self->{"write_fh"}
defined $self->{"read_fh"} not $self->{"write_fh"} fileno $self->{"read_fh"} != fileno $self->{"write_fh"}
Truth table75%3/4
A and not(B) or C
A= defined $self->{"read_fh"}B= not $self->{"write_fh"}C= fileno $self->{"read_fh"} != fileno $self->{"write_fh"}
ABCresult
0XX0
1000
11X1
1011
1429 || fileno($self->{read_fh}) != fileno($self->{write_fh}))) {
1430 6 ▶ CORE::close($self->{read_fh}) if $self->{owns_handles};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"owns_handles"} 5 1 6
1431 6 $self->{read_fh} = undef;
1432 }
1433 $self->_rearm_stream_deadline
1434 63 ▶ if $self->{deadline_started} && $self->{timeout}{read_timeout} > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"deadline_started"} and $self->{"timeout"}{"read_timeout"} > 0 1 62 63
Condition100%3/3
$self->{"deadline_started"} and $self->{"timeout"}{"read_timeout"} > 0
!ll&&!rl&&r
1611
MC/DC100%2/2
$self->{"deadline_started"} and $self->{"timeout"}{"read_timeout"} > 0
$self->{"deadline_started"} $self->{"timeout"}{"read_timeout"} > 0
Truth table100%3/3
A and B
A= $self->{"deadline_started"}B= $self->{"timeout"}{"read_timeout"} > 0
ABresult
0X0
100
111
1435  
1436 63 ▶ if (my $callback = $self->{callbacks}{on_eof}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $callback = $self->{"callbacks"}{"on_eof"}) 36 27 63
1437 36 $callback->($self);
1438 }
1439 63 ▶ $self->_close_now(1) if $self->{write_ended};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"write_ended"} 8 55 63
1440 }
1441  
1442 1 ▶sub _fail_io ($self, $operation, $errno) {
Subroutine _fail_io: called CC=1 SCAR=0.0
1443 1 local $! = $errno;
1444 1 my $error = Linux::Event::Error->new(
1445 type => 'io',
1446 operation => $operation,
1447 errno => $errno,
1448 message => "$!",
1449 );
1450 1 $self->_fail($error);
1451 }
1452  
1453 17 ▶sub _fail_framing ($self, $message) {
Subroutine _fail_framing: called CC=1 SCAR=0.0
1454 17 my $error = Linux::Event::Error->new(
1455 type => 'framing',
1456 operation => 'frame',
1457 message => $message,
1458 );
1459 17 $self->_fail($error);
1460 }
1461  
1462 48 ▶sub _fail ($self, $error) {
Subroutine _fail: called CC=7 SCAR=20.2
1463 48 ▶ return if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 48 48
1464 48 $self->{last_error} = $error;
1465 48 my $failure;
1466 48 ▶ if (my $callback = $self->{callbacks}{on_error}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $callback = $self->{"callbacks"}{"on_error"}) 48 0 48
1467 48 my $reported = eval { $callback->($self, $error); 1 };
1468 48 ▶ $failure = $@ if !$reported;
Branch: 1 branch
BranchTrueFalseTotal
unless $reported 1 47 48
1469 }
1470 48 my $closed = eval { $self->_close_now(1); 1 };
1471 48 ▶ $failure //= $@ if !$closed;
Branch: 1 branch
BranchTrueFalseTotal
unless $closed 0 48 48
Condition0%0/3
$failure //= $@
l!l&&r!l&&!r
000
MC/DC0%0/2
$failure //= $@
$failure $@
Truth table0%0/3
A //= B
A= $failureB= $@
ABresult
1X1
011
000
1472 48 ▶ die $failure if defined $failure;
Branch: 1 branch
BranchTrueFalseTotal
if defined $failure 1 47 48
1473 47 return;
1474 }
1475  
1476 2654 ▶sub _close_now ($self, $close_fh) {
Subroutine _close_now: called CC=8 SCAR=20.9
1477 2654 ▶ return if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 18 2636 2654
1478 2636 $self->{closed} = 1;
1479 2636 my $failure;
1480 2636 ▶ _teardown_step(\$failure, sub { $self->_cancel_pending });
Subroutine __ANON__: called CC=1 SCAR=0.0
1481 2636 $self->{preconnect_output} = [];
1482 2636 $self->{preconnect_bytes} = 0;
1483 2636 delete $self->{preconnect_write_blocked};
1484 2636 delete $self->{preconnect_drain_reached};
1485 2636 ▶ _teardown_step(\$failure, sub { $self->_cancel_stream_deadline });
Subroutine __ANON__: called CC=1 SCAR=0.0
1486 2636 ▶ _teardown_step(\$failure, sub { $self->_destroy_transport_deadline });
Subroutine __ANON__: called CC=1 SCAR=0.0
1487  
1488 2636 ▶ if (my $xs_state = delete $self->{xs_state}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $xs_state = delete $self->{"xs_state"}) 2625 11 2636
1489 2625 ▶ _teardown_step(\$failure, sub { $xs_state->_close(4) });
Subroutine __ANON__: called CC=1 SCAR=0.0
1490 }
1491 2636 ▶ _teardown_step(\$failure, sub { $self->_cancel_io_watchers });
Subroutine __ANON__: called CC=1 SCAR=0.0
1492 2636 ▶ _teardown_step(\$failure, sub { $self->_close_handles }) if $close_fh;
Subroutine __ANON__: called CC=1 SCAR=0.2
Branch: 1 branch
BranchTrueFalseTotal
if $close_fh 2636 0 2636
1493  
1494 2636 ▶ if (!$self->{detached} && !$self->{close_fired}++) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"detached"} or $self->{"close_fired"}++) 2636 0 2636
Condition33%1/3
$self->{"detached"} or $self->{"close_fired"}++
l!l&&r!l&&!r
002636
MC/DC0%0/2
$self->{"detached"} or $self->{"close_fired"}++
$self->{"detached"} $self->{"close_fired"}++
Truth table33%1/3
A or B
A= $self->{"detached"}B= $self->{"close_fired"}++
ABresult
1X1
011
000
1495 2636 ▶ if (my $callback = $self->{callbacks}{on_close}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $callback = $self->{"callbacks"}{"on_close"}) 50 2586 2636
1496 50 ▶ _teardown_step(\$failure, sub { $callback->($self) });
Subroutine __ANON__: called CC=1 SCAR=0.0
1497 }
1498 }
1499 2636 delete @$self{qw(
1500 callbacks callback_overrides _input_callbacks
1501 _input_callback_overrides
1502 )};
1503 2636 ▶ die $failure if defined $failure;
Branch: 1 branch
BranchTrueFalseTotal
if defined $failure 4 2632 2636
1504 2632 return;
1505 }
1506  
1507 317388 ▶sub _teardown_step ($failure, $callback) {
Subroutine _teardown_step: called CC=4 SCAR=14.0
1508 317388 my $completed = eval { $callback->(); 1 };
1509 317388 ▶ if (!$completed && !defined $$failure) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($completed or defined $$failure) 8 317380 317388
Condition66%2/3
$completed or defined $$failure
l!l&&r!l&&!r
31738008
MC/DC50%1/2
$completed or defined $$failure
$completed defined $$failure
Truth table66%2/3
A or B
A= $completedB= defined $$failure
ABresult
1X1
011
000
1510 8 ▶ $$failure = $@ || "Stream teardown step failed\n";
Condition50%1/2
$@ || "Stream teardown step failed\n"
l!l
80
MC/DC0%0/1
$@ || "Stream teardown step failed\n"
$@
Truth table50%1/2
A
A= $@
Aresult
11
00
1511 }
1512 317388 return;
1513 }
1514  
1515 46 ▶sub _cancel_pending ($self) { return }
Subroutine _cancel_pending: called CC=1 SCAR=0.0
1516  
1517 103146 ▶sub _cancel_io_watchers ($self) {
Subroutine _cancel_io_watchers: called CC=5 SCAR=16.1
1518 103146 my $read = delete $self->{read_watcher};
1519 103146 my $write = delete $self->{write_watcher};
1520 103146 ▶ $read->cancel if $read;
Branch: 1 branch
BranchTrueFalseTotal
if $read 103029 117 103146
1521 103146 ▶ $write->cancel if $write && (!$read || refaddr($write) != refaddr($read));
Branch: 1 branch
BranchTrueFalseTotal
if $write and !$read || builtin::refaddr($write) != builtin::refaddr($read) 59 103087 103146
Condition100%6/6
$write and !$read || builtin::refaddr($write) != builtin::refaddr($read)
!ll&&!rl&&r
7210301559
not $read or builtin::refaddr($write) != builtin::refaddr($read)
l!l&&r!l&&!r
581103015
MC/DC100%3/3
$write and !$read || builtin::refaddr($write) != builtin::refaddr($read)
$write not $read builtin::refaddr($write) != builtin::refaddr($read)
Truth table100%4/4
A and not(B) or C
A= $writeB= not $readC= builtin::refaddr($write) != builtin::refaddr($read)
ABCresult
0XX0
1000
11X1
1011
1522 103146 return;
1523 }
1524  
1525 8 ▶sub _restore_borrowed_handles ($self) {
Subroutine _restore_borrowed_handles: called CC=12 SCAR=30.2
1526 8 ▶ return if $self->{owns_handles};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"owns_handles"} 0 8 8
1527 8 ▶ my $saved = delete $self->{borrowed_handle_flags} // {};
Condition50%1/2
delete $self->{"borrowed_handle_flags"} // {}
l!l
80
MC/DC0%0/1
delete $self->{"borrowed_handle_flags"} // {}
delete $self->{"borrowed_handle_flags"}
Truth table50%1/2
A
A= delete $self->{"borrowed_handle_flags"}
Aresult
11
00
1528 8 my $failure;
1529  
1530 0 for my $fd (sort { $a <=> $b } keys %$saved) {
1531 8 my $entry = $saved->{$fd};
1532 8 my $fh = $entry->{fh};
1533 8 ▶ my $current_fd = defined($fh) ? fileno($fh) : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $fh ? : 8 0 8
1534 8 ▶ next if !defined($current_fd) || $current_fd != $fd;
Branch: 1 branch
BranchTrueFalseTotal
if not defined $current_fd or $current_fd != $fd 0 8 8
Condition33%1/3
not defined $current_fd or $current_fd != $fd
l!l&&r!l&&!r
008
MC/DC0%0/2
not defined $current_fd or $current_fd != $fd
not defined $current_fd $current_fd != $fd
Truth table33%1/3
not(A) or B
A= not defined $current_fdB= $current_fd != $fd
ABresult
1X1
011
000
1535  
1536 my $restored_status = fcntl(
1537 $fh, F_SETFL, $entry->{status_flags},
1538 8 );
1539 8 ▶ $failure //= "restore borrowed handle $fd status flags: $!"
Branch: 1 branch
BranchTrueFalseTotal
unless $restored_status 0 8 8
Condition0%0/2
$failure //= "restore borrowed handle $fd status flags: $!"
l!l
00
MC/DC0%0/1
$failure //= "restore borrowed handle $fd status flags: $!"
$failure
Truth table0%0/2
A
A= $failure
Aresult
11
00
1540 if !$restored_status;
1541  
1542 my $restored_descriptor = fcntl(
1543 $fh, F_SETFD, $entry->{descriptor_flags},
1544 8 );
1545 8 ▶ $failure //= "restore borrowed handle $fd descriptor flags: $!"
Branch: 1 branch
BranchTrueFalseTotal
unless $restored_descriptor 0 8 8
Condition0%0/2
$failure //= "restore borrowed handle $fd descriptor flags: $!"
l!l
00
MC/DC0%0/1
$failure //= "restore borrowed handle $fd descriptor flags: $!"
$failure
Truth table0%0/2
A
A= $failure
Aresult
11
00
1546 if !$restored_descriptor;
1547 }
1548  
1549 8 ▶ croak $failure if defined $failure;
Branch: 1 branch
BranchTrueFalseTotal
if defined $failure 0 8 8
1550 8 return;
1551 }
1552  
1553 2648 ▶sub _close_handles ($self) {
Subroutine _close_handles: called CC=10 SCAR=23.0
1554 2648 ▶ if (!$self->{owns_handles}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"owns_handles"}) 7 2641 2648
1555 7 my $failure;
1556 7 my $restored = eval { $self->_restore_borrowed_handles; 1 };
1557 7 ▶ $failure = $@ if !$restored;
Branch: 1 branch
BranchTrueFalseTotal
unless $restored 0 7 7
1558 7 $self->{read_fh} = undef;
1559 7 $self->{write_fh} = undef;
1560 7 ▶ die $failure if defined $failure;
Branch: 1 branch
BranchTrueFalseTotal
if defined $failure 0 7 7
1561 7 return;
1562 }
1563  
1564 2641 my $read = delete $self->{read_fh};
1565 2641 my $write = delete $self->{write_fh};
1566 2641 ▶ my $read_fd = defined($read) ? fileno($read) : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $read ? : 2619 22 2641
1567 2641 ▶ my $write_fd = defined($write) ? fileno($write) : undef;
Branch: 1 branch
BranchTrueFalseTotal
defined $write ? : 2606 35 2641
1568 2641 ▶ CORE::close($read) if defined $read;
Branch: 1 branch
BranchTrueFalseTotal
if defined $read 2619 22 2641
1569 2641 ▶ CORE::close($write) if defined($write)
Branch: 1 branch
BranchTrueFalseTotal
if defined $write and !defined($read_fd) || $write_fd != $read_fd 3 2638 2641
Condition100%6/6
defined $write and !defined($read_fd) || $write_fd != $read_fd
!ll&&!rl&&r
3526033
not defined $read_fd or $write_fd != $read_fd
l!l&&r!l&&!r
212603
MC/DC100%3/3
defined $write and !defined($read_fd) || $write_fd != $read_fd
defined $write not defined $read_fd $write_fd != $read_fd
Truth table100%4/4
A and not(B) or C
A= defined $writeB= not defined $read_fdC= $write_fd != $read_fd
ABCresult
0XX0
1000
11X1
1011
1570 && (!defined($read_fd) || $write_fd != $read_fd);
1571 2641 return;
1572 }
1573  
1574 103145 ▶sub _set_nonblocking ($fh) {
Subroutine _set_nonblocking: called CC=9 SCAR=27.6
1575 103145 my $flags = fcntl($fh, F_GETFL, 0);
1576 103145 ▶ croak "new(): fcntl(F_GETFL): $!" if !defined $flags;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $flags 0 103145 103145
1577  
1578 103145 my $changed_status = !($flags & O_NONBLOCK);
1579 103145 ▶ if ($changed_status) {
Branch: 1 branch
BranchTrueFalseTotal
if ($changed_status) 694 102451 103145
1580 694 ▶ fcntl($fh, F_SETFL, $flags | O_NONBLOCK)
Branch: 1 branch
BranchTrueFalseTotal
fcntl $fh, 4, $flags | 2048 or croak("new(): fcntl(F_SETFL O_NONBLOCK): $!") 694 0 694
1581 or croak "new(): fcntl(F_SETFL O_NONBLOCK): $!";
1582 }
1583  
1584 103145 my $descriptor_flags = fcntl($fh, F_GETFD, 0);
1585 103145 ▶ if (!defined $descriptor_flags) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $descriptor_flags) 0 103145 103145
1586 0 my $message = "$!";
1587 0 ▶ fcntl($fh, F_SETFL, $flags) if $changed_status;
Branch: 1 branch
BranchTrueFalseTotal
if $changed_status 0 0 0
1588 0 croak "new(): fcntl(F_GETFD): $message";
1589 }
1590  
1591 103145 ▶ if (!($descriptor_flags & FD_CLOEXEC)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($descriptor_flags & 1) 1 103144 103145
1592 1 ▶ if (!fcntl($fh, F_SETFD, $descriptor_flags | FD_CLOEXEC)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (fcntl $fh, 2, $descriptor_flags | 1) 0 1 1
1593 0 my $message = "$!";
1594 0 ▶ fcntl($fh, F_SETFL, $flags) if $changed_status;
Branch: 1 branch
BranchTrueFalseTotal
if $changed_status 0 0 0
1595 0 croak "new(): fcntl(F_SETFD FD_CLOEXEC): $message";
1596 }
1597 }
1598  
1599 103145 return ($flags, $descriptor_flags);
1600 }
1601  
1602 127 1;
1603  
1604 package Linux::Event::_ByteStream::Descriptor::Native;
1605 312 ▶sub new ($class, $spec) {
Subroutine new: called CC=1 SCAR=0.0
1606 312 return $class->_new_validated(
1607 Linux::Event::_ByteStream::Descriptor::_validate_native_spec($spec),
1608 );
1609 }
1610 0 ▶sub CLONE_SKIP ($class) { 1 }
Subroutine CLONE_SKIP: not called CC=1 SCAR=6.9
1611  
1612 package Linux::Event::_ByteStream::State;
1613 127 my @STAT_NAME = qw(
1614 activity_clock_calls read_ready_calls read_calls bytes_read
1615 read_eagain_count read_eintr_count eof_count read_error_count
1616 delivery_calls read_batch_flushes read_batch_peak_bytes input_appends
1617 input_compactions input_peak_bytes delimiter_searches frames_emitted
1618 message_callback_calls message_batch_calls message_batch_peak_messages
1619 message_batch_peak_bytes framing_error_count transition_count
1620 consumer_message_calls consumer_input_calls consumer_pause_count
1621 consumer_resume_count
1622 consumer_event_calls consumer_flush_calls write_submit_calls
1623 write_ready_calls write_calls writev_calls bytes_written
1624 write_eagain_count write_eintr_count write_error_count output_limit_count
1625 queued_segments queue_peak_bytes drain_calls empty_calls read_budget_bytes
1626 read_batch_bytes message_batch_size input_buffered_bytes
1627 consumer_flush_pending consumer_paused pending_bytes write_blocked
1628 activity_tracking
1629 );
1630  
1631 110 ▶sub stats ($self) {
Subroutine stats: called CC=2 SCAR=7.0
1632 110 my $values = $self->_stats_snapshot;
1633 110 ▶ Carp::croak 'native Stream stats snapshot has an unexpected field count'
Branch: 1 branch
BranchTrueFalseTotal
if @$values != @STAT_NAME 0 110 110
1634 if @$values != @STAT_NAME;
1635 110 my %stats;
1636 110 @stats{@STAT_NAME} = @$values;
1637 110 return \%stats;
1638 }
1639  
1640 0 ▶sub CLONE_SKIP ($class) { 1 }
Subroutine CLONE_SKIP: not called CC=1 SCAR=6.9
1641  
1642 package Linux::Event::_ByteStream::_Deadline;
1643 127 ▶use parent -norequire, 'Linux::Event::Kernel::Timer';
Subroutine BEGIN: called CC=1 SCAR=0.0
1644  
1645 17 ▶sub on_timer ($timer) {
Subroutine on_timer: called CC=2 SCAR=7.0
1646 17 my $state = $timer->data;
1647 17 my $stream = $state->{stream};
1648 17 ▶ $stream->_stream_deadline_fired($timer) if $stream;
Branch: 1 branch
BranchTrueFalseTotal
if $stream 17 0 17
1649 17 return;
1650 }
1651  
1652 package Linux::Event::_ByteStream;
« blib/lib/Linux/Event/Framer/LengthPrefix.pm ↑ Summary bench/run-connect-microbench.pl »