| 1 | package Linux::Event::_Socket::Descriptor; | ||||||||||||||||||||||||||||
| 2 | 120 | ▶ | use v5.36; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 120 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 120 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 120 | ▶ | use Carp qw(croak); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 120 | ▶ | use mro (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 120 | ▶ | use Linux::Event::_SocketConfig (); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 120 | my %TLS_DEFINITION; | |||||||||||||||||||||||||||
| 12 | my %CLASS_DESCRIPTOR; | ||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 7 | ▶ | sub declare_tls ($base, $target, $definition) { | ||||||||||||||||||||||||||
|
Subroutine
declare_tls: called CC=6 SCAR=19.3
Pod
undocumented
| |||||||||||||||||||||||||||||
| 15 | 7 | ▶ | croak 'TLS may be declared only for a Linux::Event stream-socket subclass' | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$target eq $base or not $target->isa($base)
MC/DC0%0/2
$target eq $base or not $target->isa($base)
$target eq $base
not $target->isa($base)
Truth table33%1/3
A or not(B)
A= $target eq $baseB= not $target->isa($base)
| |||||||||||||||||||||||||||||
| 16 | if $target eq $base || !$target->isa($base); | ||||||||||||||||||||||||||||
| 17 | croak "$target already has a stream-socket descriptor" | ||||||||||||||||||||||||||||
| 18 | 7 | ▶ | if exists $CLASS_DESCRIPTOR{$target}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 19 | 7 | ▶ | croak "$target already declares TLS" if exists $TLS_DEFINITION{$target}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 20 | 6 | ▶ | croak 'TLS declaration must be a hash reference' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 21 | if ref($definition) ne 'HASH'; | ||||||||||||||||||||||||||||
| 22 | 6 | $TLS_DEFINITION{$target} = $definition; | |||||||||||||||||||||||||||
| 23 | 6 | return; | |||||||||||||||||||||||||||
| 24 | } | ||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 258 | ▶ | sub _tls_for ($class) { | ||||||||||||||||||||||||||
|
Subroutine
_tls_for: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||
| 27 | 258 | for my $package (@{ mro::get_linear_isa($class) }) { | |||||||||||||||||||||||||||
| 28 | 1319 | ▶ | return $TLS_DEFINITION{$package} if exists $TLS_DEFINITION{$package}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | 255 | return undef; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 103161 | ▶ | sub for_class ($class) { | ||||||||||||||||||||||||||
|
Subroutine
for_class: called CC=11 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 34 | 103161 | ▶ | return $CLASS_DESCRIPTOR{$class} if exists $CLASS_DESCRIPTOR{$class}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 260 | ▶ | croak 'Linux::Event::_Socket::Stream is a private implementation base; subclass Linux::Event::IO::Sock::Stream' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | if $class eq 'Linux::Event::_Socket::Stream'; | ||||||||||||||||||||||||||||
| 37 | 259 | ▶ | croak "$class is not a Linux::Event stream-socket class" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 38 | if !$class->isa('Linux::Event::_Socket::Stream'); | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 259 | my %option = map { $_ => undef } Linux::Event::_SocketConfig::names(); | |||||||||||||||||||||||||||
| 41 | 259 | ▶ | if (my $configure = $class->can('socket_options')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | 5 | my @configured = $configure->($class); | |||||||||||||||||||||||||||
| 43 | 5 | my %configured; | |||||||||||||||||||||||||||
| 44 | 5 | ▶ | if (@configured == 1 && ref($configured[0]) eq 'HASH') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@configured == 1 and ref $configured[0] eq "HASH"
MC/DC0%0/2
@configured == 1 and ref $configured[0] eq "HASH"
@configured == 1
ref $configured[0] eq "HASH"
Truth table33%1/3
A and B
A= @configured == 1B= ref $configured[0] eq "HASH"
| |||||||||||||||||||||||||||||
| 45 | 0 | %configured = %{ $configured[0] }; | |||||||||||||||||||||||||||
| 46 | } else { | ||||||||||||||||||||||||||||
| 47 | 5 | ▶ | croak "$class socket_options() returned an odd option list" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | if @configured % 2; | ||||||||||||||||||||||||||||
| 49 | 5 | %configured = @configured; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | 5 | my @unknown = grep { !exists $option{$_} } keys %configured; | |||||||||||||||||||||||||||
| 52 | 5 | ▶ | croak "$class socket_options() returned unknown options: " | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 53 | . join(', ', sort @unknown) if @unknown; | ||||||||||||||||||||||||||||
| 54 | 5 | @option{keys %configured} = values %configured; | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | 259 | for my $name (keys %option) { | |||||||||||||||||||||||||||
| 57 | 2070 | ▶ | if (defined $option{$name}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | $option{$name} = Linux::Event::_SocketConfig::normalize( | ||||||||||||||||||||||||||||
| 59 | 11 | $class, $name, $option{$name}, | |||||||||||||||||||||||||||
| 60 | ); | ||||||||||||||||||||||||||||
| 61 | } else { | ||||||||||||||||||||||||||||
| 62 | 2059 | delete $option{$name}; | |||||||||||||||||||||||||||
| 63 | } | ||||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | 258 | return $CLASS_DESCRIPTOR{$class} = { | |||||||||||||||||||||||||||
| 66 | options => \%option, | ||||||||||||||||||||||||||||
| 67 | tls => _tls_for($class), | ||||||||||||||||||||||||||||
| 68 | configure_socket => scalar $class->can('configure_socket'), | ||||||||||||||||||||||||||||
| 69 | }; | ||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | 0 | ▶ | sub clear_cache () { %CLASS_DESCRIPTOR = (); return } | ||||||||||||||||||||||||||
|
Subroutine
clear_cache: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 120 | 1; | |||||||||||||||||||||||||||