blib/lib/Linux/Event/TLS.pm

filter: Statementstmt 94.7% 143 / 151 Branchbran 75.5% 65 / 86 Conditioncond 48.5% 33 / 68 MC/DCmcdc 16.2% 6 / 37 Subroutinesub 89.6% 26 / 29 Podpod 0.0% 0 / 2 totaltotal 73.1% 273 / 373 CC 70 SCAR 19.1
CC
70
Cov
79%
_alpn_wire
12.3
client
9.6
_timeout
9.1
CRAP 6.7
« blib/lib/Linux/Event/Kernel/Timer.pm ↑ Summary blib/lib/Linux/Event/Framer/Varint.pm »
1 package Linux::Event::TLS;
2 13 ▶use v5.36;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 13 our $VERSION = '0.119';
7  
8 13 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 13 ▶use POSIX qw(isfinite);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 13 ▶use utf8 ();
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 13 require XSLoader;
13 13 XSLoader::load(__PACKAGE__, $VERSION);
14  
15 0 ▶sub CLONE_SKIP ($class) { 1 }
Subroutine CLONE_SKIP: not called CC=1 SCAR=6.9
16  
17 26 ▶sub import ($class, @arg) {
Subroutine import: called CC=7 SCAR=19.6
18 26 my $target = caller;
19 26 require Linux::Event::IO::Sock::Stream;
20 26 require Linux::Event::_Socket::Descriptor;
21  
22 26 ▶ my $base = $target->isa('Linux::Event::IO::Sock::Stream')
Branch: 1 branch
BranchTrueFalseTotal
$target->isa('Linux::Event::IO::Sock::Stream') ? : 12 14 26
23 ? 'Linux::Event::IO::Sock::Stream' : undef;
24  
25 26 ▶ return if $target eq 'main' && !defined($base) && !@arg;
Branch: 1 branch
BranchTrueFalseTotal
if $target eq "main" and not defined $base and not @arg 13 13 26
Condition66%4/6
$target eq "main" and not defined $base and not @arg
!ll&&!rl&&r
13013
$target eq "main" and not defined $base
!ll&&!rl&&r
13013
MC/DC33%1/3
$target eq "main" and not defined $base and not @arg
$target eq "main" not defined $base not @arg
Truth table50%2/4
A and not(B) and not(C)
A= $target eq "main"B= not defined $baseC= not @arg
ABCresult
0XX0
10X0
1100
1111
26 13 ▶ croak "$target must be a Linux::Event IO stream-socket subclass before declaring TLS"
Branch: 1 branch
BranchTrueFalseTotal
unless defined $base 1 12 13
27 if !defined $base;
28 12 ▶ croak 'TLS declaration options must be key/value pairs' if @arg % 2;
Branch: 1 branch
BranchTrueFalseTotal
if @arg % 2 0 12 12
29  
30 12 Linux::Event::_Socket::Descriptor::declare_tls(
31 $base,
32 $target,
33 $class->_build_declaration($target, @arg),
34 );
35 6 return;
36 }
37  
38 41 ▶sub _alpn_wire ($protocols) {
Subroutine _alpn_wire: called CC=11 SCAR=25.1
39 41 ▶ return '' if !defined $protocols;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $protocols 27 14 41
40 14 ▶ croak 'alpn must be an array reference' if ref($protocols) ne 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $protocols ne "ARRAY" 0 14 14
41 14 my $wire = '';
42 14 for my $protocol (@$protocols) {
43 269 ▶ my $bytes = defined($protocol) && !ref($protocol)
Branch: 1 branch
BranchTrueFalseTotal
defined $protocol && !ref($protocol) ? : 269 0 269
Condition33%1/3
defined $protocol and not ref $protocol
!ll&&!rl&&r
00269
MC/DC0%0/2
defined $protocol and not ref $protocol
defined $protocol not ref $protocol
Truth table33%1/3
A and not(B)
A= defined $protocolB= not ref $protocol
ABresult
0X0
100
111
44 ? "$protocol" : undef;
45 269 ▶ my $is_bytes = defined($bytes) && utf8::downgrade($bytes, 1);
Condition66%2/3
defined $bytes && utf8::downgrade($bytes, 1)
!ll&&!rl&&r
01268
MC/DC50%1/2
defined $bytes && utf8::downgrade($bytes, 1)
defined $bytes utf8::downgrade($bytes, 1)
Truth table66%2/3
A && B
A= defined $bytesB= utf8::downgrade($bytes, 1)
ABresult
0X0
100
111
46 269 ▶ croak 'each ALPN protocol must be a byte string of 1..255 bytes'
Branch: 1 branch
BranchTrueFalseTotal
if not $is_bytes or length $bytes < 1 or length $bytes > 255 1 268 269
Condition66%4/6
not $is_bytes or length $bytes < 1 or length $bytes > 255
l!l&&r!l&&!r
10268
not $is_bytes or length $bytes < 1
l!l&&r!l&&!r
10268
MC/DC33%1/3
not $is_bytes or length $bytes < 1 or length $bytes > 255
not $is_bytes length $bytes < 1 length $bytes > 255
Truth table50%2/4
not(A) or B or C
A= not $is_bytesB= length $bytes < 1C= length $bytes > 255
ABCresult
1XX1
01X1
0011
0000
47 if !$is_bytes || length($bytes) < 1 || length($bytes) > 255;
48 268 $wire .= pack('C', length($bytes)) . $bytes;
49 268 ▶ croak 'the encoded ALPN protocol list must not exceed 65535 bytes'
Branch: 1 branch
BranchTrueFalseTotal
if length $wire > 65535 1 267 268
50 if length($wire) > 65_535;
51 }
52 12 return $wire;
53 }
54  
55 77 ▶sub _timeout ($method, $name, $value, $default) {
Subroutine _timeout: called CC=8 SCAR=22.1
56 77 ▶ $value = $default if !defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 72 5 77
57 77 ▶ my $where = $method =~ /\s/ ? $method : "$method()";
Branch: 1 branch
BranchTrueFalseTotal
$method =~ /\s/u ? : 23 54 77
58 77 ▶ croak "$where: $name must be a non-negative number of seconds"
Branch: 1 branch
BranchTrueFalseTotal
if ref $value or not $value =~ /\A(?:\d+(?:\.\d*)?|\.\d+)\z/u or $value < 0 0 77 77
Condition33%2/6
ref $value or not $value =~ /\A(?:\d+(?:\.\d*)?|\.\d+)\z/u or $value < 0
l!l&&r!l&&!r
0077
ref $value or not $value =~ /\A(?:\d+(?:\.\d*)?|\.\d+)\z/u
l!l&&r!l&&!r
0077
MC/DC0%0/3
ref $value or not $value =~ /\A(?:\d+(?:\.\d*)?|\.\d+)\z/u or $value < 0
ref $value not $value =~ /\A(?:\d+(?:\.\d*)?|\.\d+)\z/u $value < 0
Truth table25%1/4
A or not(B) or C
A= ref $valueB= not $value =~ /\A(?:\d+(?:\.\d*)?|\.\d+)\z/uC= $value < 0
ABCresult
1XX1
01X1
0011
0000
59 if ref($value)
60 || $value !~ /\A(?:\d+(?:\.\d*)?|\.\d+)\z/
61 || $value < 0;
62 77 $value = 0 + $value;
63 77 ▶ croak "$where: $name must be a finite number of seconds"
Branch: 1 branch
BranchTrueFalseTotal
unless isfinite($value) 0 77 77
64 if !isfinite($value);
65 77 ▶ croak "$where: $name exceeds the supported timer range"
Branch: 1 branch
BranchTrueFalseTotal
if $value > 2147483647 1 76 77
66 if $value > 2_147_483_647;
67 76 return $value;
68 }
69  
70 134 ▶sub _optional_string ($target, $name, $value) {
Subroutine _optional_string: called CC=5 SCAR=16.7
71 134 ▶ return undef if !defined $value;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $value 62 72 134
72 72 ▶ croak "$target TLS $name must be a non-empty string without NUL bytes"
Branch: 1 branch
BranchTrueFalseTotal
if ref $value or $value eq "" or $value =~ /\0/u 2 70 72
Condition50%3/6
ref $value or $value eq "" or $value =~ /\0/u
l!l&&r!l&&!r
0270
ref $value or $value eq ""
l!l&&r!l&&!r
0072
MC/DC33%1/3
ref $value or $value eq "" or $value =~ /\0/u
ref $value $value eq "" $value =~ /\0/u
Truth table50%2/4
A or B or C
A= ref $valueB= $value eq ""C= $value =~ /\0/u
ABCresult
1XX1
01X1
0011
0000
73 if ref($value) || $value eq '' || $value =~ /\0/;
74 70 return "$value";
75 }
76  
77 27 ▶sub _server_name ($target, $value) {
Subroutine _server_name: called CC=6 SCAR=18.0
78 27 my $server_name = _optional_string($target, 'server_name', $value);
79 26 ▶ return undef if !defined $server_name;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $server_name 9 17 26
80 17 ▶ $server_name = substr($server_name, 1, length($server_name) - 2)
Branch: 1 branch
BranchTrueFalseTotal
if length $server_name >= 2 and substr($server_name, 0, 1) eq "[" and substr($server_name, -1, 1) eq "]" 1 16 17
Condition66%4/6
length $server_name >= 2 and substr($server_name, 0, 1) eq "[" and substr($server_name, -1, 1) eq "]"
!ll&&!rl&&r
1601
length $server_name >= 2 and substr($server_name, 0, 1) eq "["
!ll&&!rl&&r
0161
MC/DC33%1/3
length $server_name >= 2 and substr($server_name, 0, 1) eq "[" and substr($server_name, -1, 1) eq "]"
length $server_name >= 2 substr($server_name, 0, 1) eq "[" substr($server_name, -1, 1) eq "]"
Truth table50%2/4
A and B and C
A= length $server_name >= 2B= substr($server_name, 0, 1) eq "["C= substr($server_name, -1, 1) eq "]"
ABCresult
0XX0
10X0
1100
1111
81 if length($server_name) >= 2
82 && substr($server_name, 0, 1) eq '['
83 && substr($server_name, -1, 1) eq ']';
84 17 ▶ croak "$target TLS server_name must not be empty after removing brackets"
Branch: 1 branch
BranchTrueFalseTotal
if $server_name eq "" 1 16 17
85 if $server_name eq '';
86 16 return $server_name;
87 }
88  
89 12 ▶sub _build_declaration ($class, $target, @arg) {
Subroutine _build_declaration: called CC=7 SCAR=19.8
90 12 my %opt = @arg;
91 12 my @known = qw(
92 cert_file key_file server_name verify ca_file ca_path alpn
93 handshake_timeout shutdown_timeout
94 );
95 12 my %known = map { $_ => 1 } @known;
96 12 my @unknown = grep { !$known{$_} } keys %opt;
97 12 ▶ croak "$target TLS declaration has unknown options: "
Branch: 1 branch
BranchTrueFalseTotal
if @unknown 1 11 12
98 . join(', ', sort @unknown) if @unknown;
99  
100 my $cert_file = _optional_string(
101 $target, 'cert_file', delete $opt{cert_file},
102 11 );
103 my $key_file = _optional_string(
104 $target, 'key_file', delete $opt{key_file},
105 11 );
106 11 ▶ croak "$target TLS declaration requires cert_file and key_file together"
Branch: 1 branch
BranchTrueFalseTotal
if defined $cert_file != defined $key_file 1 10 11
107 if defined($cert_file) != defined($key_file);
108 10 my $server_name = _server_name($target, delete $opt{server_name});
109 my $ca_file = _optional_string(
110 $target, 'ca_file', delete $opt{ca_file},
111 9 );
112 my $ca_path = _optional_string(
113 $target, 'ca_path', delete $opt{ca_path},
114 9 );
115 9 ▶ my $verify = exists($opt{verify}) ? delete($opt{verify}) : 1;
Branch: 1 branch
BranchTrueFalseTotal
exists $opt{'verify'} ? : 0 9 9
116 9 ▶ croak "$target TLS verify must be 0 or 1"
Branch: 1 branch
BranchTrueFalseTotal
if ref $verify or not $verify =~ /\A[01]\z/u 0 9 9
Condition33%1/3
ref $verify or not $verify =~ /\A[01]\z/u
l!l&&r!l&&!r
009
MC/DC0%0/2
ref $verify or not $verify =~ /\A[01]\z/u
ref $verify not $verify =~ /\A[01]\z/u
Truth table33%1/3
A or not(B)
A= ref $verifyB= not $verify =~ /\A[01]\z/u
ABresult
1X1
011
000
117 if ref($verify) || $verify !~ /\A[01]\z/;
118  
119 return {
120 target => $target,
121 cert_file => $cert_file,
122 key_file => $key_file,
123 server_name => $server_name,
124 verify => $verify ? 1 : 0,
125 ca_file => $ca_file,
126 ca_path => $ca_path,
127 alpn_wire => _alpn_wire(delete $opt{alpn}),
128 handshake_timeout => _timeout(
129 "$target TLS declaration", 'handshake_timeout',
130 delete($opt{handshake_timeout}), 10,
131 ),
132 shutdown_timeout => _timeout(
133 "$target TLS declaration", 'shutdown_timeout',
134 9 ▶ delete($opt{shutdown_timeout}), 5,
Branch: 1 branch
BranchTrueFalseTotal
$verify ? : 9 0 9
135 ),
136 };
137 }
138  
139 0 ▶sub _validate_server_declaration ($class, $definition) {
Subroutine _validate_server_declaration: not called CC=2 SCAR=17.9
140 0 my $target = $definition->{target};
141 croak "$target is used for accepted TLS stream sockets but does not declare "
142 . 'cert_file and key_file'
143 0 ▶ if !defined($definition->{cert_file});
Branch: 1 branch
BranchTrueFalseTotal
unless defined $definition->{"cert_file"} 0 0 0
144 0 return;
145 }
146  
147 2 ▶sub _client_from_declaration ($class, $definition, $connect_host = undef) {
Subroutine _client_from_declaration: called CC=6 SCAR=21.4
148 2 my $target = $definition->{target};
149 2 ▶ my $server_name = $definition->{server_name} // $connect_host;
Condition33%1/3
$definition->{"server_name"} // $connect_host
l!l&&r!l&&!r
020
MC/DC0%0/2
$definition->{"server_name"} // $connect_host
$definition->{"server_name"} $connect_host
Truth table33%1/3
A // B
A= $definition->{"server_name"}B= $connect_host
ABresult
1X1
011
000
150 2 ▶ croak "$target TLS client requires server_name when connect() has no host"
Branch: 1 branch
BranchTrueFalseTotal
if not defined $server_name or ref $server_name or $server_name eq "" 0 2 2
Condition33%2/6
not defined $server_name or ref $server_name or $server_name eq ""
l!l&&r!l&&!r
002
not defined $server_name or ref $server_name
l!l&&r!l&&!r
002
MC/DC0%0/3
not defined $server_name or ref $server_name or $server_name eq ""
not defined $server_name ref $server_name $server_name eq ""
Truth table25%1/4
not(A) or B or C
A= not defined $server_nameB= ref $server_nameC= $server_name eq ""
ABCresult
1XX1
01X1
0011
0000
151 if !defined($server_name) || ref($server_name) || $server_name eq '';
152 2 $server_name = _server_name($target, $server_name);
153 return $class->_new_client(
154 $server_name,
155 $definition->{verify},
156 $definition->{ca_file},
157 $definition->{ca_path},
158 $definition->{alpn_wire},
159 $definition->{handshake_timeout},
160 $definition->{shutdown_timeout},
161 2 );
162 }
163  
164 0 ▶sub _server_from_declaration ($class, $definition) {
Subroutine _server_from_declaration: not called CC=1 SCAR=6.9
165 0 $class->_validate_server_declaration($definition);
166 return $class->_new_server(
167 $definition->{cert_file},
168 $definition->{key_file},
169 $definition->{alpn_wire},
170 $definition->{handshake_timeout},
171 $definition->{shutdown_timeout},
172 0 );
173 }
174  
175 5 ▶sub _class_tls_defaults ($stream_class) {
Subroutine _class_tls_defaults: called CC=5 SCAR=17.8
176 5 ▶ my $method = $stream_class->can('tls_defaults') or return {};
Branch: 1 branch
BranchTrueFalseTotal
my $method = $stream_class->can("tls_defaults") or return {} 2 3 5
177 2 my @value = $method->($stream_class);
178 2 my %option;
179 2 ▶ if (@value == 1 && ref($value[0]) eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (@value == 1 and ref $value[0] eq 'HASH') { } 0 2 2
Condition33%1/3
@value == 1 and ref $value[0] eq "HASH"
!ll&&!rl&&r
200
MC/DC0%0/2
@value == 1 and ref $value[0] eq "HASH"
@value == 1 ref $value[0] eq "HASH"
Truth table33%1/3
A and B
A= @value == 1B= ref $value[0] eq "HASH"
ABresult
0X0
100
111
180 0 %option = %{ $value[0] };
181 } else {
182 2 ▶ croak "$stream_class tls_defaults() returned an odd option list"
Branch: 1 branch
BranchTrueFalseTotal
if @value % 2 0 2 2
183 if @value % 2;
184 2 %option = @value;
185 }
186 2 return \%option;
187 }
188  
189 5 ▶sub _prepare_listener_server ($class, $stream_class, $recipe) {
Subroutine _prepare_listener_server: called CC=7 SCAR=20.0
190 5 ▶ croak 'Listener TLS recipe must be a hash reference'
Branch: 1 branch
BranchTrueFalseTotal
if defined $recipe and ref $recipe ne "HASH" 0 5 5
Condition33%1/3
defined $recipe and ref $recipe ne "HASH"
!ll&&!rl&&r
050
MC/DC0%0/2
defined $recipe and ref $recipe ne "HASH"
defined $recipe ref $recipe ne "HASH"
Truth table33%1/3
A and B
A= defined $recipeB= ref $recipe ne "HASH"
ABresult
0X0
100
111
191 if defined($recipe) && ref($recipe) ne 'HASH';
192 5 ▶ my %option = (%{ _class_tls_defaults($stream_class) }, %{ $recipe // {} });
Condition50%1/2
$recipe // {}
l!l
50
MC/DC0%0/1
$recipe // {}
$recipe
Truth table50%1/2
A
A= $recipe
Aresult
11
00
193  
194 5 my %known = map { $_ => 1 } qw(
195 cert_file key_file alpn handshake_timeout shutdown_timeout
196 );
197 5 my @unknown = grep { !$known{$_} } keys %option;
198 5 ▶ croak 'Listener TLS recipe has unknown options: '
Branch: 1 branch
BranchTrueFalseTotal
if @unknown 0 5 5
199 . join(', ', sort @unknown) if @unknown;
200  
201 my $cert_file = _optional_string(
202 "$stream_class Listener", 'cert_file', delete $option{cert_file},
203 5 );
204 my $key_file = _optional_string(
205 "$stream_class Listener", 'key_file', delete $option{key_file},
206 5 );
207 5 ▶ croak 'Listener TLS recipe requires cert_file and key_file together'
Branch: 1 branch
BranchTrueFalseTotal
if defined $cert_file != defined $key_file 0 5 5
208 if defined($cert_file) != defined($key_file);
209 5 ▶ croak 'Listener TLS recipe requires cert_file and key_file'
Branch: 1 branch
BranchTrueFalseTotal
unless defined $cert_file 1 4 5
210 if !defined $cert_file;
211 4 my $alpn = _alpn_wire(delete $option{alpn});
212 my $handshake_timeout = _timeout(
213 'Listener TLS', 'handshake_timeout',
214 4 delete($option{handshake_timeout}), 10,
215 );
216 my $shutdown_timeout = _timeout(
217 'Listener TLS', 'shutdown_timeout',
218 4 delete($option{shutdown_timeout}), 5,
219 );
220  
221 4 return $class->_new_server_template(
222 $cert_file, $key_file, $alpn,
223 $handshake_timeout, $shutdown_timeout,
224 );
225 }
226  
227 5 ▶sub _listener_server_connection ($class, $template) {
Subroutine _listener_server_connection: called CC=2 SCAR=7.2
228 5 ▶ return undef if !defined $template;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $template 0 5 5
229 5 return $template->_clone_server;
230 }
231  
232 16 ▶sub client ($class, %opt) {
Subroutine client: called CC=9 SCAR=22.7
Pod undocumented
233 16 ▶ croak 'client(): must be called as a class method' if ref $class;
Branch: 1 branch
BranchTrueFalseTotal
if ref $class 0 16 16
234 my $server_name = delete $opt{server_name}
235 16 ▶ // croak 'client(): missing server_name';
Condition50%1/2
delete $opt{"server_name"} // croak("client(): missing server_name")
l!l
160
MC/DC0%0/1
delete $opt{"server_name"} // croak("client(): missing server_name")
delete $opt{"server_name"}
Truth table50%1/2
A
A= delete $opt{"server_name"}
Aresult
11
00
236 16 ▶ my $verify = exists $opt{verify} ? delete($opt{verify}) : 1;
Branch: 1 branch
BranchTrueFalseTotal
exists $opt{'verify'} ? : 4 12 16
237 16 ▶ croak 'client(): verify must be 0 or 1'
Branch: 1 branch
BranchTrueFalseTotal
if not defined $verify or ref $verify or not $verify =~ /\A[01]\z/u 1 15 16
Condition50%3/6
not defined $verify or ref $verify or not $verify =~ /\A[01]\z/u
l!l&&r!l&&!r
0115
not defined $verify or ref $verify
l!l&&r!l&&!r
0016
MC/DC33%1/3
not defined $verify or ref $verify or not $verify =~ /\A[01]\z/u
not defined $verify ref $verify not $verify =~ /\A[01]\z/u
Truth table50%2/4
not(A) or B or not(C)
A= not defined $verifyB= ref $verifyC= not $verify =~ /\A[01]\z/u
ABCresult
1XX1
01X1
0011
0000
238 if !defined($verify) || ref($verify) || $verify !~ /\A[01]\z/;
239 15 $server_name = _server_name('client()', $server_name);
240 my $ca_file = _optional_string(
241 'client()', 'ca_file', delete $opt{ca_file},
242 14 );
243 my $ca_path = _optional_string(
244 'client()', 'ca_path', delete $opt{ca_path},
245 14 );
246 14 my $alpn = _alpn_wire(delete $opt{alpn});
247 my $handshake_timeout = _timeout(
248 13 'client', 'handshake_timeout', delete($opt{handshake_timeout}), 10,
249 );
250 my $shutdown_timeout = _timeout(
251 13 'client', 'shutdown_timeout', delete($opt{shutdown_timeout}), 5,
252 );
253 13 ▶ croak 'client(): unknown options: ' . join(', ', sort keys %opt) if %opt;
Branch: 1 branch
BranchTrueFalseTotal
if %opt 0 13 13
254 13 ▶ return $class->_new_client(
Branch: 1 branch
BranchTrueFalseTotal
$verify ? : 10 3 13
255 $server_name, $verify ? 1 : 0, $ca_file, $ca_path, $alpn,
256 $handshake_timeout, $shutdown_timeout,
257 );
258 }
259  
260 15 ▶sub server ($class, %opt) {
Subroutine server: called CC=5 SCAR=16.6
Pod undocumented
261 15 ▶ croak 'server(): must be called as a class method' if ref $class;
Branch: 1 branch
BranchTrueFalseTotal
if ref $class 0 15 15
262 my $cert_file = delete $opt{cert_file}
263 15 ▶ // croak 'server(): missing cert_file';
Condition50%1/2
delete $opt{"cert_file"} // croak("server(): missing cert_file")
l!l
150
MC/DC0%0/1
delete $opt{"cert_file"} // croak("server(): missing cert_file")
delete $opt{"cert_file"}
Truth table50%1/2
A
A= delete $opt{"cert_file"}
Aresult
11
00
264 my $key_file = delete $opt{key_file}
265 15 ▶ // croak 'server(): missing key_file';
Condition50%1/2
delete $opt{"key_file"} // croak("server(): missing key_file")
l!l
150
MC/DC0%0/1
delete $opt{"key_file"} // croak("server(): missing key_file")
delete $opt{"key_file"}
Truth table50%1/2
A
A= delete $opt{"key_file"}
Aresult
11
00
266 15 $cert_file = _optional_string('server()', 'cert_file', $cert_file);
267 14 $key_file = _optional_string('server()', 'key_file', $key_file);
268 14 my $alpn = _alpn_wire(delete $opt{alpn});
269 my $handshake_timeout = _timeout(
270 14 'server', 'handshake_timeout', delete($opt{handshake_timeout}), 10,
271 );
272 my $shutdown_timeout = _timeout(
273 14 'server', 'shutdown_timeout', delete($opt{shutdown_timeout}), 5,
274 );
275 14 ▶ croak 'server(): unknown options: ' . join(', ', sort keys %opt) if %opt;
Branch: 1 branch
BranchTrueFalseTotal
if %opt 0 14 14
276 14 return $class->_new_server(
277 $cert_file, $key_file, $alpn,
278 $handshake_timeout, $shutdown_timeout,
279 );
280 }
281  
282 25 ▶sub _stream_transport_bind ($self, $fd) {
Subroutine _stream_transport_bind: called CC=1 SCAR=0.0
283 25 return $self->_bind_fd($fd);
284 }
285  
286 28 ▶sub _install_deadline ($self, $stream, $operation) {
Subroutine _install_deadline: called CC=3 SCAR=11.0
287 28 my $fd = $self->_arm_deadline($operation);
288 28 ▶ return if !defined $fd;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $fd 1 27 28
289 27 ▶ return if $stream->_has_transport_deadline_watcher;
Branch: 1 branch
BranchTrueFalseTotal
if $stream->_has_transport_deadline_watcher 2 25 27
290 25 my $watcher = $stream->loop->watch(
291 fd => $fd,
292 _internal => 1,
293 data => {
294 provider => $self,
295 stream => $stream,
296 },
297 read => \&_deadline_ready,
298 );
299 25 $stream->_set_transport_deadline_watcher($watcher);
300 25 return;
301 }
302  
303 3 ▶sub _deadline_ready ($watcher) {
Subroutine _deadline_ready: called CC=1 SCAR=0.0
304 3 my $state = $watcher->data;
305 3 my $stream = $state->{stream};
306 3 my $operation = $state->{provider}->_deadline_operation;
307 3 my $message = $state->{provider}->_consume_deadline($operation);
308 3 $stream->_transport_deadline_expired($operation, $message);
309 3 return;
310 }
311  
312 25 ▶sub _stream_transport_start ($self, $stream) {
Subroutine _stream_transport_start: called CC=1 SCAR=0.0
313 25 $self->_install_deadline($stream, 'handshake');
314 }
315  
316 20 ▶sub _stream_transport_ready ($self, $stream) {
Subroutine _stream_transport_ready: called CC=1 SCAR=0.0
317 20 $stream->_clear_transport_deadline;
318 }
319  
320 3 ▶sub _stream_transport_begin_shutdown ($self, $stream) {
Subroutine _stream_transport_begin_shutdown: called CC=1 SCAR=0.0
321 3 $self->_install_deadline($stream, 'shutdown');
322 }
323  
324 22 ▶sub _stream_transport_cancel_deadline ($self) {
Subroutine _stream_transport_cancel_deadline: called CC=1 SCAR=0.0
325 22 $self->_cancel_deadline;
326 }
327  
328 25 ▶sub _stream_transport_close_deadline ($self) {
Subroutine _stream_transport_close_deadline: called CC=1 SCAR=0.0
329 25 $self->_close_deadline;
330 }
331  
332 13 1;
333  
334 __END__
« blib/lib/Linux/Event/Kernel/Timer.pm ↑ Summary blib/lib/Linux/Event/Framer/Varint.pm »