blib/lib/Linux/Event/Stream.pm

filter: Statementstmt 89.6% 621 / 693 Branchbran 75.1% 353 / 470 Conditioncond 53.2% 180 / 338 MC/DCmcdc 25.6% 49 / 191 Subroutinesub 93.5% 102 / 109 Podpod 95.6% 44 / 46 totaltotal 73.0% 1349 / 1847 CC 362 SCAR 29.6
CC
362
Cov
77%
new
69.2
_finish_write_side
54.9
_xs_transport_event
48.1
CRAP 19.3
« blib/lib/Linux/Event/Process.pm ↑ Summary bench/run-listen-microbench.pl »
1 package Linux::Event::Stream;
2 87 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 87 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 87 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 87 our $VERSION = '0.105';
7  
8 87 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 87 ▶use Fcntl qw(F_GETFD F_GETFL F_SETFD F_SETFL FD_CLOEXEC O_NONBLOCK);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 87 ▶use POSIX qw(isfinite);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 87 ▶use Scalar::Util qw(looks_like_number weaken);
Subroutine BEGIN: called CC=1 SCAR=0.0
12 87 ▶use Socket qw(SOL_SOCKET SO_ERROR);
Subroutine BEGIN: called CC=1 SCAR=0.0
13 87 ▶use utf8 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 87 ▶use Linux::Event::Stream::_Connection ();
Subroutine BEGIN: called CC=1 SCAR=0.0
16 87 ▶use Linux::Event::Stream::_Descriptor ();
Subroutine BEGIN: called CC=1 SCAR=0.0
17 87 ▶use Linux::Event::Error;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 87 ▶use Linux::Event::Address;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 87 ▶use Linux::Event::_SocketConfig ();
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 87 require XSLoader;
22 87 XSLoader::load(__PACKAGE__, $VERSION);
23  
24 90 ▶sub _declare_framer ($base, $target, $definition) {
Subroutine _declare_framer: called CC=1 SCAR=0.0
25 90 return Linux::Event::Stream::_Descriptor::declare_framer(
26 $base, $target, $definition,
27 );
28 }
29  
30 8 ▶sub _declare_tls ($base, $target, $definition) {
Subroutine _declare_tls: called CC=1 SCAR=0.0
31 8 return Linux::Event::Stream::_Descriptor::declare_tls(
32 $base, $target, $definition,
33 );
34 }
35  
36 606 ▶sub _timeout_value ($target, $name, $value) {
Subroutine _timeout_value: called CC=8 SCAR=20.8
37 606 ▶ my $seconds = !defined($value) || ref($value) || !looks_like_number($value)
Branch: 1 branch
BranchTrueFalseTotal
!defined($value) || ref $value || !&looks_like_number($value) ? : 2 604 606
Condition83%5/6
not defined $value or ref $value or not &looks_like_number($value)
l!l&&r!l&&!r
11604
not defined $value or ref $value
l!l&&r!l&&!r
01605
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
38 ? undef : 0 + $value;
39 606 ▶ 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 599 606
Condition100%6/6
not defined $seconds && isfinite($seconds) or $seconds < 0
l!l&&r!l&&!r
43599
defined $seconds && isfinite($seconds)
!ll&&!rl&&r
22602
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
40 if !defined($seconds) || !isfinite($seconds) || $seconds < 0;
41 599 ▶ croak "$target $name exceeds the supported timer range"
Branch: 1 branch
BranchTrueFalseTotal
if $seconds > 2147483647 2 597 599
42 if $seconds > 2_147_483_647;
43 597 return $seconds;
44 }
45  
46 17 ▶sub _deadline_spec ($method, $value) {
Subroutine _deadline_spec: called CC=9 SCAR=22.0
47 17 ▶ croak "$method(): deadline must be a hash reference"
Branch: 1 branch
BranchTrueFalseTotal
if ref $value ne "HASH" 1 16 17
48 if ref($value) ne 'HASH';
49 16 my %option = %$value;
50 16 my $has_after = exists $option{after};
51 16 my $has_at = exists $option{at};
52 16 ▶ croak "$method(): deadline requires exactly one of after or at"
Branch: 1 branch
BranchTrueFalseTotal
if $has_after == $has_at 2 14 16
53 if $has_after == $has_at;
54 14 my $operation = delete $option{operation};
55 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
56 if !defined($operation) || ref($operation) || $operation eq '';
57 13 ▶ my $name = $has_after ? 'after' : 'at';
Branch: 1 branch
BranchTrueFalseTotal
$has_after ? : 12 1 13
58 my $seconds = _timeout_value("$method(): deadline", $name,
59 13 delete $option{$name});
60 11 ▶ croak "$method(): unknown deadline options: "
Branch: 1 branch
BranchTrueFalseTotal
if %option 1 10 11
61 . join(', ', sort keys %option) if %option;
62 return {
63 10 ▶ absolute => $has_at ? 1 : 0,
Branch: 1 branch
BranchTrueFalseTotal
$has_at ? : 1 9 10
64 seconds => $seconds,
65 operation => "$operation",
66 };
67 }
68  
69 15 ▶sub _xs_framing_error ($self, $message) {
Subroutine _xs_framing_error: called CC=1 SCAR=0.0
70 15 $self->_fail_framing($message);
71 15 return;
72 }
73  
74 28 ▶sub _xs_read_eof ($self) {
Subroutine _xs_read_eof: called CC=1 SCAR=0.0
75 28 $self->_mark_eof;
76 28 return;
77 }
78  
79 0 ▶sub _xs_read_error ($self, $errno) {
Subroutine _xs_read_error: not called CC=1 SCAR=6.9
80 0 local $! = $errno;
81 0 $self->_fail_io('read', $errno);
82 0 return;
83 }
84  
85 0 ▶sub _xs_write_error ($self, $errno) {
Subroutine _xs_write_error: not called CC=1 SCAR=6.9
86 0 local $! = $errno;
87 0 $self->_fail_io('write', $errno);
88 0 return;
89 }
90  
91 1 ▶sub _xs_output_limit ($self, $pending_bytes, $limit) {
Subroutine _xs_output_limit: called CC=1 SCAR=0.0
92 1 my $error = Linux::Event::Error->new(
93 type => 'output_limit',
94 operation => 'write',
95 message => "pending output would exceed $limit bytes",
96 pending_bytes => $pending_bytes,
97 limit => $limit,
98 );
99 1 $self->_fail($error);
100 1 return;
101 }
102  
103 11 ▶sub _xs_write_empty ($self) {
Subroutine _xs_write_empty: called CC=7 SCAR=21.2
104 11 ▶ return if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 11 11
105 11 $self->{deadline_write_started} = undef;
106 $self->_rearm_stream_deadline
107 11 ▶ if $self->{deadline_started} && $self->{timeout}{write_timeout} > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"deadline_started"} and $self->{"timeout"}{"write_timeout"} > 0 0 11 11
Condition33%1/3
$self->{"deadline_started"} and $self->{"timeout"}{"write_timeout"} > 0
!ll&&!rl&&r
0110
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
108 11 ▶ $self->{watcher}->disable_write if $self->{watcher};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"watcher"} 11 0 11
109 11 ▶ $self->_finish_write_side if $self->{write_ending} && !$self->{write_ended};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"write_ending"} and not $self->{"write_ended"} 1 10 11
Condition66%2/3
$self->{"write_ending"} and not $self->{"write_ended"}
!ll&&!rl&&r
1001
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
110 11 return;
111 }
112  
113 4 ▶sub _xs_drain ($self) {
Subroutine _xs_drain: called CC=5 SCAR=17.8
114 4 ▶ return if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 4 4
115 4 ▶ if ($self->{preconnect_write_blocked}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"preconnect_write_blocked"} and not $self->{"transport_ready_fired"} & 2) 0 4 4
Condition66%2/3
$self->{"preconnect_write_blocked"} and not $self->{"transport_ready_fired"} & 2
!ll&&!rl&&r
310
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
116 && !($self->{transport_ready_fired} & 0x02)) {
117 0 $self->{preconnect_drain_reached} = 1;
118 0 return;
119 }
120 4 delete $self->{preconnect_write_blocked};
121 4 delete $self->{preconnect_drain_reached};
122 4 my $callback = $self->{descriptor}{callbacks}{on_drain};
123 4 ▶ $callback->($self) if $callback;
Branch: 1 branch
BranchTrueFalseTotal
if $callback 4 0 4
124 4 return;
125 }
126  
127 11696 ▶sub _xs_transport_event ($self, $status, $operation, $message) {
Subroutine _xs_transport_event: called CC=25 SCAR=38.7
128 11696 ▶ return if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 11696 11696
129  
130 11696 ▶ if ($status == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status == 2) 11623 73 11696
131 11623 ▶ $self->{watcher}->enable_read if $self->{watcher};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"watcher"} 11623 0 11623
132 11623 return;
133 }
134 73 ▶ if ($status == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status == 3) 0 73 73
135 0 ▶ $self->{watcher}->enable_write if $self->{watcher};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"watcher"} 0 0 0
136 0 return;
137 }
138 73 ▶ if ($status == 5) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status == 5) 3 70 73
139 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
140 type => $self->transport_name // 'transport',
141 operation => $operation,
142 message => $message || 'transport error',
143 );
144 3 $self->_fail($error);
145 3 return;
146 }
147  
148 70 ▶ 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) 16 54 70
Condition50%3/6
$self->{"xs_state"} and $self->{"xs_state"}->transport_ready and not $self->{"transport_ready_fired"} & 1
!ll&&!rl&&r
05416
$self->{"xs_state"} and $self->{"xs_state"}->transport_ready
!ll&&!rl&&r
0070
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
149 && !($self->{transport_ready_fired} & 0x01)) {
150 16 $self->{transport_ready_fired} |= 0x01;
151 16 $self->_start_stream_deadlines;
152 16 ▶ if ($self->{transport}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"transport"} and $self->{"transport"}->can("_stream_transport_ready")) 16 0 16
Condition33%1/3
$self->{"transport"} and $self->{"transport"}->can("_stream_transport_ready")
!ll&&!rl&&r
0016
MC/DC0%0/2
$self->{"transport"} and $self->{"transport"}->can("_stream_transport_ready")
$self->{"transport"} $self->{"transport"}->can("_stream_transport_ready")
Truth table33%1/3
A and B
A= $self->{"transport"}B= $self->{"transport"}->can("_stream_transport_ready")
ABresult
0X0
100
111
153 && $self->{transport}->can('_stream_transport_ready')) {
154 16 $self->{transport}->_stream_transport_ready($self);
155 }
156 16 ▶ if ($self->{read_paused} && $self->{watcher}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"read_paused"} and $self->{"watcher"}) 1 15 16
Condition66%2/3
$self->{"read_paused"} and $self->{"watcher"}
!ll&&!rl&&r
1501
MC/DC50%1/2
$self->{"read_paused"} and $self->{"watcher"}
$self->{"read_paused"} $self->{"watcher"}
Truth table66%2/3
A and B
A= $self->{"read_paused"}B= $self->{"watcher"}
ABresult
0X0
100
111
157 1 $self->{watcher}->disable_read;
158 }
159 16 ▶ if (my $callback = $self->{descriptor}{callbacks}{on_transport_ready}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $callback = $self->{"descriptor"}{"callbacks"}{"on_transport_ready"}) 12 4 16
160 12 $callback->($self);
161 }
162 16 $self->_fire_ready;
163 }
164 70 ▶ 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 70 70
Condition44%4/9
$status == 0 || $status == 1 and $self->{"write_ending"} and not $self->pending_bytes
!ll&&!rl&&r
7000
$status == 0 || $status == 1 and $self->{"write_ending"}
!ll&&!rl&&r
0700
$status == 0 or $status == 1
l!l&&r!l&&!r
6820
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
165 && !$self->pending_bytes) {
166 0 $self->_finish_write_side;
167 0 ▶ return if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 0 0
168 }
169 70 ▶ if ($self->{watcher} && !$self->pending_bytes
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"watcher"} and not $self->pending_bytes and not $self->{"write_ending"}) 68 2 70
Condition66%4/6
$self->{"watcher"} and not $self->pending_bytes and not $self->{"write_ending"}
!ll&&!rl&&r
2068
$self->{"watcher"} and not $self->pending_bytes
!ll&&!rl&&r
0268
MC/DC33%1/3
$self->{"watcher"} and not $self->pending_bytes and not $self->{"write_ending"}
$self->{"watcher"} not $self->pending_bytes not $self->{"write_ending"}
Truth table50%2/4
A and not(B) and not(C)
A= $self->{"watcher"}B= not $self->pending_bytesC= not $self->{"write_ending"}
ABCresult
0XX0
10X0
1100
1111
170 && !$self->{write_ending}) {
171 68 $self->{watcher}->disable_write;
172 }
173 70 return;
174 }
175  
176 74686 ▶sub _watch_error_xs_cb ($state) {
Subroutine _watch_error_xs_cb: called CC=2 SCAR=7.2
177 74686 ▶ my $self = $state->stream or return;
Branch: 1 branch
BranchTrueFalseTotal
my $self = $state->stream or return 74686 0 74686
178 74686 $self->_on_terminal_ready;
179 }
180  
181 102882 ▶sub new ($class, %opt) {
Subroutine new: called CC=49 SCAR=42.4
Pod documented
182 102882 ▶ croak 'new(): must be called as a class method' if ref $class;
Branch: 1 branch
BranchTrueFalseTotal
if ref $class 0 102882 102882
183 102882 my $loop = delete $opt{loop};
184 102882 ▶ 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") 1 102881 102882
Condition77%7/9
defined $loop and not ref $loop && $loop->can("add") && $loop->can("watch_fd")
!ll&&!rl&&r
1025793021
ref $loop && $loop->can('add') && $loop->can('watch_fd')
!ll&&!rl&&r
10302
ref $loop and $loop->can("add")
!ll&&!rl&&r
10302
MC/DC50%2/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 table60%3/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
185 if defined($loop) && (!ref($loop) || !$loop->can('add')
186 || !$loop->can('watch_fd'));
187 102881 my $fh = delete $opt{fh};
188 102881 my $connect = delete $opt{_connect};
189 102881 ▶ my $accepted = delete($opt{_accepted}) // 0;
Condition100%2/2
delete $opt{"_accepted"} // 0
l!l
1038101843
MC/DC100%1/1
delete $opt{"_accepted"} // 0
delete $opt{"_accepted"}
Truth table100%2/2
A
A= delete $opt{"_accepted"}
Aresult
11
00
190 102881 my $tls_role = delete $opt{tls_role};
191 102881 my $data = delete $opt{data};
192 102881 my $peer = delete $opt{peer};
193 102881 my $transport = delete $opt{transport};
194 102881 my $socket_override = Linux::Event::_SocketConfig::extract('new', \%opt);
195 102881 my %timeout_override;
196 102881 for my $name (qw(idle_timeout read_timeout write_timeout)) {
197 $timeout_override{$name} = _timeout_value('new():', $name,
198 308637 ▶ delete $opt{$name}) if exists $opt{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opt{$name} 25 308612 308637
199 }
200 my $initial_deadline = exists($opt{deadline})
201 102875 ▶ ? _deadline_spec('new', delete $opt{deadline}) : undef;
Branch: 1 branch
BranchTrueFalseTotal
exists $opt{'deadline'} ? : 12 102863 102875
202 102868 ▶ croak 'new(): unknown options: ' . join(', ', sort keys %opt) if %opt;
Branch: 1 branch
BranchTrueFalseTotal
if %opt 1 102867 102868
203 102867 ▶ croak 'new(): exactly one of fh or an outbound connection is required'
Branch: 1 branch
BranchTrueFalseTotal
if defined $fh == defined $connect 0 102867 102867
204 if defined($fh) == defined($connect);
205 102867 ▶ croak 'new(): fh must be a filehandle'
Branch: 1 branch
BranchTrueFalseTotal
if defined $fh and not defined fileno $fh 0 102867 102867
Condition66%2/3
defined $fh and not defined fileno $fh
!ll&&!rl&&r
10471018200
MC/DC0%0/2
defined $fh and not defined fileno $fh
defined $fh not defined fileno $fh
Truth table66%2/3
A and not(B)
A= defined $fhB= not defined fileno $fh
ABresult
0X0
100
111
206 if defined($fh) && !defined(fileno($fh));
207 102867 ▶ croak 'new(): internal connection options must be a hash reference'
Branch: 1 branch
BranchTrueFalseTotal
if defined $connect and ref $connect ne "HASH" 0 102867 102867
Condition66%2/3
defined $connect and ref $connect ne "HASH"
!ll&&!rl&&r
10182010470
MC/DC0%0/2
defined $connect and ref $connect ne "HASH"
defined $connect ref $connect ne "HASH"
Truth table66%2/3
A and B
A= defined $connectB= ref $connect ne "HASH"
ABresult
0X0
100
111
208 if defined($connect) && ref($connect) ne 'HASH';
209 102867 ▶ croak 'new(): tls_role must be client or server'
Branch: 1 branch
BranchTrueFalseTotal
if defined $tls_role and ref $tls_role || $tls_role ne "client" && $tls_role ne "server" 0 102867 102867
Condition11%1/9
defined $tls_role and ref $tls_role || $tls_role ne "client" && $tls_role ne "server"
!ll&&!rl&&r
10286700
ref $tls_role or $tls_role ne "client" and $tls_role ne "server"
l!l&&r!l&&!r
000
$tls_role ne "client" and $tls_role ne "server"
!ll&&!rl&&r
000
MC/DC0%0/4
defined $tls_role and ref $tls_role || $tls_role ne "client" && $tls_role ne "server"
defined $tls_role ref $tls_role $tls_role ne "client" $tls_role ne "server"
Truth table20%1/5
A and B or C and D
A= defined $tls_roleB= ref $tls_roleC= $tls_role ne "client"D= $tls_role ne "server"
ABCDresult
0XXX0
100X0
10100
11XX1
10111
210 if defined($tls_role)
211 && (ref($tls_role) || ($tls_role ne 'client' && $tls_role ne 'server'));
212 102867 ▶ croak 'new(): tls_role is only valid with fh'
Branch: 1 branch
BranchTrueFalseTotal
if defined $tls_role and not defined $fh 0 102867 102867
Condition33%1/3
defined $tls_role and not defined $fh
!ll&&!rl&&r
10286700
MC/DC0%0/2
defined $tls_role and not defined $fh
defined $tls_role not defined $fh
Truth table33%1/3
A and not(B)
A= defined $tls_roleB= not defined $fh
ABresult
0X0
100
111
213 if defined($tls_role) && !defined($fh);
214 102867 ▶ croak 'new(): internal accepted mode is only valid with fh'
Branch: 1 branch
BranchTrueFalseTotal
if $accepted and not defined $fh 0 102867 102867
Condition66%2/3
$accepted and not defined $fh
!ll&&!rl&&r
10182910380
MC/DC0%0/2
$accepted and not defined $fh
$accepted not defined $fh
Truth table66%2/3
A and not(B)
A= $acceptedB= not defined $fh
ABresult
0X0
100
111
215 if $accepted && !defined($fh);
216 102867 ▶ croak 'new(): tls_role cannot be combined with accepted mode'
Branch: 1 branch
BranchTrueFalseTotal
if $accepted and defined $tls_role 0 102867 102867
Condition66%2/3
$accepted and defined $tls_role
!ll&&!rl&&r
10182910380
MC/DC0%0/2
$accepted and defined $tls_role
$accepted defined $tls_role
Truth table66%2/3
A and B
A= $acceptedB= defined $tls_role
ABresult
0X0
100
111
217 if $accepted && defined($tls_role);
218 102867 ▶ croak 'new(): transport must be an object implementing _stream_transport_bind()'
Branch: 1 branch
BranchTrueFalseTotal
if defined $transport and not ref $transport && $transport->can("_stream_transport_bind") 0 102867 102867
Condition50%3/6
defined $transport and not ref $transport && $transport->can("_stream_transport_bind")
!ll&&!rl&&r
102848190
ref $transport && $transport->can('_stream_transport_bind')
!ll&&!rl&&r
0019
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
219 if defined($transport)
220 && (!ref($transport) || !$transport->can('_stream_transport_bind'));
221  
222 102867 my $descriptor = Linux::Event::Stream::_Descriptor::for_class($class);
223 my %socket_policy = map {
224 102849 $_ => exists($socket_override->{$_})
225 822792 ▶ ? $socket_override->{$_} : $descriptor->{options}{$_}
Branch: 1 branch
BranchTrueFalseTotal
exists $socket_override->{$_} ? : 1 822791 822792
226 } Linux::Event::_SocketConfig::names();
227 102849 ▶ if (my $tls = $descriptor->{tls}) {
Branch: 2 branches
BranchTrueFalseTotal
if (my $tls = $descriptor->{'tls'}) { } 4 102845 102849
elsif (defined $tls_role) { } 0 102845 102845
228 4 ▶ croak 'new(): transport cannot be supplied for a TLS-declared Stream'
Branch: 1 branch
BranchTrueFalseTotal
if defined $transport 0 4 4
229 if defined $transport;
230 4 require Linux::Event::TLS;
231 4 ▶ my $role = defined($connect) ? 'client'
Branch: 2 branches
BranchTrueFalseTotal
defined $connect ? : 2 2 4
$accepted ? : 1 1 2
232 : $accepted ? 'server'
233 : $tls_role;
234 4 ▶ croak 'new(): a TLS-declared adopted fh requires tls_role'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $role 1 3 4
235 if !defined $role;
236 $transport = $role eq 'server'
237 ? Linux::Event::TLS->_server_from_declaration($tls)
238 : Linux::Event::TLS->_client_from_declaration(
239 $tls, defined($connect) ? $connect->{host} : undef,
240 3 ▶ );
Branch: 2 branches
BranchTrueFalseTotal
$role eq 'server' ? : 1 2 3
defined $connect ? : 2 0 2
241 } elsif (defined $tls_role) {
242 0 croak 'new(): tls_role requires a Stream subclass declaring TLS';
243 }
244 my %timeout = map {
245 102848 $_ => exists($timeout_override{$_})
246 308544 ▶ ? $timeout_override{$_} : $descriptor->{options}{$_}
Branch: 1 branch
BranchTrueFalseTotal
exists $timeout_override{$_} ? : 19 308525 308544
247 } qw(idle_timeout read_timeout write_timeout);
248 102848 my $self = bless {
249 descriptor => $descriptor,
250 loop => undef,
251 fh => $fh,
252 watcher => undef,
253 data => $data,
254 transport => $transport,
255 xs_state => undef,
256 read_paused => 0,
257 read_eof => 0,
258 write_ending => 0,
259 write_ended => 0,
260 closed => 0,
261 detached => 0,
262 close_fired => 0,
263 last_error => undef,
264 transport_ready_fired => 0,
265 transport_deadline_watcher => undef,
266 transport_shutdown_started => 0,
267 timeout => \%timeout,
268 timeout_override => \%timeout_override,
269 initial_deadline => $initial_deadline,
270 operation_deadline_at => undef,
271 operation_deadline_name => undef,
272 operation_deadline_timeout => undef,
273 deadline_timer => undef,
274 deadline_started => 0,
275 deadline_tracking => 0,
276 deadline_read_started => undef,
277 deadline_write_started => undef,
278 socket_policy => \%socket_policy,
279 local => undef,
280 }, $class;
281 102848 ▶ $self->{peer} = $peer if defined $peer;
Branch: 1 branch
BranchTrueFalseTotal
if defined $peer 1038 101810 102848
282  
283 102848 ▶ if (defined $fh) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $fh) 101801 1047 102848
284 101801 my $configured = eval {
285 101801 my $local = Linux::Event::Address->new(getsockname($fh));
286 101801 my $family = $local->family_number;
287 Linux::Event::_SocketConfig::apply_policy(
288 $fh, $family, $self->{socket_policy},
289 101801 );
290 101800 ▶ my $role = $accepted ? 'accepted' : 'adopted';
Branch: 1 branch
BranchTrueFalseTotal
$accepted ? : 1038 100762 101800
291 101800 my $address = $peer;
292 101800 ▶ if (!defined($address)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $address) 100762 1038 101800
293 100762 my $packed = eval { getpeername($fh) };
294 100762 ▶ $address = Linux::Event::Address->new($packed)
Branch: 1 branch
BranchTrueFalseTotal
if defined $packed 100762 0 100762
295 if defined $packed;
296 100762 ▶ $self->{peer} = $address if defined $address;
Branch: 1 branch
BranchTrueFalseTotal
if defined $address 100762 0 100762
297 }
298 101800 $self->_configure_socket($fh, $role, $address);
299 101800 $self->{local} = $local;
300 101800 1;
301 };
302 101801 ▶ if (!$configured) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($configured) 1 101800 101801
303 1 ▶ my $error = $@ || 'socket configuration failed';
Condition50%1/2
$@ || 'socket configuration failed'
l!l
10
MC/DC0%0/1
$@ || 'socket configuration failed'
$@
Truth table50%1/2
A
A= $@
Aresult
11
00
304 1 close $fh;
305 1 $self->{fh} = undef;
306 1 die $error;
307 }
308 101800 $self->_prepare_fh($fh);
309 }
310 102847 ▶ if ($connect) {
Branch: 1 branch
BranchTrueFalseTotal
if ($connect) 1047 101800 102847
311 1047 $self->{preconnect_output} = [];
312 1047 $self->{preconnect_bytes} = 0;
313 $self->{connection} = Linux::Event::Stream::_Connection->new(
314 %$connect,
315 stream => $self,
316 socket_policy => $self->{socket_policy},
317 1047 );
318 }
319 102836 ▶ $self->_attach_to_loop($loop) if $loop;
Branch: 1 branch
BranchTrueFalseTotal
if $loop 274 102562 102836
320 102836 return $self;
321 }
322  
323 1048 ▶sub connect ($class, %opt) {
Subroutine connect: called CC=4 SCAR=13.9
Pod documented
324 1048 ▶ croak 'connect(): must be called as a class method' if ref $class;
Branch: 1 branch
BranchTrueFalseTotal
if ref $class 0 1048 1048
325 1048 my %stream;
326 1048 for my $name (qw(loop data transport idle_timeout read_timeout
327 write_timeout deadline tcp_nodelay keepalive keepalive_idle
328 keepalive_interval keepalive_count tcp_user_timeout send_buffer
329 receive_buffer)) {
330 15720 ▶ $stream{$name} = delete $opt{$name} if exists $opt{$name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $opt{$name} 1047 14673 15720
331 }
332 1048 return $class->new(%stream, _connect => \%opt);
333 }
334  
335 0 ▶sub CLONE ($class) {
Subroutine CLONE: not called CC=1 SCAR=6.9
336 0 Linux::Event::Stream::_Descriptor::clear_cache();
337 0 return;
338 }
339  
340 0 ▶sub CLONE_SKIP ($class) { 1 }
Subroutine CLONE_SKIP: not called CC=1 SCAR=6.9
341  
342 39 ▶sub _validate_accepted_configuration ($class) {
Subroutine _validate_accepted_configuration: called CC=2 SCAR=6.9
343 39 my $descriptor = Linux::Event::Stream::_Descriptor::for_class($class);
344 38 ▶ if (my $tls = $descriptor->{tls}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $tls = $descriptor->{"tls"}) 4 34 38
345 4 require Linux::Event::TLS;
346 4 Linux::Event::TLS->_server_from_declaration($tls);
347 }
348 36 return;
349 }
350  
351 102827 ▶sub _prepare_fh ($self, $fh) {
Subroutine _prepare_fh: called CC=6 SCAR=19.6
352 102827 _set_nonblocking($fh);
353 102827 my $descriptor = $self->{descriptor};
354 my $xs_state = Linux::Event::Stream::XSState->new(
355 $self,
356 fileno($fh),
357 $descriptor->{xs},
358 102827 );
359 102827 $self->{xs_state} = $xs_state;
360  
361 102827 my $initial_interest = 0x01;
362 102827 my $transport = $self->{transport};
363 102827 ▶ if (defined $transport) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $transport) 21 102806 102827
364 21 my @binding;
365 21 my $attached = eval {
366 21 @binding = $transport->_stream_transport_bind(fileno($fh));
367 21 $xs_state->_attach_transport(
368 $transport, @binding[0, 1, 2],
369 );
370 21 1;
371 };
372 21 ▶ if (!$attached) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($attached) 0 21 21
373 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
374 0 $xs_state->_close;
375 0 $self->{xs_state} = undef;
376 0 CORE::close($fh);
377 0 $self->{fh} = undef;
378 0 die $error;
379 }
380 21 ▶ $initial_interest = $binding[3] // 0;
Condition50%1/2
$binding[3] // 0
l!l
210
MC/DC0%0/1
$binding[3] // 0
$binding[3]
Truth table50%1/2
A
A= $binding[3]
Aresult
11
00
381 }
382  
383 102827 ▶ $self->{initial_interest} = $initial_interest
Branch: 1 branch
BranchTrueFalseTotal
if $initial_interest != 1 12 102815 102827
384 if $initial_interest != 0x01;
385 102827 return;
386 }
387  
388 102831 ▶sub _configure_socket ($self, $fh, $role, $address) {
Subroutine _configure_socket: called CC=4 SCAR=16.8
389 102831 my $callback = $self->{descriptor}{callbacks}{configure_socket};
390 102831 ▶ return if !$callback;
Branch: 1 branch
BranchTrueFalseTotal
unless $callback 102829 2 102831
391 2 my $ok = eval { $callback->($self, $fh, $role, $address); 1 };
392 2 ▶ return if $ok;
Branch: 1 branch
BranchTrueFalseTotal
if $ok 2 0 2
393 0 my $message = "$@";
394 0 $message =~ s/\s+\z//;
395 0 ▶ $message = 'configure_socket callback failed' if $message eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $message eq "" 0 0 0
396 0 die Linux::Event::Error->new(
397 type => 'socket_configuration',
398 operation => 'configure_socket',
399 message => $message,
400 );
401 }
402  
403 102831 ▶sub _attach_to_loop ($self, $loop) {
Subroutine _attach_to_loop: called CC=17 SCAR=30.3
404 croak 'add(): Stream is not unattached'
405 102831 ▶ if $self->{closed} || $self->{loop};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or $self->{"loop"} 1 102830 102831
Condition66%2/3
$self->{"closed"} or $self->{"loop"}
l!l&&r!l&&!r
01102830
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
406 102830 $self->{loop} = $loop;
407 102830 ▶ if (my $connection = $self->{connection}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $connection = $self->{"connection"}) 1033 101797 102830
408 1033 my $attached = eval { $connection->_attach_to_loop($loop); 1 };
409 1033 ▶ if (!$attached) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($attached) 0 1033 1033
410 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
411 0 $self->{loop} = undef;
412 0 die $failure;
413 }
414 1033 return $self;
415 }
416  
417 101797 ▶ my $initial_interest = delete($self->{initial_interest}) // 0x01;
Condition100%2/2
delete $self->{"initial_interest"} // 1
l!l
12101785
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
418 101797 my $watcher = eval {
419 $loop->watch_fd(
420 fileno($self->{fh}),
421 _internal => 1,
422 fh => $self->{fh},
423 data => $self->{xs_state},
424 101797 read => \&Linux::Event::Stream::XSState::_read_ready,
425 write => \&Linux::Event::Stream::XSState::_write_ready,
426 error => \&_watch_error_xs_cb,
427 _callback_data_arg => 1,
428 );
429 };
430 101797 ▶ if (!$watcher) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($watcher) 1 101796 101797
431 1 ▶ my $failure = $@ || 'Stream registration failed';
Condition50%1/2
$@ || 'Stream registration failed'
l!l
10
MC/DC0%0/1
$@ || 'Stream registration failed'
$@
Truth table50%1/2
A
A= $@
Aresult
11
00
432 1 $self->{loop} = undef;
433 1 $self->{initial_interest} = $initial_interest;
434 1 die $failure;
435 }
436 101796 $self->{watcher} = $watcher;
437 101796 ▶ $watcher->disable_write if !($initial_interest & 0x02);
Branch: 1 branch
BranchTrueFalseTotal
unless $initial_interest & 2 101785 11 101796
438 101796 ▶ $watcher->disable_read if !($initial_interest & 0x01);
Branch: 1 branch
BranchTrueFalseTotal
unless $initial_interest & 1 11 101785 101796
439 101796 my $transport = $self->{transport};
440 101796 ▶ if ($transport && $transport->can('_stream_transport_start')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($transport and $transport->can("_stream_transport_start")) 20 101776 101796
Condition66%2/3
$transport and $transport->can("_stream_transport_start")
!ll&&!rl&&r
101776020
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
441 20 my $started = eval { $transport->_stream_transport_start($self); 1 };
442 20 ▶ if (!$started) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($started) 0 20 20
443 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
444 0 $self->_close_now(1);
445 0 die $error;
446 }
447 }
448 101796 ▶ $self->_flush_preconnect_output if exists $self->{preconnect_output};
Branch: 1 branch
BranchTrueFalseTotal
if exists $self->{"preconnect_output"} 0 101796 101796
449 101796 ▶ $self->_start_stream_deadlines if !$transport;
Branch: 1 branch
BranchTrueFalseTotal
unless $transport 101776 20 101796
450 101796 return $self;
451 }
452  
453 1027 ▶sub _connect_succeeded ($self, $fh) {
Subroutine _connect_succeeded: called CC=15 SCAR=31.5
454 1027 ▶ return if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 1027 1027
455 1027 delete $self->{connection};
456 1027 $self->{fh} = $fh;
457 1027 $self->{local} = Linux::Event::Address->new(getsockname($fh));
458 1027 my $packed_peer = eval { getpeername($fh) };
459 1027 ▶ $self->{peer} = Linux::Event::Address->new($packed_peer)
Branch: 1 branch
BranchTrueFalseTotal
if defined $packed_peer 1027 0 1027
460 if defined $packed_peer;
461 1027 my $prepared = eval { $self->_prepare_fh($fh); 1 };
462 1027 ▶ if (!$prepared) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($prepared) 0 1027 1027
463 0 ▶ my $message = $@ || 'connected Stream setup failed';
Condition0%0/2
$@ || 'connected Stream setup failed'
l!l
00
MC/DC0%0/1
$@ || 'connected Stream setup failed'
$@
Truth table0%0/2
A
A= $@
Aresult
11
00
464 0 my $error = Linux::Event::Error->new(
465 type => 'connect', operation => 'attach', message => $message,
466 );
467 0 $self->_fail($error);
468 0 return;
469 }
470 1027 ▶ my $initial_interest = delete($self->{initial_interest}) // 0x01;
Condition100%2/2
delete $self->{"initial_interest"} // 1
l!l
11026
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
471 1027 my $watcher = eval {
472 $self->{loop}->watch_fd(
473 fileno($self->{fh}),
474 _internal => 1,
475 fh => $self->{fh},
476 data => $self->{xs_state},
477 1027 read => \&Linux::Event::Stream::XSState::_read_ready,
478 write => \&Linux::Event::Stream::XSState::_write_ready,
479 error => \&_watch_error_xs_cb,
480 _callback_data_arg => 1,
481 );
482 };
483 1027 ▶ if (!$watcher) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($watcher) 0 1027 1027
484 0 ▶ my $message = "$@" || 'connected Stream registration failed';
Condition0%0/2
"$@" || 'connected Stream registration failed'
l!l
00
MC/DC0%0/1
"$@" || 'connected Stream registration failed'
"$@"
Truth table0%0/2
A
A= "$@"
Aresult
11
00
485 0 $self->_fail(Linux::Event::Error->new(
486 type => 'setup', operation => 'watch', message => $message,
487 ));
488 0 return;
489 }
490 1027 $self->{watcher} = $watcher;
491 1027 ▶ $watcher->disable_write if !($initial_interest & 0x02);
Branch: 1 branch
BranchTrueFalseTotal
unless $initial_interest & 2 1026 1 1027
492 1027 ▶ $watcher->disable_read if !($initial_interest & 0x01);
Branch: 1 branch
BranchTrueFalseTotal
unless $initial_interest & 1 1 1026 1027
493 1027 my $transport = $self->{transport};
494 1027 ▶ if ($transport && $transport->can('_stream_transport_start')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($transport and $transport->can("_stream_transport_start")) 1 1026 1027
Condition66%2/3
$transport and $transport->can("_stream_transport_start")
!ll&&!rl&&r
102601
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
495 1 my $started = eval { $transport->_stream_transport_start($self); 1 };
496 1 ▶ if (!$started) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($started) 0 1 1
497 0 ▶ my $message = $@ || '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
498 0 my $error = Linux::Event::Error->new(
499 type => 'transport', operation => 'start', message => $message,
500 );
501 0 $self->_fail($error);
502 0 return;
503 }
504 }
505 1027 $self->_flush_preconnect_output;
506 1027 ▶ if (!$self->{transport}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"transport"}) 1026 1 1027
507 1026 $self->_start_stream_deadlines;
508 1026 $self->_fire_ready;
509 }
510 1027 return;
511 }
512  
513 5 ▶sub _connect_failed ($self, $connect_error) {
Subroutine _connect_failed: called CC=2 SCAR=7.0
514 5 ▶ return if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 5 5
515 5 delete $self->{connection};
516 5 $self->_fail($connect_error);
517 4 return;
518 }
519  
520 2077 ▶sub _fire_ready ($self) {
Subroutine _fire_ready: called CC=8 SCAR=21.8
521 2077 ▶ return if $self->{closed} || ($self->{transport_ready_fired} & 0x02);
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or $self->{"transport_ready_fired"} & 2 0 2077 2077
Condition33%1/3
$self->{"closed"} or $self->{"transport_ready_fired"} & 2
l!l&&r!l&&!r
002077
MC/DC0%0/2
$self->{"closed"} or $self->{"transport_ready_fired"} & 2
$self->{"closed"} $self->{"transport_ready_fired"} & 2
Truth table33%1/3
A or B
A= $self->{"closed"}B= $self->{"transport_ready_fired"} & 2
ABresult
1X1
011
000
522 2077 $self->{transport_ready_fired} |= 0x02;
523 2077 ▶ if (my $callback = $self->{descriptor}{callbacks}{on_ready}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $callback = $self->{"descriptor"}{"callbacks"}{"on_ready"}) 2058 19 2077
524 2058 $callback->($self);
525 }
526 2077 ▶ return if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 2042 35 2077
527 35 ▶ 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 34 35
Condition50%3/6
$self->{"preconnect_write_blocked"} and $self->{"preconnect_drain_reached"} || !$self->{"xs_state"}->is_write_blocked
!ll&&!rl&&r
3401
$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
528 && ($self->{preconnect_drain_reached}
529 || !$self->{xs_state}->is_write_blocked)) {
530 1 $self->_xs_drain;
531 }
532 35 return;
533 }
534  
535 1027 ▶sub _flush_preconnect_output ($self) {
Subroutine _flush_preconnect_output: called CC=8 SCAR=23.4
536 1027 ▶ my $queued = delete $self->{preconnect_output} // [];
Condition50%1/2
delete $self->{"preconnect_output"} // []
l!l
10270
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
537 1027 $self->{preconnect_output} = [];
538 1027 $self->{preconnect_bytes} = 0;
539 1027 for my $bytes (@$queued) {
540 5 my $status = $self->{xs_state}->_write($bytes);
541 5 ▶ $self->{watcher}->enable_write if $status & 0x02;
Branch: 1 branch
BranchTrueFalseTotal
if $status & 2 1 4 5
542 5 ▶ last if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 5 5
543 }
544 1027 ▶ 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 1027 1027
Condition33%2/6
$self->{"write_ending"} and not $self->{"closed"} and not $self->pending_bytes
!ll&&!rl&&r
102700
$self->{"write_ending"} and not $self->{"closed"}
!ll&&!rl&&r
102700
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
545 0 $self->_finish_write_side;
546 }
547 1027 return;
548 }
549  
550 1032 ▶sub fh ($self) { $self->{fh} }
Subroutine fh: called CC=1 SCAR=0.0
Pod undocumented
551 58 ▶sub loop ($self) { $self->{loop} }
Subroutine loop: called CC=1 SCAR=0.0
Pod documented
552 6 ▶sub peer ($self) { $self->{peer} }
Subroutine peer: called CC=1 SCAR=0.0
Pod documented
553 7 ▶sub local ($self) { $self->{local} }
Subroutine local: called CC=1 SCAR=0.0
Pod documented
554 18 ▶sub state ($self) {
Subroutine state: called CC=6 SCAR=18.0
Pod documented
555 18 ▶ return 'detached' if $self->{closed} && $self->{detached};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} and $self->{"detached"} 0 18 18
Condition66%2/3
$self->{"closed"} and $self->{"detached"}
!ll&&!rl&&r
1350
MC/DC0%0/2
$self->{"closed"} and $self->{"detached"}
$self->{"closed"} $self->{"detached"}
Truth table66%2/3
A and B
A= $self->{"closed"}B= $self->{"detached"}
ABresult
0X0
100
111
556 18 ▶ return 'closed' if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 5 13 18
557 13 ▶ return 'unattached' if !$self->{loop};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"loop"} 5 8 13
558 8 ▶ return 'connecting' if $self->{connection};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"connection"} 4 4 8
559 4 return 'active';
560 }
561 1 ▶sub last_error ($self) { $self->{last_error} }
Subroutine last_error: called CC=1 SCAR=0.0
Pod documented
562 1038 ▶sub transport ($self) { $self->{transport} }
Subroutine transport: called CC=1 SCAR=0.0
Pod documented
563 86 ▶sub is_closed ($self) { !!$self->{closed} }
Subroutine is_closed: called CC=1 SCAR=0.0
Pod documented
564 20 ▶sub is_terminal ($self) { !!$self->{closed} }
Subroutine is_terminal: called CC=1 SCAR=0.0
Pod undocumented
565 6 ▶sub is_read_paused ($self) { !!$self->{read_paused} }
Subroutine is_read_paused: called CC=1 SCAR=0.0
Pod documented
566 5 ▶sub is_read_eof ($self) { !!$self->{read_eof} }
Subroutine is_read_eof: called CC=1 SCAR=0.0
Pod documented
567 10 ▶sub is_write_ended ($self) { !!$self->{write_ended} }
Subroutine is_write_ended: called CC=1 SCAR=0.0
Pod documented
568 8 ▶sub is_write_blocked ($self) {
Subroutine is_write_blocked: called CC=2 SCAR=9.2
Pod documented
569 8 ▶ return !!$self->{xs_state}->is_write_blocked if $self->{xs_state};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"xs_state"} 8 0 8
570 0 return !!$self->{preconnect_write_blocked};
571 }
572  
573 190013 ▶sub data ($self, @arg) {
Subroutine data: called CC=2 SCAR=6.9
Pod documented
574 190013 ▶ $self->{data} = $arg[0] if @arg;
Branch: 1 branch
BranchTrueFalseTotal
if @arg 1 190012 190013
575 190013 return $self->{data};
576 }
577  
578 49424 ▶sub pending_bytes ($self) {
Subroutine pending_bytes: called CC=3 SCAR=11.0
Pod documented
579 49424 ▶ my $pending = $self->{preconnect_bytes} // 0;
Condition100%2/2
$self->{"preconnect_bytes"} // 0
l!l
1149413
MC/DC100%1/1
$self->{"preconnect_bytes"} // 0
$self->{"preconnect_bytes"}
Truth table100%2/2
A
A= $self->{"preconnect_bytes"}
Aresult
11
00
580 49424 ▶ $pending += $self->{xs_state}->pending_bytes if $self->{xs_state};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"xs_state"} 49422 2 49424
581 49424 return $pending;
582 }
583  
584 100506 ▶sub transport_name ($self) {
Subroutine transport_name: called CC=2 SCAR=6.9
Pod documented
585 100506 ▶ return $self->{xs_state}->transport_name if $self->{xs_state};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"xs_state"} 100505 1 100506
586 1 return undef;
587 }
588  
589 6 ▶sub is_transport_ready ($self) {
Subroutine is_transport_ready: called CC=2 SCAR=9.2
Pod documented
590 6 ▶ return !!$self->{xs_state}->transport_ready if $self->{xs_state};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"xs_state"} 6 0 6
591 0 return 0;
592 }
593  
594 1 ▶sub selected_alpn ($self) {
Subroutine selected_alpn: called CC=3 SCAR=12.5
Pod documented
595 1 my $transport = $self->{transport};
596 1 ▶ return undef if !$transport || !$transport->can('selected_alpn');
Branch: 1 branch
BranchTrueFalseTotal
unless $transport and $transport->can("selected_alpn") 0 1 1
Condition33%1/3
$transport and $transport->can("selected_alpn")
!ll&&!rl&&r
001
MC/DC0%0/2
$transport and $transport->can("selected_alpn")
$transport $transport->can("selected_alpn")
Truth table33%1/3
A and B
A= $transportB= $transport->can("selected_alpn")
ABresult
0X0
100
111
597 1 return $transport->selected_alpn;
598 }
599  
600 1 ▶sub tls_protocol ($self) {
Subroutine tls_protocol: called CC=3 SCAR=12.5
Pod documented
601 1 my $transport = $self->{transport};
602 1 ▶ return undef if !$transport || !$transport->can('protocol');
Branch: 1 branch
BranchTrueFalseTotal
unless $transport and $transport->can("protocol") 0 1 1
Condition33%1/3
$transport and $transport->can("protocol")
!ll&&!rl&&r
001
MC/DC0%0/2
$transport and $transport->can("protocol")
$transport $transport->can("protocol")
Truth table33%1/3
A and B
A= $transportB= $transport->can("protocol")
ABresult
0X0
100
111
603 1 return $transport->protocol;
604 }
605  
606 1 ▶sub tls_cipher ($self) {
Subroutine tls_cipher: called CC=3 SCAR=12.5
Pod documented
607 1 my $transport = $self->{transport};
608 1 ▶ return undef if !$transport || !$transport->can('cipher');
Branch: 1 branch
BranchTrueFalseTotal
unless $transport and $transport->can("cipher") 0 1 1
Condition33%1/3
$transport and $transport->can("cipher")
!ll&&!rl&&r
001
MC/DC0%0/2
$transport and $transport->can("cipher")
$transport $transport->can("cipher")
Truth table33%1/3
A and B
A= $transportB= $transport->can("cipher")
ABresult
0X0
100
111
609 1 return $transport->cipher;
610 }
611  
612 1 ▶sub tls_stats ($self) {
Subroutine tls_stats: called CC=3 SCAR=12.5
Pod documented
613 1 my $transport = $self->{transport};
614 1 ▶ return undef if !$transport || !$transport->can('stats');
Branch: 1 branch
BranchTrueFalseTotal
unless $transport and $transport->can("stats") 0 1 1
Condition33%1/3
$transport and $transport->can("stats")
!ll&&!rl&&r
001
MC/DC0%0/2
$transport and $transport->can("stats")
$transport $transport->can("stats")
Truth table33%1/3
A and B
A= $transportB= $transport->can("stats")
ABresult
0X0
100
111
615 1 return $transport->stats;
616 }
617  
618 5 ▶sub idle_timeout ($self) { $self->{timeout}{idle_timeout} }
Subroutine idle_timeout: called CC=1 SCAR=0.0
Pod documented
619 4 ▶sub read_timeout ($self) { $self->{timeout}{read_timeout} }
Subroutine read_timeout: called CC=1 SCAR=0.0
Pod documented
620 4 ▶sub write_timeout ($self) { $self->{timeout}{write_timeout} }
Subroutine write_timeout: called CC=1 SCAR=0.0
Pod documented
621  
622 12 ▶sub _socket_option ($self, $name, @argument) {
Subroutine _socket_option: called CC=6 SCAR=19.6
623 croak "$name(): Stream has no established socket"
624 12 ▶ if $self->{closed} || !defined($self->{fh});
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or not defined $self->{"fh"} 0 12 12
Condition33%1/3
$self->{"closed"} or not defined $self->{"fh"}
l!l&&r!l&&!r
0012
MC/DC0%0/2
$self->{"closed"} or not defined $self->{"fh"}
$self->{"closed"} not defined $self->{"fh"}
Truth table33%1/3
A or not(B)
A= $self->{"closed"}B= not defined $self->{"fh"}
ABresult
1X1
011
000
625 12 ▶ croak "$name(): expected zero or one argument" if @argument > 1;
Branch: 1 branch
BranchTrueFalseTotal
if @argument > 1 0 12 12
626 my $family = $self->{local}
627 ? $self->{local}->family_number
628 12 ▶ : Linux::Event::Address->new(getsockname($self->{fh}))->family_number;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'local'} ? : 12 0 12
629 Linux::Event::_SocketConfig::set_option(
630 12 ▶ $self->{fh}, $family, $name, $argument[0],
Branch: 1 branch
BranchTrueFalseTotal
if @argument 3 9 12
631 ) if @argument;
632 return Linux::Event::_SocketConfig::get_option(
633 12 $self->{fh}, $family, $name,
634 );
635 }
636  
637 3 ▶sub tcp_nodelay ($self, @argument) {
Subroutine tcp_nodelay: called CC=1 SCAR=0.0
Pod documented
638 3 return $self->_socket_option('tcp_nodelay', @argument);
639 }
640 1 ▶sub keepalive ($self, @argument) {
Subroutine keepalive: called CC=1 SCAR=0.0
Pod documented
641 1 return $self->_socket_option('keepalive', @argument);
642 }
643 1 ▶sub keepalive_idle ($self, @argument) {
Subroutine keepalive_idle: called CC=1 SCAR=0.0
Pod documented
644 1 return $self->_socket_option('keepalive_idle', @argument);
645 }
646 1 ▶sub keepalive_interval ($self, @argument) {
Subroutine keepalive_interval: called CC=1 SCAR=0.0
Pod documented
647 1 return $self->_socket_option('keepalive_interval', @argument);
648 }
649 1 ▶sub keepalive_count ($self, @argument) {
Subroutine keepalive_count: called CC=1 SCAR=0.0
Pod documented
650 1 return $self->_socket_option('keepalive_count', @argument);
651 }
652 1 ▶sub tcp_user_timeout ($self, @argument) {
Subroutine tcp_user_timeout: called CC=1 SCAR=0.0
Pod documented
653 1 return $self->_socket_option('tcp_user_timeout', @argument);
654 }
655 2 ▶sub send_buffer ($self, @argument) {
Subroutine send_buffer: called CC=1 SCAR=0.0
Pod documented
656 2 return $self->_socket_option('send_buffer', @argument);
657 }
658 2 ▶sub receive_buffer ($self, @argument) {
Subroutine receive_buffer: called CC=1 SCAR=0.0
Pod documented
659 2 return $self->_socket_option('receive_buffer', @argument);
660 }
661  
662 6 ▶sub set_deadline ($self, %option) {
Subroutine set_deadline: called CC=5 SCAR=16.3
Pod documented
663 6 ▶ croak 'set_deadline(): stream is closed' if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 1 5 6
664 5 my $spec = _deadline_spec('set_deadline', \%option);
665 5 ▶ if (!$self->{deadline_started}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"deadline_started"}) 0 5 5
666 0 $self->{initial_deadline} = $spec;
667 0 return $self;
668 }
669 5 my $now = _deadline_now();
670 $self->{operation_deadline_at} = $spec->{absolute}
671 5 ▶ ? $spec->{seconds} : $now + $spec->{seconds};
Branch: 1 branch
BranchTrueFalseTotal
$spec->{'absolute'} ? : 1 4 5
672 5 $self->{operation_deadline_name} = $spec->{operation};
673 $self->{operation_deadline_timeout} = $spec->{absolute}
674 5 ▶ ? undef : $spec->{seconds};
Branch: 1 branch
BranchTrueFalseTotal
$spec->{'absolute'} ? : 1 4 5
675 5 $self->_rearm_stream_deadline;
676 5 return $self;
677 }
678  
679 2 ▶sub clear_deadline ($self) {
Subroutine clear_deadline: called CC=3 SCAR=11.2
Pod documented
680 2 ▶ croak 'clear_deadline(): stream is closed' if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 2 2
681 2 $self->{initial_deadline} = undef;
682 2 $self->{operation_deadline_at} = undef;
683 2 $self->{operation_deadline_name} = undef;
684 2 $self->{operation_deadline_timeout} = undef;
685 2 ▶ $self->_rearm_stream_deadline if $self->{deadline_started};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"deadline_started"} 2 0 2
686 2 return $self;
687 }
688  
689 7 ▶sub deadline ($self) {
Subroutine deadline: called CC=4 SCAR=13.9
Pod documented
690 return $self->{operation_deadline_at}
691 7 ▶ if defined $self->{operation_deadline_at};
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"operation_deadline_at"} 4 3 7
692 3 ▶ my $spec = $self->{initial_deadline} or return undef;
Branch: 1 branch
BranchTrueFalseTotal
my $spec = $self->{"initial_deadline"} or return undef 1 2 3
693 1 ▶ return $spec->{seconds} if $spec->{absolute};
Branch: 1 branch
BranchTrueFalseTotal
if $spec->{"absolute"} 0 1 1
694 1 return undef;
695 }
696  
697 5 ▶sub deadline_operation ($self) {
Subroutine deadline_operation: called CC=3 SCAR=11.1
Pod documented
698 return $self->{operation_deadline_name}
699 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
700 }
701  
702 193 ▶sub _deadline_now () {
Subroutine _deadline_now: called CC=1 SCAR=0.0
703 193 require Linux::Event::Timer;
704 193 return Linux::Event::Stream::_Deadline->now;
705 }
706  
707 102990 ▶sub _needs_activity_tracking ($self) {
Subroutine _needs_activity_tracking: called CC=3 SCAR=11.0
708 return $self->{timeout}{idle_timeout} > 0
709 || $self->{timeout}{read_timeout} > 0
710 102990 ▶ || $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
932102895
$self->{"timeout"}{"idle_timeout"} > 0 or $self->{"timeout"}{"read_timeout"} > 0
l!l&&r!l&&!r
7815102897
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
711 }
712  
713 102818 ▶sub _start_stream_deadlines ($self) {
Subroutine _start_stream_deadlines: called CC=12 SCAR=26.0
714 102818 ▶ return if $self->{closed} || $self->{deadline_started};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or $self->{"deadline_started"} 0 102818 102818
Condition33%1/3
$self->{"closed"} or $self->{"deadline_started"}
l!l&&r!l&&!r
00102818
MC/DC0%0/2
$self->{"closed"} or $self->{"deadline_started"}
$self->{"closed"} $self->{"deadline_started"}
Truth table33%1/3
A or B
A= $self->{"closed"}B= $self->{"deadline_started"}
ABresult
1X1
011
000
715 102818 ▶ return if !$self->{loop} || !$self->{xs_state};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"loop"} and $self->{"xs_state"} 0 102818 102818
Condition33%1/3
$self->{"loop"} and $self->{"xs_state"}
!ll&&!rl&&r
00102818
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
716 102818 $self->{deadline_started} = 1;
717 return if !$self->_needs_activity_tracking
718 102818 ▶ && !$self->{initial_deadline};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_needs_activity_tracking or $self->{"initial_deadline"} 102769 49 102818
Condition100%3/3
$self->_needs_activity_tracking or $self->{"initial_deadline"}
l!l&&r!l&&!r
472102769
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
719 49 my $now = _deadline_now();
720 49 ▶ if ($self->_needs_activity_tracking) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_needs_activity_tracking) 47 2 49
721 47 $self->{xs_state}->_set_activity_tracking(1);
722 47 $self->{deadline_tracking} = 1;
723 }
724 49 $self->{deadline_read_started} = $now;
725 49 ▶ $self->{deadline_write_started} = $now if $self->pending_bytes > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->pending_bytes > 0 0 49 49
726 49 ▶ if (my $spec = delete $self->{initial_deadline}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $spec = delete $self->{"initial_deadline"}) 3 46 49
727 $self->{operation_deadline_at} = $spec->{absolute}
728 3 ▶ ? $spec->{seconds} : $now + $spec->{seconds};
Branch: 1 branch
BranchTrueFalseTotal
$spec->{'absolute'} ? : 0 3 3
729 3 $self->{operation_deadline_name} = $spec->{operation};
730 $self->{operation_deadline_timeout} = $spec->{absolute}
731 3 ▶ ? undef : $spec->{seconds};
Branch: 1 branch
BranchTrueFalseTotal
$spec->{'absolute'} ? : 0 3 3
732 }
733 49 $self->_rearm_stream_deadline;
734 49 return;
735 }
736  
737 204 ▶sub _deadline_candidates ($self) {
Subroutine _deadline_candidates: called CC=16 SCAR=27.9
738 204 my @candidate;
739 204 ▶ if (defined $self->{operation_deadline_at}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"operation_deadline_at"}) 13 191 204
740 push @candidate, {
741 at => $self->{operation_deadline_at},
742 operation => $self->{operation_deadline_name},
743 timeout => $self->{operation_deadline_timeout},
744 13 priority => 0,
745 };
746 }
747  
748 204 my ($last_read, $last_write);
749 204 ▶ if ($self->{deadline_tracking} && $self->{xs_state}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"deadline_tracking"} and $self->{"xs_state"}) 70 134 204
Condition66%2/3
$self->{"deadline_tracking"} and $self->{"xs_state"}
!ll&&!rl&&r
134070
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
750 ($last_read, $last_write)
751 70 = $self->{xs_state}->_activity_snapshot;
752 }
753 204 my $idle = $self->{timeout}{idle_timeout};
754 204 ▶ if ($idle > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($idle > 0) 48 156 204
755 48 ▶ my $last = $last_read > $last_write ? $last_read : $last_write;
Branch: 1 branch
BranchTrueFalseTotal
$last_read > $last_write ? : 2 46 48
756 48 push @candidate, {
757 at => $last + $idle, operation => 'idle', timeout => $idle,
758 priority => 3,
759 };
760 }
761 204 my $read = $self->{timeout}{read_timeout};
762 204 ▶ if ($read > 0 && !$self->{read_paused} && !$self->{read_eof}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($read > 0 and not $self->{"read_paused"} and not $self->{"read_eof"}) 17 187 204
Condition100%6/6
$read > 0 and not $self->{"read_paused"} and not $self->{"read_eof"}
!ll&&!rl&&r
186117
$read > 0 and not $self->{"read_paused"}
!ll&&!rl&&r
182418
MC/DC100%3/3
$read > 0 and not $self->{"read_paused"} and not $self->{"read_eof"}
$read > 0 not $self->{"read_paused"} not $self->{"read_eof"}
Truth table100%4/4
A and not(B) and not(C)
A= $read > 0B= not $self->{"read_paused"}C= not $self->{"read_eof"}
ABCresult
0XX0
10X0
1100
1111
763 17 my $last = $last_read;
764 $last = $self->{deadline_read_started}
765 if defined($self->{deadline_read_started})
766 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
767 17 push @candidate, {
768 at => $last + $read, operation => 'read', timeout => $read,
769 priority => 2,
770 };
771 }
772 204 my $write = $self->{timeout}{write_timeout};
773 204 ▶ 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) 2 202 204
Condition83%5/6
$write > 0 and not $self->{"write_ended"} and $self->pending_bytes > 0
!ll&&!rl&&r
19662
$write > 0 and not $self->{"write_ended"}
!ll&&!rl&&r
19608
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
774 2 my $last = $last_write;
775 $last = $self->{deadline_write_started}
776 if defined($self->{deadline_write_started})
777 2 ▶ && $self->{deadline_write_started} > $last;
Branch: 1 branch
BranchTrueFalseTotal
if defined $self->{"deadline_write_started"} and $self->{"deadline_write_started"} > $last 2 0 2
Condition33%1/3
defined $self->{"deadline_write_started"} and $self->{"deadline_write_started"} > $last
!ll&&!rl&&r
002
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
778 2 push @candidate, {
779 at => $last + $write, operation => 'write', timeout => $write,
780 priority => 1,
781 };
782 }
783 204 return @candidate;
784 }
785  
786 189 ▶sub _rearm_stream_deadline ($self) {
Subroutine _rearm_stream_deadline: called CC=8 SCAR=21.2
787 189 ▶ return if !$self->{deadline_started} || $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if not $self->{"deadline_started"} or $self->{"closed"} 0 189 189
Condition33%1/3
not $self->{"deadline_started"} or $self->{"closed"}
l!l&&r!l&&!r
00189
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
788 my @candidate = sort {
789 189 $a->{at} <=> $b->{at} || $a->{priority} <=> $b->{priority}
790 3 ▶ } $self->_deadline_candidates;
Condition33%1/3
$Linux::Event::Stream::a->{'at'} <=> $Linux::Event::Stream::b->{'at'} || $Linux::Event::Stream::a->{'priority'} <=> $Linux::Event::Stream::b->{'priority'}
l!l&&r!l&&!r
300
MC/DC0%0/2
$Linux::Event::Stream::a->{'at'} <=> $Linux::Event::Stream::b->{'at'} || $Linux::Event::Stream::a->{'priority'} <=> $Linux::Event::Stream::b->{'priority'}
$Linux::Event::Stream::a->{'at'} <=> $Linux::Event::Stream::b->{'at'} $Linux::Event::Stream::a->{'priority'} <=> $Linux::Event::Stream::b->{'priority'}
Truth table33%1/3
A || B
A= $Linux::Event::Stream::a->{'at'} <=> $Linux::Event::Stream::b->{'at'}B= $Linux::Event::Stream::a->{'priority'} <=> $Linux::Event::Stream::b->{'priority'}
ABresult
1X1
011
000
791 189 ▶ if (!@candidate) {
Branch: 1 branch
BranchTrueFalseTotal
unless (@candidate) 127 62 189
792 127 ▶ if (my $timer = delete $self->{deadline_timer}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $timer = delete $self->{"deadline_timer"}) 4 123 127
793 4 $timer->cancel;
794 }
795 127 return;
796 }
797  
798 62 my $at = $candidate[0]{at};
799 62 ▶ if (my $timer = $self->{deadline_timer}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $timer = $self->{"deadline_timer"}) 7 55 62
800 7 ▶ if ($timer->is_active) {
Branch: 1 branch
BranchTrueFalseTotal
if ($timer->is_active) 7 0 7
801 7 $timer->reschedule(at => $at);
802 7 return;
803 }
804 }
805  
806 55 my $state = { stream => $self };
807 55 weaken($state->{stream});
808 55 my $timer = Linux::Event::Stream::_Deadline->new(
809 at => $at, data => $state,
810 );
811 55 $self->{deadline_timer} = $timer;
812 55 $self->{loop}->add($timer);
813 55 return;
814 }
815  
816 15 ▶sub _stream_deadline_fired ($self, $timer) {
Subroutine _stream_deadline_fired: called CC=5 SCAR=17.4
817 15 ▶ return if $self->{closed} || $self->{deadline_timer} != $timer;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or $self->{"deadline_timer"} != $timer 0 15 15
Condition33%1/3
$self->{"closed"} or $self->{"deadline_timer"} != $timer
l!l&&r!l&&!r
0015
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
818 15 my $now = _deadline_now();
819 my @candidate = sort {
820 15 $a->{at} <=> $b->{at} || $a->{priority} <=> $b->{priority}
821 0 ▶ } $self->_deadline_candidates;
Condition0%0/3
$Linux::Event::Stream::a->{'at'} <=> $Linux::Event::Stream::b->{'at'} || $Linux::Event::Stream::a->{'priority'} <=> $Linux::Event::Stream::b->{'priority'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$Linux::Event::Stream::a->{'at'} <=> $Linux::Event::Stream::b->{'at'} || $Linux::Event::Stream::a->{'priority'} <=> $Linux::Event::Stream::b->{'priority'}
$Linux::Event::Stream::a->{'at'} <=> $Linux::Event::Stream::b->{'at'} $Linux::Event::Stream::a->{'priority'} <=> $Linux::Event::Stream::b->{'priority'}
Truth table0%0/3
A || B
A= $Linux::Event::Stream::a->{'at'} <=> $Linux::Event::Stream::b->{'at'}B= $Linux::Event::Stream::a->{'priority'} <=> $Linux::Event::Stream::b->{'priority'}
ABresult
1X1
011
000
822 15 my ($expired) = grep { $_->{at} <= $now } @candidate;
823 15 ▶ if (!$expired) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($expired) 3 12 15
824 3 $self->_rearm_stream_deadline;
825 3 return;
826 }
827  
828 12 my $operation = $expired->{operation};
829 my $error = Linux::Event::Error->new(
830 type => 'timeout',
831 operation => $operation,
832 message => "$operation deadline expired",
833 timeout => $expired->{timeout},
834 deadline => $expired->{at},
835 12 );
836 12 $self->_fail($error);
837 12 return;
838 }
839  
840 102829 ▶sub _cancel_stream_deadline ($self) {
Subroutine _cancel_stream_deadline: called CC=4 SCAR=13.9
841 102829 ▶ if (my $timer = delete $self->{deadline_timer}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $timer = delete $self->{"deadline_timer"}) 50 102779 102829
842 50 $timer->cancel;
843 }
844 102829 ▶ if ($self->{deadline_tracking} && $self->{xs_state}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"deadline_tracking"} and $self->{"xs_state"}) 46 102783 102829
Condition66%2/3
$self->{"deadline_tracking"} and $self->{"xs_state"}
!ll&&!rl&&r
102783046
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
845 46 $self->{xs_state}->_set_activity_tracking(0);
846 }
847 102829 $self->{deadline_tracking} = 0;
848 102829 $self->{deadline_started} = 0;
849 102829 return;
850 }
851  
852 123 ▶sub _apply_transition_timeouts ($self, $descriptor) {
Subroutine _apply_transition_timeouts: called CC=8 SCAR=20.9
853 123 for my $name (qw(idle_timeout read_timeout write_timeout)) {
854 $self->{timeout}{$name} = $descriptor->{options}{$name}
855 369 ▶ if !exists $self->{timeout_override}{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $self->{"timeout_override"}{$name} 368 1 369
856 }
857 123 ▶ return if !$self->{deadline_started} || !$self->{xs_state};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"deadline_started"} and $self->{"xs_state"} 0 123 123
Condition33%1/3
$self->{"deadline_started"} and $self->{"xs_state"}
!ll&&!rl&&r
00123
MC/DC0%0/2
$self->{"deadline_started"} and $self->{"xs_state"}
$self->{"deadline_started"} $self->{"xs_state"}
Truth table33%1/3
A and B
A= $self->{"deadline_started"}B= $self->{"xs_state"}
ABresult
0X0
100
111
858 $self->{xs_state}->_set_activity_tracking(0)
859 123 ▶ if $self->{deadline_tracking};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"deadline_tracking"} 1 122 123
860 123 $self->{deadline_tracking} = 0;
861 123 my $now = _deadline_now();
862 123 ▶ if ($self->_needs_activity_tracking) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->_needs_activity_tracking) 1 122 123
863 1 $self->{xs_state}->_set_activity_tracking(1);
864 1 $self->{deadline_tracking} = 1;
865 }
866 123 $self->{deadline_read_started} = $now;
867 123 ▶ $self->{deadline_write_started} = $self->pending_bytes > 0 ? $now : undef;
Branch: 1 branch
BranchTrueFalseTotal
$self->pending_bytes > 0 ? : 1 122 123
868 123 $self->_rearm_stream_deadline;
869 123 return;
870 }
871  
872 49122 ▶sub write ($self, $bytes) {
Subroutine write: called CC=21 SCAR=32.1
Pod documented
873 49122 ▶ croak 'write(): stream is closed' if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 49122 49122
874 croak 'write(): writable side has ended'
875 49122 ▶ if $self->{write_ending} || $self->{write_ended};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"write_ending"} or $self->{"write_ended"} 1 49121 49122
Condition66%2/3
$self->{"write_ending"} or $self->{"write_ended"}
l!l&&r!l&&!r
0149121
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
876 49121 ▶ return 1 if !defined $bytes;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $bytes 0 49121 49121
877 49121 ▶ croak 'write(): bytes must be a scalar byte string' if ref $bytes;
Branch: 1 branch
BranchTrueFalseTotal
if ref $bytes 0 49121 49121
878 49121 $bytes = "$bytes";
879 49121 ▶ croak 'write(): bytes must be a scalar byte string'
Branch: 1 branch
BranchTrueFalseTotal
unless utf8::downgrade($bytes, 1) 1 49120 49121
880 if !utf8::downgrade($bytes, 1);
881 49120 ▶ return 1 if $bytes eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $bytes eq "" 1 49119 49120
882  
883 49119 ▶ if (!$self->{xs_state}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"xs_state"}) 5 49114 49119
884 croak 'write(): stream has no pending or active transport'
885 5 ▶ if !$self->{connection};
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"connection"} 0 5 5
886 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
887 5 my $limit = $self->{descriptor}{options}{max_pending_bytes};
888 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
889 0 my $error = Linux::Event::Error->new(
890 type => 'output_limit',
891 operation => 'write',
892 message => "pending output would exceed $limit bytes",
893 pending_bytes => $pending,
894 limit => $limit,
895 );
896 0 $self->_fail($error);
897 0 return 0;
898 }
899 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
900 5 $self->{preconnect_bytes} = $pending;
901 5 ▶ if ($pending > $self->{descriptor}{options}{high_watermark}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pending > $self->{"descriptor"}{"options"}{"high_watermark"}) 1 4 5
902 1 $self->{preconnect_write_blocked} = 1;
903 1 return 0;
904 }
905 4 return 1;
906 }
907  
908 49114 my $was_pending = $self->pending_bytes;
909 49114 my $status = $self->{xs_state}->_write($bytes);
910 49114 ▶ $self->{watcher}->enable_write if $status & 0x02;
Branch: 1 branch
BranchTrueFalseTotal
if $status & 2 19 49095 49114
911 49114 ▶ 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 49113 49114
Condition77%7/9
$self->{"deadline_started"} and $self->{"timeout"}{"write_timeout"} > 0 and not $was_pending and $self->pending_bytes > 0
!ll&&!rl&&r
4911301
$self->{"deadline_started"} and $self->{"timeout"}{"write_timeout"} > 0 and not $was_pending
!ll&&!rl&&r
4911301
$self->{"deadline_started"} and $self->{"timeout"}{"write_timeout"} > 0
!ll&&!rl&&r
1491121
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
912 && !$was_pending && $self->pending_bytes > 0) {
913 1 $self->{deadline_write_started} = _deadline_now();
914 1 $self->_rearm_stream_deadline;
915 }
916 49114 ▶ return $status & 0x01 ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$status & 1 ? : 49100 14 49114
917 }
918  
919 16341 ▶sub send ($self, $payload) {
Subroutine send: called CC=2 SCAR=7.1
Pod documented
920 my $framer = $self->{descriptor}{framer}
921 16341 ▶ // croak 'send(): requires a framed Stream subclass';
Condition50%1/2
$self->{"descriptor"}{"framer"} // croak("send(): requires a framed Stream subclass")
l!l
163410
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
922 16341 my $bytes = $framer->{frame}->($framer->{native}, $payload);
923 16337 return $self->write($bytes);
924 }
925  
926 10 ▶sub end ($self, $final_bytes = undef) {
Subroutine end: called CC=9 SCAR=25.9
Pod documented
927 return $self
928 10 ▶ if $self->{closed} || $self->{write_ending} || $self->{write_ended};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or $self->{"write_ending"} or $self->{"write_ended"} 0 10 10
Condition33%2/6
$self->{"closed"} or $self->{"write_ending"} or $self->{"write_ended"}
l!l&&r!l&&!r
0010
$self->{"closed"} or $self->{"write_ending"}
l!l&&r!l&&!r
0010
MC/DC0%0/3
$self->{"closed"} or $self->{"write_ending"} or $self->{"write_ended"}
$self->{"closed"} $self->{"write_ending"} $self->{"write_ended"}
Truth table25%1/4
A or B or C
A= $self->{"closed"}B= $self->{"write_ending"}C= $self->{"write_ended"}
ABCresult
1XX1
01X1
0011
0000
929 10 ▶ $self->write($final_bytes) if defined($final_bytes) && $final_bytes ne '';
Branch: 1 branch
BranchTrueFalseTotal
if defined $final_bytes and $final_bytes ne "" 0 10 10
Condition33%1/3
defined $final_bytes and $final_bytes ne ""
!ll&&!rl&&r
1000
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
930 10 $self->{write_ending} = 1;
931 $self->_finish_write_side
932 10 ▶ if $self->{xs_state} && $self->pending_bytes == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"xs_state"} and $self->pending_bytes == 0 9 1 10
Condition66%2/3
$self->{"xs_state"} and $self->pending_bytes == 0
!ll&&!rl&&r
019
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
933 10 return $self;
934 }
935  
936 16 ▶sub pause_read ($self) {
Subroutine pause_read: called CC=8 SCAR=22.8
Pod documented
937 16 ▶ return $self if $self->{closed} || $self->{read_eof} || $self->{read_paused};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or $self->{"read_eof"} or $self->{"read_paused"} 0 16 16
Condition33%2/6
$self->{"closed"} or $self->{"read_eof"} or $self->{"read_paused"}
l!l&&r!l&&!r
0016
$self->{"closed"} or $self->{"read_eof"}
l!l&&r!l&&!r
0016
MC/DC0%0/3
$self->{"closed"} or $self->{"read_eof"} or $self->{"read_paused"}
$self->{"closed"} $self->{"read_eof"} $self->{"read_paused"}
Truth table25%1/4
A or B or C
A= $self->{"closed"}B= $self->{"read_eof"}C= $self->{"read_paused"}
ABCresult
1XX1
01X1
0011
0000
938 16 $self->{read_paused} = 1;
939 16 ▶ $self->{xs_state}->_pause if $self->{xs_state};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"xs_state"} 16 0 16
940 16 ▶ $self->{watcher}->disable_read if $self->{watcher};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"watcher"} 16 0 16
941 $self->_rearm_stream_deadline
942 16 ▶ if $self->{deadline_started} && $self->{timeout}{read_timeout} > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"deadline_started"} and $self->{"timeout"}{"read_timeout"} > 0 3 13 16
Condition100%3/3
$self->{"deadline_started"} and $self->{"timeout"}{"read_timeout"} > 0
!ll&&!rl&&r
1123
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
943 16 return $self;
944 }
945  
946 15 ▶sub resume_read ($self) {
Subroutine resume_read: called CC=10 SCAR=25.6
Pod documented
947 15 ▶ return $self if $self->{closed} || $self->{read_eof} || !$self->{read_paused};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or $self->{"read_eof"} or not $self->{"read_paused"} 0 15 15
Condition33%2/6
$self->{"closed"} or $self->{"read_eof"} or not $self->{"read_paused"}
l!l&&r!l&&!r
0015
$self->{"closed"} or $self->{"read_eof"}
l!l&&r!l&&!r
0015
MC/DC0%0/3
$self->{"closed"} or $self->{"read_eof"} or not $self->{"read_paused"}
$self->{"closed"} $self->{"read_eof"} not $self->{"read_paused"}
Truth table25%1/4
A or B or not(C)
A= $self->{"closed"}B= $self->{"read_eof"}C= not $self->{"read_paused"}
ABCresult
1XX1
01X1
0011
0000
948 15 $self->{read_paused} = 0;
949 $self->{deadline_read_started} = _deadline_now()
950 15 ▶ if $self->{deadline_started} && $self->{timeout}{read_timeout} > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"deadline_started"} and $self->{"timeout"}{"read_timeout"} > 0 2 13 15
Condition66%2/3
$self->{"deadline_started"} and $self->{"timeout"}{"read_timeout"} > 0
!ll&&!rl&&r
0132
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
951 15 ▶ $self->{xs_state}->_resume if $self->{xs_state};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"xs_state"} 15 0 15
952 15 ▶ $self->{watcher}->enable_read if $self->{watcher};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"watcher"} 15 0 15
953 $self->_rearm_stream_deadline
954 15 ▶ if $self->{deadline_started} && $self->{timeout}{read_timeout} > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"deadline_started"} and $self->{"timeout"}{"read_timeout"} > 0 2 13 15
Condition66%2/3
$self->{"deadline_started"} and $self->{"timeout"}{"read_timeout"} > 0
!ll&&!rl&&r
0132
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
955 15 return $self;
956 }
957  
958 128 ▶sub transition_to ($self, $class, %opt) {
Subroutine transition_to: called CC=12 SCAR=26.0
Pod documented
959 128 ▶ croak 'transition_to(): stream is closed' if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 1 127 128
960 127 ▶ croak 'transition_to(): target class is required'
Branch: 1 branch
BranchTrueFalseTotal
if not defined $class or ref $class or $class eq "" 0 127 127
Condition33%2/6
not defined $class or ref $class or $class eq ""
l!l&&r!l&&!r
00127
not defined $class or ref $class
l!l&&r!l&&!r
00127
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
961 if !defined($class) || ref($class) || $class eq '';
962 127 ▶ croak "transition_to(): $class is already active"
Branch: 1 branch
BranchTrueFalseTotal
if ref $self eq $class 1 126 127
963 if ref($self) eq $class;
964  
965 126 my $input = delete $opt{input};
966 126 ▶ croak 'transition_to(): input must be a byte string'
Branch: 1 branch
BranchTrueFalseTotal
if defined $input and ref $input 0 126 126
Condition66%2/3
defined $input and ref $input
!ll&&!rl&&r
12150
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
967 if defined($input) && ref($input);
968 126 ▶ if (defined $input) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $input) 5 121 126
969 5 $input = "$input";
970 5 ▶ croak 'transition_to(): input must be a byte string'
Branch: 1 branch
BranchTrueFalseTotal
unless utf8::downgrade($input, 1) 0 5 5
971 if !utf8::downgrade($input, 1);
972 }
973 126 ▶ croak 'transition_to(): unknown options: ' . join(', ', sort keys %opt)
Branch: 1 branch
BranchTrueFalseTotal
if %opt 1 125 126
974 if %opt;
975  
976 125 my $descriptor = Linux::Event::Stream::_Descriptor::for_class($class);
977 my $xs_state = $self->{xs_state}
978 125 ▶ // croak 'transition_to(): stream has no native state';
Condition50%1/2
$self->{"xs_state"} // croak("transition_to(): stream has no native state")
l!l
1250
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
979  
980 # XS validates and swaps the immutable descriptor without invoking a
981 # callback. Update the Perl object's type before buffered input is allowed
982 # to enter the new callback set.
983 125 $xs_state->_transition($descriptor->{xs}, $input);
984 123 $self->{descriptor} = $descriptor;
985 123 bless $self, $class;
986 123 $self->_apply_transition_timeouts($descriptor);
987 123 $xs_state->_transition_ready;
988 123 return $self;
989 }
990  
991 2310 ▶sub close ($self) {
Subroutine close: called CC=1 SCAR=0.0
Pod documented
992 2310 $self->_close_now(1);
993 2310 return $self;
994 }
995  
996 100491 ▶sub detach ($self) {
Subroutine detach: called CC=7 SCAR=20.0
Pod documented
997 100491 ▶ croak 'detach(): stream is already closed' if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 100491 100491
998 100491 ▶ croak 'detach(): stream is not established' if !defined $self->{fh};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->{"fh"} 0 100491 100491
999 100491 ▶ croak 'detach(): cannot detach a non-plain transport'
Branch: 1 branch
BranchTrueFalseTotal
if ($self->transport_name // "plain") ne "plain" 1 100490 100491
Condition50%1/2
$self->transport_name // "plain"
l!l
1004910
MC/DC0%0/1
$self->transport_name // "plain"
$self->transport_name
Truth table50%1/2
A
A= $self->transport_name
Aresult
11
00
1000 if ($self->transport_name // 'plain') ne 'plain';
1001 100490 my $fh = $self->{fh};
1002 100490 $self->_cancel_stream_deadline;
1003 100490 ▶ if (my $xs_state = delete $self->{xs_state}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $xs_state = delete $self->{"xs_state"}) 100490 0 100490
1004 100490 $xs_state->_close;
1005 }
1006 100490 ▶ if (my $watcher = delete $self->{watcher}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $watcher = delete $self->{"watcher"}) 100490 0 100490
1007 100490 $watcher->cancel;
1008 }
1009 100490 $self->{closed} = 1;
1010 100490 $self->{detached} = 1;
1011 100490 $self->{fh} = undef;
1012 100490 return $fh;
1013 }
1014  
1015 74686 ▶sub _on_terminal_ready ($self) {
Subroutine _on_terminal_ready: called CC=7 SCAR=22.0
1016 74686 ▶ return if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 74686 74686
1017  
1018 74686 my $packed = getsockopt($self->{fh}, SOL_SOCKET, SO_ERROR);
1019 74686 ▶ if (defined $packed) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $packed) 74686 0 74686
1020 74686 my $errno = unpack('i', $packed);
1021 74686 ▶ if ($errno) {
Branch: 1 branch
BranchTrueFalseTotal
if ($errno) 0 74686 74686
1022 0 local $! = $errno;
1023 0 $self->_fail_io('socket', $errno);
1024 0 return;
1025 }
1026 }
1027  
1028 $self->{xs_state}->_read_ready
1029 74686 ▶ 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"} 15 74671 74686
Condition66%4/6
not $self->{"read_paused"} || $self->{"read_eof"} and $self->{"xs_state"}
!ll&&!rl&&r
74671015
$self->{'read_paused'} || $self->{'read_eof'}
l!l&&r!l&&!r
07467115
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
1030 }
1031  
1032 10 ▶sub _finish_write_side ($self) {
Subroutine _finish_write_side: called CC=18 SCAR=40.1
1033 10 ▶ return if $self->{closed} || $self->{write_ended};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} or $self->{"write_ended"} 0 10 10
Condition33%1/3
$self->{"closed"} or $self->{"write_ended"}
l!l&&r!l&&!r
0010
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
1034 10 ▶ return if $self->pending_bytes > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->pending_bytes > 0 0 10 10
1035  
1036 10 ▶ if (!$self->{transport_shutdown_started}++ && $self->{transport}
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"transport_shutdown_started"}++ and $self->{"transport"} and $self->{"transport"}->can("_stream_transport_begin_shutdown")) 3 7 10
Condition66%4/6
not $self->{"transport_shutdown_started"}++ and $self->{"transport"} and $self->{"transport"}->can("_stream_transport_begin_shutdown")
!ll&&!rl&&r
703
not $self->{"transport_shutdown_started"}++ and $self->{"transport"}
!ll&&!rl&&r
073
MC/DC33%1/3
not $self->{"transport_shutdown_started"}++ and $self->{"transport"} and $self->{"transport"}->can("_stream_transport_begin_shutdown")
not $self->{"transport_shutdown_started"}++ $self->{"transport"} $self->{"transport"}->can("_stream_transport_begin_shutdown")
Truth table50%2/4
not(A) and B and C
A= not $self->{"transport_shutdown_started"}++B= $self->{"transport"}C= $self->{"transport"}->can("_stream_transport_begin_shutdown")
ABCresult
0XX0
10X0
1100
1111
1037 && $self->{transport}->can('_stream_transport_begin_shutdown')) {
1038 3 my $started = eval {
1039 3 $self->{transport}->_stream_transport_begin_shutdown($self);
1040 3 1;
1041 };
1042 3 ▶ if (!$started) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($started) 0 3 3
1043 0 ▶ my $error = Linux::Event::Error->new(
Condition0%0/2
$@ || 'transport shutdown setup failed'
l!l
00
MC/DC0%0/1
$@ || 'transport shutdown setup failed'
$@
Truth table0%0/2
A
A= $@
Aresult
11
00
1044 type => $self->transport_name,
1045 operation => 'shutdown',
1046 message => $@ || 'transport shutdown setup failed',
1047 );
1048 0 $self->_fail($error);
1049 0 return;
1050 }
1051 }
1052  
1053 10 my ($status, $errno, $message) = $self->{xs_state}->_shutdown_write;
1054 10 ▶ if ($status == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status == 2) 1 9 10
1055 1 ▶ $self->{watcher}->enable_read if $self->{watcher};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"watcher"} 1 0 1
1056 1 return;
1057 }
1058 9 ▶ if ($status == 3) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status == 3) 0 9 9
1059 0 ▶ $self->{watcher}->enable_write if $self->{watcher};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"watcher"} 0 0 0
1060 0 return;
1061 }
1062 9 ▶ if ($status == 5) {
Branch: 1 branch
BranchTrueFalseTotal
if ($status == 5) 0 9 9
1063 0 ▶ if (($self->transport_name // 'plain') ne 'plain') {
Branch: 1 branch
BranchTrueFalseTotal
if (($self->transport_name // "plain") ne "plain") 0 0 0
Condition0%0/2
$self->transport_name // "plain"
l!l
00
MC/DC0%0/1
$self->transport_name // "plain"
$self->transport_name
Truth table0%0/2
A
A= $self->transport_name
Aresult
11
00
1064 0 ▶ my $error = Linux::Event::Error->new(
Condition0%0/2
$message || 'transport shutdown failed'
l!l
00
MC/DC0%0/1
$message || 'transport shutdown failed'
$message
Truth table0%0/2
A
A= $message
Aresult
11
00
1065 type => $self->transport_name,
1066 operation => 'shutdown',
1067 message => $message || 'transport shutdown failed',
1068 );
1069 0 $self->_fail($error);
1070 0 return;
1071 }
1072 0 local $! = $errno;
1073 0 $self->_fail_io('shutdown', $errno);
1074 0 return;
1075 }
1076  
1077 9 $self->{write_ending} = 0;
1078 9 $self->{write_ended} = 1;
1079 9 $self->_clear_transport_deadline;
1080 9 ▶ $self->_close_now(1) if $self->{read_eof};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"read_eof"} 2 7 9
1081 }
1082  
1083 21 ▶sub _set_transport_deadline_watcher ($self, $watcher) {
Subroutine _set_transport_deadline_watcher: called CC=2 SCAR=7.1
1084 21 ▶ return if $self->{transport_deadline_watcher};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"transport_deadline_watcher"} 0 21 21
1085 21 $self->{transport_deadline_watcher} = $watcher;
1086 21 return;
1087 }
1088  
1089 23 ▶sub _has_transport_deadline_watcher ($self) {
Subroutine _has_transport_deadline_watcher: called CC=1 SCAR=0.0
1090 23 return !!$self->{transport_deadline_watcher};
1091 }
1092  
1093 25 ▶sub _clear_transport_deadline ($self) {
Subroutine _clear_transport_deadline: called CC=3 SCAR=11.0
1094 25 ▶ if ($self->{transport}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"transport"} and $self->{"transport"}->can("_stream_transport_cancel_deadline")) 18 7 25
Condition66%2/3
$self->{"transport"} and $self->{"transport"}->can("_stream_transport_cancel_deadline")
!ll&&!rl&&r
7018
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
1095 && $self->{transport}->can('_stream_transport_cancel_deadline')) {
1096 18 $self->{transport}->_stream_transport_cancel_deadline;
1097 }
1098 25 return;
1099 }
1100  
1101 2339 ▶sub _destroy_transport_deadline ($self) {
Subroutine _destroy_transport_deadline: called CC=4 SCAR=13.9
1102 2339 ▶ if (my $watcher = delete $self->{transport_deadline_watcher}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $watcher = delete $self->{"transport_deadline_watcher"}) 20 2319 2339
1103 20 $watcher->cancel;
1104 }
1105 2339 ▶ if ($self->{transport}
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"transport"} and $self->{"transport"}->can("_stream_transport_close_deadline")) 21 2318 2339
Condition66%2/3
$self->{"transport"} and $self->{"transport"}->can("_stream_transport_close_deadline")
!ll&&!rl&&r
2318021
MC/DC50%1/2
$self->{"transport"} and $self->{"transport"}->can("_stream_transport_close_deadline")
$self->{"transport"} $self->{"transport"}->can("_stream_transport_close_deadline")
Truth table66%2/3
A and B
A= $self->{"transport"}B= $self->{"transport"}->can("_stream_transport_close_deadline")
ABresult
0X0
100
111
1106 && $self->{transport}->can('_stream_transport_close_deadline')) {
1107 21 $self->{transport}->_stream_transport_close_deadline;
1108 }
1109 2339 return;
1110 }
1111  
1112 3 ▶sub _transport_deadline_expired ($self, $operation, $message) {
Subroutine _transport_deadline_expired: called CC=3 SCAR=11.4
1113 3 ▶ return if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 3 3
1114 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
1115 type => $self->transport_name // 'transport',
1116 operation => $operation,
1117 message => $message,
1118 );
1119 3 $self->_fail($error);
1120 3 return;
1121 }
1122  
1123 28 ▶sub _mark_eof ($self) {
Subroutine _mark_eof: called CC=8 SCAR=21.6
1124 28 ▶ return if $self->{read_eof} || $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"read_eof"} or $self->{"closed"} 0 28 28
Condition33%1/3
$self->{"read_eof"} or $self->{"closed"}
l!l&&r!l&&!r
0028
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
1125 28 $self->{read_eof} = 1;
1126 28 ▶ $self->{watcher}->disable_read if $self->{watcher};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"watcher"} 28 0 28
1127 $self->_rearm_stream_deadline
1128 28 ▶ if $self->{deadline_started} && $self->{timeout}{read_timeout} > 0;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"deadline_started"} and $self->{"timeout"}{"read_timeout"} > 0 1 27 28
Condition66%2/3
$self->{"deadline_started"} and $self->{"timeout"}{"read_timeout"} > 0
!ll&&!rl&&r
0271
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
1129  
1130 28 ▶ if (my $callback = $self->{descriptor}{callbacks}{on_eof}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $callback = $self->{"descriptor"}{"callbacks"}{"on_eof"}) 26 2 28
1131 26 $callback->($self);
1132 }
1133 28 ▶ $self->_close_now(1) if $self->{write_ended};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"write_ended"} 3 25 28
1134 }
1135  
1136 0 ▶sub _fail_io ($self, $operation, $errno) {
Subroutine _fail_io: not called CC=1 SCAR=6.9
1137 0 local $! = $errno;
1138 0 my $error = Linux::Event::Error->new(
1139 type => 'io',
1140 operation => $operation,
1141 errno => $errno,
1142 message => "$!",
1143 );
1144 0 $self->_fail($error);
1145 }
1146  
1147 15 ▶sub _fail_framing ($self, $message) {
Subroutine _fail_framing: called CC=1 SCAR=0.0
1148 15 my $error = Linux::Event::Error->new(
1149 type => 'framing',
1150 operation => 'frame',
1151 message => $message,
1152 );
1153 15 $self->_fail($error);
1154 }
1155  
1156 39 ▶sub _fail ($self, $error) {
Subroutine _fail: called CC=7 SCAR=20.2
1157 39 ▶ return if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 0 39 39
1158 39 $self->{last_error} = $error;
1159 39 my $failure;
1160 39 ▶ if (my $callback = $self->{descriptor}{callbacks}{on_error}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $callback = $self->{"descriptor"}{"callbacks"}{"on_error"}) 39 0 39
1161 39 my $reported = eval { $callback->($self, $error); 1 };
1162 39 ▶ $failure = $@ if !$reported;
Branch: 1 branch
BranchTrueFalseTotal
unless $reported 1 38 39
1163 }
1164 39 my $closed = eval { $self->_close_now(1); 1 };
1165 39 ▶ $failure //= $@ if !$closed;
Branch: 1 branch
BranchTrueFalseTotal
unless $closed 0 39 39
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
1166 39 ▶ die $failure if defined $failure;
Branch: 1 branch
BranchTrueFalseTotal
if defined $failure 1 38 39
1167 38 return;
1168 }
1169  
1170 2354 ▶sub _close_now ($self, $close_fh) {
Subroutine _close_now: called CC=10 SCAR=23.1
1171 2354 ▶ return if $self->{closed};
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"closed"} 15 2339 2354
1172 2339 $self->{closed} = 1;
1173 2339 ▶ if (my $connection = delete $self->{connection}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $connection = delete $self->{"connection"}) 4 2335 2339
1174 4 $connection->cancel;
1175 }
1176 2339 $self->{preconnect_output} = [];
1177 2339 $self->{preconnect_bytes} = 0;
1178 2339 delete $self->{preconnect_write_blocked};
1179 2339 delete $self->{preconnect_drain_reached};
1180 2339 $self->_cancel_stream_deadline;
1181 2339 $self->_destroy_transport_deadline;
1182  
1183 2339 ▶ if (my $xs_state = delete $self->{xs_state}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $xs_state = delete $self->{"xs_state"}) 2330 9 2339
1184 2330 $xs_state->_close;
1185 }
1186 2339 ▶ if (my $watcher = delete $self->{watcher}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $watcher = delete $self->{"watcher"}) 2326 13 2339
1187 2326 $watcher->cancel;
1188 }
1189 2339 ▶ CORE::close($self->{fh}) if $close_fh && defined $self->{fh};
Branch: 1 branch
BranchTrueFalseTotal
if $close_fh and defined $self->{"fh"} 2330 9 2339
Condition66%2/3
$close_fh and defined $self->{"fh"}
!ll&&!rl&&r
092330
MC/DC50%1/2
$close_fh and defined $self->{"fh"}
$close_fh defined $self->{"fh"}
Truth table66%2/3
A and B
A= $close_fhB= defined $self->{"fh"}
ABresult
0X0
100
111
1190 2339 $self->{fh} = undef;
1191  
1192 2339 ▶ if (!$self->{detached} && !$self->{close_fired}++) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $self->{"detached"} || $self->{"close_fired"}++) 2339 0 2339
Condition33%1/3
$self->{'detached'} || $self->{'close_fired'}++
l!l&&r!l&&!r
002339
MC/DC0%0/2
$self->{'detached'} || $self->{'close_fired'}++
$self->{'detached'} $self->{'close_fired'}++
Truth table33%1/3
A || B
A= $self->{'detached'}B= $self->{'close_fired'}++
ABresult
1X1
011
000
1193 2339 ▶ if (my $callback = $self->{descriptor}{callbacks}{on_close}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $callback = $self->{"descriptor"}{"callbacks"}{"on_close"}) 33 2306 2339
1194 33 $callback->($self);
1195 }
1196 }
1197 }
1198  
1199 102827 ▶sub _set_nonblocking ($fh) {
Subroutine _set_nonblocking: called CC=7 SCAR=20.0
1200 102827 my $flags = fcntl($fh, F_GETFL, 0);
1201 102827 ▶ croak "new(): fcntl(F_GETFL): $!" if !defined $flags;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $flags 0 102827 102827
1202 102827 ▶ if (!($flags & O_NONBLOCK)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($flags & 2048) 518 102309 102827
1203 518 ▶ fcntl($fh, F_SETFL, $flags | O_NONBLOCK)
Branch: 1 branch
BranchTrueFalseTotal
fcntl $fh, 4, $flags | 2048 or croak("new(): fcntl(F_SETFL O_NONBLOCK): $!") 518 0 518
1204 or croak "new(): fcntl(F_SETFL O_NONBLOCK): $!";
1205 }
1206 102827 my $descriptor_flags = fcntl($fh, F_GETFD, 0);
1207 102827 ▶ croak "new(): fcntl(F_GETFD): $!" if !defined $descriptor_flags;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $descriptor_flags 0 102827 102827
1208 102827 ▶ if (!($descriptor_flags & FD_CLOEXEC)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $descriptor_flags & 1) 1 102826 102827
1209 1 ▶ fcntl($fh, F_SETFD, $descriptor_flags | FD_CLOEXEC)
Branch: 1 branch
BranchTrueFalseTotal
fcntl $fh, 2, $descriptor_flags | 1 or croak("new(): fcntl(F_SETFD FD_CLOEXEC): $!") 1 0 1
1210 or croak "new(): fcntl(F_SETFD FD_CLOEXEC): $!";
1211 }
1212 }
1213  
1214 87 1;
1215  
1216 package Linux::Event::Stream::XSDescriptor;
1217 0 ▶sub CLONE_SKIP ($class) { 1 }
Subroutine CLONE_SKIP: not called CC=1 SCAR=6.9
1218  
1219 package Linux::Event::Stream::XSState;
1220 0 ▶sub CLONE_SKIP ($class) { 1 }
Subroutine CLONE_SKIP: not called CC=1 SCAR=6.9
1221  
1222 package Linux::Event::Stream::_Deadline;
1223 87 ▶use parent -norequire, 'Linux::Event::Timer';
Subroutine BEGIN: called CC=1 SCAR=0.0
1224  
1225 15 ▶sub on_timer ($timer) {
Subroutine on_timer: called CC=2 SCAR=7.0
1226 15 my $state = $timer->data;
1227 15 my $stream = $state->{stream};
1228 15 ▶ $stream->_stream_deadline_fired($timer) if $stream;
Branch: 1 branch
BranchTrueFalseTotal
if $stream 15 0 15
1229 15 return;
1230 }
1231  
1232 package Linux::Event::Stream;
1233  
1234 __END__
« blib/lib/Linux/Event/Process.pm ↑ Summary bench/run-listen-microbench.pl »