blib/lib/IO/Socket/Forwarder.pm

filter: Statementstmt 12.4% 23 / 185 Branchbran 0.0% 0 / 190 Conditioncond 0.0% 0 / 121 MC/DCmcdc 0.0% 0 / 68 Subroutinesub 50.0% 6 / 12 Podpod 100% 1 / 1 totaltotal 5.2% 30 / 577 CC 140 SCAR 97.9
CC
140
Cov
5%
forward_sockets
19460.0
_min
6.0
_debug
2.0
CRAP 17913.7
↑ Summary
1 package IO::Socket::Forwarder;
2  
3 1 our $VERSION = '0.02';
4  
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 1 ▶use Fcntl qw(F_GETFL F_SETFL O_NONBLOCK);
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 1 require Exporter;
12 1 our @ISA = qw(Exporter);
13 1 our @EXPORT_OK = qw(forward_sockets);
14  
15 1 ▶use constant _default_io_buffer_size => 64 * 1024;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 1 ▶use constant _default_io_chunk_size => 16 * 1024;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 0 ▶sub _debug {
Subroutine _debug: not called CC=1 SCAR=6.9
19 0 require Time::HiRes;
20 0 my $time = Time::HiRes::time();
21 0 my @date = localtime $time;
22 0 my $out = "@_";
23 0 $out =~ s/([^ -~])/sprintf("\\x%02x", ord $1)/ge;
24 0 warn sprintf("%02d:%02d:%02d.%03d: %s\n",
25 @date[2, 1, 0], 1000 * ($time - int $time), $out);
26 }
27  
28 # lazy accessors to IO::Socket::SSL
29 # we use it but don't depend on it!
30 0 ▶sub _ssl_error { $IO::Socket::SSL::SSL_ERROR }
Subroutine _ssl_error: not called CC=1 SCAR=6.9
31 0 ▶sub _ssl_want_read { IO::Socket::SSL::SSL_WANT_READ() }
Subroutine _ssl_want_read: not called CC=1 SCAR=6.9
32 0 ▶sub _ssl_want_write { IO::Socket::SSL::SSL_WANT_WRITE() }
Subroutine _ssl_want_write: not called CC=1 SCAR=6.9
33  
34 0 ▶sub _min { $_[0] < $_[1] ? $_[0] : $_[1] }
Subroutine _min: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
$_[0] < $_[1] ? : 0 0 0
35  
36 0 ▶sub forward_sockets {
Subroutine forward_sockets: not called CC=139 SCAR=98.8
Pod documented
37 0 my ($s1, $s2, %opts) = @_;
38  
39 0 my $debug = delete $opts{debug};
40 0 ▶ $debug = $IO::Socket::Forwarder::debug unless defined $debug;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $debug 0 0 0
41  
42 0 ▶ my $io_buffer_size = delete $opts{io_buffer_size} || _default_io_buffer_size;
Condition0%0/2
delete $opts{'io_buffer_size'} || 65536
l!l
00
MC/DC0%0/1
delete $opts{'io_buffer_size'} || 65536
delete $opts{'io_buffer_size'}
Truth table0%0/2
A
A= delete $opts{'io_buffer_size'}
Aresult
11
00
43 0 ▶ my $io_chunk_size = delete $opts{io_chunk_size} || _default_io_chunk_size;
Condition0%0/2
delete $opts{'io_chunk_size'} || 16384
l!l
00
MC/DC0%0/1
delete $opts{'io_chunk_size'} || 16384
delete $opts{'io_chunk_size'}
Truth table0%0/2
A
A= delete $opts{'io_chunk_size'}
Aresult
11
00
44  
45 0 my $fn1 = fileno $s1;
46 0 ▶ defined $fn1 or croak "socket 1 is not a valid file handle";
Branch: 1 branch
BranchTrueFalseTotal
defined $fn1 or croak("socket 1 is not a valid file handle") 0 0 0
47 0 my $fn2 = fileno $s2;
48 0 ▶ defined $fn1 or croak "socket 2 is not a valid file handle";
Branch: 1 branch
BranchTrueFalseTotal
defined $fn1 or croak("socket 2 is not a valid file handle") 0 0 0
49  
50 0 my $ssl1 = $s1->isa('IO::Socket::SSL');
51 0 my $ssl2 = $s2->isa('IO::Socket::SSL');
52  
53 0 ▶ $debug and _debug "s1 fn=$fn1, ssl=$ssl1";
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug("s1 fn=$fn1, ssl=$ssl1") 0 0 0
54 0 ▶ $debug and _debug "s2 fn=$fn2, ssl=$ssl2";
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug("s2 fn=$fn2, ssl=$ssl2") 0 0 0
55  
56 0 ▶ my $b1to2 = delete $opts{buffer_1to2} // '';
Condition0%0/2
delete $opts{"buffer_1to2"} // ""
l!l
00
MC/DC0%0/1
delete $opts{"buffer_1to2"} // ""
delete $opts{"buffer_1to2"}
Truth table0%0/2
A
A= delete $opts{"buffer_1to2"}
Aresult
11
00
57 0 ▶ my $b2to1 = delete $opts{buffer_2to1} // '';
Condition0%0/2
delete $opts{"buffer_2to1"} // ""
l!l
00
MC/DC0%0/1
delete $opts{"buffer_2to1"} // ""
delete $opts{"buffer_2to1"}
Truth table0%0/2
A
A= delete $opts{"buffer_2to1"}
Aresult
11
00
58  
59 0 ▶ if ($debug) {
Branch: 1 branch
BranchTrueFalseTotal
if ($debug) 0 0 0
60 0 _debug "b1to2: $b1to2";
61 0 _debug "b2to1: $b2to1";
62 }
63  
64 0 my ($write_chunk_size1, $write_chunk_size2) = ($io_chunk_size, $io_chunk_size);
65  
66 0 my ($s1_in_closed, $s2_in_closed,
67 $s1_out_closed, $s2_out_closed,
68 $ssl_wtr1, $ssl_wtw1, $ssl_wtr2, $ssl_wtw2,
69 %close);
70  
71 0 ▶ unless ($^O =~ /Win32/) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($^O =~ /Win32/) 0 0 0
72 0 ▶ fcntl($s1, F_SETFL, fcntl($s1, F_GETFL, 0) | O_NONBLOCK)
Branch: 1 branch
BranchTrueFalseTotal
fcntl $s1, 4, fcntl($s1, 3, 0) | 2048 or croak("unable to make socket 1 non-blocking") 0 0 0
73 or croak "unable to make socket 1 non-blocking";
74 0 ▶ fcntl($s2, F_SETFL, fcntl($s2, F_GETFL, 0) | O_NONBLOCK)
Branch: 1 branch
BranchTrueFalseTotal
fcntl $s2, 4, fcntl($s2, 3, 0) | 2048 or croak("unable to make socket 2 non-blocking") 0 0 0
75 or croak "unable to make socket 2 non-blocking";
76 }
77  
78 0 if (0 and $debug) {
79 _debug "delaying...";
80 sleep 5;
81 _debug "starting...";
82 }
83  
84 0 while (1) {
85 0 ▶ my $wtr1 = (not $s1_in_closed and length $b1to2 < $io_buffer_size);
Condition0%0/3
!$s1_in_closed && length $b1to2 < $io_buffer_size
!ll&&!rl&&r
000
MC/DC0%0/2
!$s1_in_closed && length $b1to2 < $io_buffer_size
!$s1_in_closed length $b1to2 < $io_buffer_size
Truth table0%0/3
not(A) && B
A= !$s1_in_closedB= length $b1to2 < $io_buffer_size
ABresult
0X0
100
111
86 0 ▶ if ($ssl1 and $wtr1 and $s1->pending) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ssl1 and $wtr1 and $s1->pending) 0 0 0
Condition0%0/6
$ssl1 and $wtr1 and $s1->pending
!ll&&!rl&&r
000
$ssl1 and $wtr1
!ll&&!rl&&r
000
MC/DC0%0/3
$ssl1 and $wtr1 and $s1->pending
$ssl1 $wtr1 $s1->pending
Truth table0%0/4
A and B and C
A= $ssl1B= $wtr1C= $s1->pending
ABCresult
0XX0
10X0
1100
1111
87 0 ▶ sysread($s1, $b1to2, _min($s1->pending, $io_buffer_size), length $b1to2)
Branch: 1 branch
BranchTrueFalseTotal
sysread $s1, $b1to2, _min($s1->pending, $io_buffer_size), length $b1to2 and redo 0 0 0
88 and redo;
89 }
90  
91 0 ▶ my $wtr2 = (not $s2_in_closed and length $b2to1 < $io_buffer_size);
Condition0%0/3
!$s2_in_closed && length $b2to1 < $io_buffer_size
!ll&&!rl&&r
000
MC/DC0%0/2
!$s2_in_closed && length $b2to1 < $io_buffer_size
!$s2_in_closed length $b2to1 < $io_buffer_size
Truth table0%0/3
not(A) && B
A= !$s2_in_closedB= length $b2to1 < $io_buffer_size
ABresult
0X0
100
111
92 0 ▶ if ($ssl2 and $wtr2 and $s2->pending) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ssl2 and $wtr2 and $s2->pending) 0 0 0
Condition0%0/6
$ssl2 and $wtr2 and $s2->pending
!ll&&!rl&&r
000
$ssl2 and $wtr2
!ll&&!rl&&r
000
MC/DC0%0/3
$ssl2 and $wtr2 and $s2->pending
$ssl2 $wtr2 $s2->pending
Truth table0%0/4
A and B and C
A= $ssl2B= $wtr2C= $s2->pending
ABCresult
0XX0
10X0
1100
1111
93 0 ▶ sysread($s2, $b2to1, _min($s2->pending, $io_buffer_size), length $b2to1)
Branch: 1 branch
BranchTrueFalseTotal
sysread $s2, $b2to1, _min($s2->pending, $io_buffer_size), length $b2to1 and redo 0 0 0
94 and redo;
95 }
96  
97 0 ▶ my $wtw1 = (not $s1_out_closed and length $b2to1);
Condition0%0/3
!$s1_out_closed && length $b2to1
!ll&&!rl&&r
000
MC/DC0%0/2
!$s1_out_closed && length $b2to1
!$s1_out_closed length $b2to1
Truth table0%0/3
not(A) && B
A= !$s1_out_closedB= length $b2to1
ABresult
0X0
100
111
98 0 ▶ my $wtw2 = (not $s2_out_closed and length $b1to2);
Condition0%0/3
!$s2_out_closed && length $b1to2
!ll&&!rl&&r
000
MC/DC0%0/2
!$s2_out_closed && length $b1to2
!$s2_out_closed length $b1to2
Truth table0%0/3
not(A) && B
A= !$s2_out_closedB= length $b1to2
ABresult
0X0
100
111
99  
100 0 ▶ $debug and _debug "wtr1: $wtr1, wtr2: $wtr2, wtw1: $wtw1, wtw2: $wtw2";
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug("wtr1: $wtr1, wtr2: $wtr2, wtw1: $wtw1, wtw2: $wtw2") 0 0 0
101  
102 0 ▶ unless ($wtr1 or $wtr2 or $wtw1 or $wtw2) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($wtr1 or $wtr2 or $wtw1 or $wtw2) 0 0 0
Condition0%0/9
$wtr1 or $wtr2 or $wtw1 or $wtw2
l!l&&r!l&&!r
000
$wtr1 or $wtr2 or $wtw1
l!l&&r!l&&!r
000
$wtr1 or $wtr2
l!l&&r!l&&!r
000
MC/DC0%0/4
$wtr1 or $wtr2 or $wtw1 or $wtw2
$wtr1 $wtr2 $wtw1 $wtw2
Truth table0%0/5
A or B or C or D
A= $wtr1B= $wtr2C= $wtw1D= $wtw2
ABCDresult
1XXX1
01XX1
001X1
00011
00000
103 0 ▶ $debug and _debug "nothing else to do, exiting...";
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug("nothing else to do, exiting...") 0 0 0
104 0 last;
105 }
106  
107  
108  
109 0 my $bitsr = '';
110 0 ▶ vec($bitsr, $fn1, 1) = 1 if (($wtr1 && !$ssl_wtw1) || $ssl_wtr1);
Branch: 1 branch
BranchTrueFalseTotal
if $wtr1 and not $ssl_wtw1 or $ssl_wtr1 0 0 0
Condition0%0/6
$wtr1 and not $ssl_wtw1 or $ssl_wtr1
l!l&&r!l&&!r
000
$wtr1 and not $ssl_wtw1
!ll&&!rl&&r
000
MC/DC0%0/3
$wtr1 and not $ssl_wtw1 or $ssl_wtr1
$wtr1 not $ssl_wtw1 $ssl_wtr1
Truth table0%0/5
A and not(B) or C
A= $wtr1B= not $ssl_wtw1C= $ssl_wtr1
ABCresult
11X1
0X11
1011
0X00
1000
111 0 ▶ vec($bitsr, $fn2, 1) = 1 if (($wtr2 && !$ssl_wtw2) || $ssl_wtr2);
Branch: 1 branch
BranchTrueFalseTotal
if $wtr2 and not $ssl_wtw2 or $ssl_wtr2 0 0 0
Condition0%0/6
$wtr2 and not $ssl_wtw2 or $ssl_wtr2
l!l&&r!l&&!r
000
$wtr2 and not $ssl_wtw2
!ll&&!rl&&r
000
MC/DC0%0/3
$wtr2 and not $ssl_wtw2 or $ssl_wtr2
$wtr2 not $ssl_wtw2 $ssl_wtr2
Truth table0%0/5
A and not(B) or C
A= $wtr2B= not $ssl_wtw2C= $ssl_wtr2
ABCresult
11X1
0X11
1011
0X00
1000
112 0 my $bitsw = '';
113 0 ▶ vec($bitsw, $fn1, 1) = 1 if (($wtw1 && !$ssl_wtr1) || $ssl_wtw1);
Branch: 1 branch
BranchTrueFalseTotal
if $wtw1 and not $ssl_wtr1 or $ssl_wtw1 0 0 0
Condition0%0/6
$wtw1 and not $ssl_wtr1 or $ssl_wtw1
l!l&&r!l&&!r
000
$wtw1 and not $ssl_wtr1
!ll&&!rl&&r
000
MC/DC0%0/3
$wtw1 and not $ssl_wtr1 or $ssl_wtw1
$wtw1 not $ssl_wtr1 $ssl_wtw1
Truth table0%0/5
A and not(B) or C
A= $wtw1B= not $ssl_wtr1C= $ssl_wtw1
ABCresult
11X1
0X11
1011
0X00
1000
114 0 ▶ vec($bitsw, $fn2, 1) = 1 if (($wtw2 && !$ssl_wtr2) || $ssl_wtw2);
Branch: 1 branch
BranchTrueFalseTotal
if $wtw2 and not $ssl_wtr2 or $ssl_wtw2 0 0 0
Condition0%0/6
$wtw2 and not $ssl_wtr2 or $ssl_wtw2
l!l&&r!l&&!r
000
$wtw2 and not $ssl_wtr2
!ll&&!rl&&r
000
MC/DC0%0/3
$wtw2 and not $ssl_wtr2 or $ssl_wtw2
$wtw2 not $ssl_wtr2 $ssl_wtw2
Truth table0%0/5
A and not(B) or C
A= $wtw2B= not $ssl_wtr2C= $ssl_wtw2
ABCresult
11X1
0X11
1011
0X00
1000
115  
116 0 ▶ $debug and _debug "calling select('$bitsr', '$bitsw')...";
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug("calling select('${bitsr}', '${bitsw}')...") 0 0 0
117  
118 0 my $n = select($bitsr, $bitsw, undef, undef);
119  
120 0 ▶ $debug and _debug "select done, n: $n";
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug("select done, n: $n") 0 0 0
121  
122 0 ▶ if ($n > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($n > 0) 0 0 0
123 0 ▶ if ($wtr1 and vec(($ssl_wtw1 ? $bitsw : $bitsr), $fn1, 1)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($wtr1 and vec $ssl_wtw1 ? $bitsw : $bitsr, $fn1, 1) 0 0 0
$ssl_wtw1 ? : 0 0 0
Condition0%0/3
$wtr1 and vec $ssl_wtw1 ? $bitsw : $bitsr, $fn1, 1
!ll&&!rl&&r
000
MC/DC0%0/2
$wtr1 and vec $ssl_wtw1 ? $bitsw : $bitsr, $fn1, 1
$wtr1 vec $ssl_wtw1 ? $bitsw : $bitsr, $fn1, 1
Truth table0%0/3
A and B
A= $wtr1B= vec $ssl_wtw1 ? $bitsw : $bitsr, $fn1, 1
ABresult
0X0
100
111
124 0 ▶ $debug and _debug "reading from s1...";
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug("reading from s1...") 0 0 0
125 0 my $bytes = sysread($s1, $b1to2, $io_chunk_size, length $b1to2);
126 0 ▶ $debug and _debug "bytes: " . ($bytes // '<undef>');
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug('bytes: ' . ($bytes // "<undef>")) 0 0 0
Condition0%0/2
$bytes // "<undef>"
l!l
00
MC/DC0%0/1
$bytes // "<undef>"
$bytes
Truth table0%0/2
A
A= $bytes
Aresult
11
00
127 0 ▶ if ($bytes) {
Branch: 3 branches
BranchTrueFalseTotal
if ($bytes) { } 0 0 0
elsif ($ssl1 and not defined $bytes) { } 0 0 0
elsif ($ssl_wtw1) { } 0 0 0
128 0 undef $ssl_wtw1;
129 0 ▶ $debug and _debug "s1 read: " . substr($b1to2, -$bytes);
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug('s1 read: ' . substr($b1to2, -$bytes)) 0 0 0
130 }
131 ▶ elsif ($ssl1 and not defined $bytes) {
Condition0%0/3
$ssl1 and not defined $bytes
!ll&&!rl&&r
000
MC/DC0%0/2
$ssl1 and not defined $bytes
$ssl1 not defined $bytes
Truth table0%0/3
A and not(B)
A= $ssl1B= not defined $bytes
ABresult
0X0
100
111
132 0 ▶ if (_ssl_error == _ssl_want_write) {
Branch: 2 branches
BranchTrueFalseTotal
if (_ssl_error() == _ssl_want_write()) { } 0 0 0
elsif (_ssl_error() == _ssl_want_read()) { } 0 0 0
133 0 $ssl_wtw1 = 1;
134 0 ▶ $debug and _debug "s1 wants to write for SSL";
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug("s1 wants to write for SSL") 0 0 0
135 }
136 elsif (_ssl_error == _ssl_want_read) {
137 0 ▶ $debug and _debug "s1 wants to read more for SSL";
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug("s1 wants to read more for SSL") 0 0 0
138 }
139 else {
140 0 _debug "unexpected SSL error " . _ssl_error;
141 0 $close{slin} = 1;
142 }
143 }
144 elsif ($ssl_wtw1) {
145 0 undef $ssl_wtw1;
146 }
147 else {
148 0 ▶ $debug and _debug "nothing read from s1, closing schedulled";
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug("nothing read from s1, closing schedulled") 0 0 0
149 0 $close{s1in} = 1;
150 }
151 }
152 0 ▶ if ($wtr2 and vec(($ssl_wtw2 ? $bitsw : $bitsr), $fn2, 1)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($wtr2 and vec $ssl_wtw2 ? $bitsw : $bitsr, $fn2, 1) 0 0 0
$ssl_wtw2 ? : 0 0 0
Condition0%0/3
$wtr2 and vec $ssl_wtw2 ? $bitsw : $bitsr, $fn2, 1
!ll&&!rl&&r
000
MC/DC0%0/2
$wtr2 and vec $ssl_wtw2 ? $bitsw : $bitsr, $fn2, 1
$wtr2 vec $ssl_wtw2 ? $bitsw : $bitsr, $fn2, 1
Truth table0%0/3
A and B
A= $wtr2B= vec $ssl_wtw2 ? $bitsw : $bitsr, $fn2, 1
ABresult
0X0
100
111
153 0 ▶ $debug and _debug "reading from s2...";
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug("reading from s2...") 0 0 0
154 0 my $bytes = sysread($s2, $b2to1, $io_chunk_size, length $b2to1);
155 0 ▶ $debug and _debug "bytes: " . ($bytes // '<undef>');
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug('bytes: ' . ($bytes // "<undef>")) 0 0 0
Condition0%0/2
$bytes // "<undef>"
l!l
00
MC/DC0%0/1
$bytes // "<undef>"
$bytes
Truth table0%0/2
A
A= $bytes
Aresult
11
00
156 0 ▶ if ($bytes) {
Branch: 3 branches
BranchTrueFalseTotal
if ($bytes) { } 0 0 0
elsif ($ssl2 and not defined $bytes) { } 0 0 0
elsif ($ssl_wtw2) { } 0 0 0
157 0 undef $ssl_wtw2;
158 0 ▶ $debug and _debug "s2 read: " . substr($b2to1, -$bytes);
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug('s2 read: ' . substr($b2to1, -$bytes)) 0 0 0
159 }
160 ▶ elsif ($ssl2 and not defined $bytes) {
Condition0%0/3
$ssl2 and not defined $bytes
!ll&&!rl&&r
000
MC/DC0%0/2
$ssl2 and not defined $bytes
$ssl2 not defined $bytes
Truth table0%0/3
A and not(B)
A= $ssl2B= not defined $bytes
ABresult
0X0
100
111
161 0 ▶ if (_ssl_error == _ssl_want_write) {
Branch: 2 branches
BranchTrueFalseTotal
if (_ssl_error() == _ssl_want_write()) { } 0 0 0
elsif (_ssl_error() == _ssl_want_read()) { } 0 0 0
162 0 $ssl_wtw2 = 1;
163 0 ▶ $debug and _debug "s2 wants to write for SSL";
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug("s2 wants to write for SSL") 0 0 0
164 }
165 elsif (_ssl_error == _ssl_want_read) {
166 0 ▶ $debug and _debug "s2 wants to read more for SSL";
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug("s2 wants to read more for SSL") 0 0 0
167 }
168 else {
169 0 _debug "unexpected SSL error " . _ssl_error;
170 }
171 }
172 elsif ($ssl_wtw2) {
173 0 undef $ssl_wtw2;
174 }
175 else {
176 0 ▶ $debug and _debug "nothing read from s2, closing schedulled";
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug("nothing read from s2, closing schedulled") 0 0 0
177 0 $close{s2in} = 1;
178 }
179 }
180 0 ▶ if ($wtw1 and vec(($ssl_wtr1 ? $bitsr : $bitsw), $fn1, 1)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($wtw1 and vec $ssl_wtr1 ? $bitsr : $bitsw, $fn1, 1) 0 0 0
$ssl_wtr1 ? : 0 0 0
Condition0%0/3
$wtw1 and vec $ssl_wtr1 ? $bitsr : $bitsw, $fn1, 1
!ll&&!rl&&r
000
MC/DC0%0/2
$wtw1 and vec $ssl_wtr1 ? $bitsr : $bitsw, $fn1, 1
$wtw1 vec $ssl_wtr1 ? $bitsr : $bitsw, $fn1, 1
Truth table0%0/3
A and B
A= $wtw1B= vec $ssl_wtr1 ? $bitsr : $bitsw, $fn1, 1
ABresult
0X0
100
111
181 0 ▶ $debug and _debug "writting to s1...";
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug("writting to s1...") 0 0 0
182 0 my $bytes = syswrite($s1, $b2to1, $io_chunk_size);
183 0 ▶ $debug and _debug "bytes: " . ($bytes // '<undef>');
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug('bytes: ' . ($bytes // "<undef>")) 0 0 0
Condition0%0/2
$bytes // "<undef>"
l!l
00
MC/DC0%0/1
$bytes // "<undef>"
$bytes
Truth table0%0/2
A
A= $bytes
Aresult
11
00
184 0 ▶ if ($bytes) {
Branch: 2 branches
BranchTrueFalseTotal
if ($bytes) { } 0 0 0
elsif ($ssl1 and not defined $bytes) { } 0 0 0
185 0 ▶ $debug and _debug "s1 wrote: " . substr($b2to1, 0, $bytes);
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug('s1 wrote: ' . substr($b2to1, 0, $bytes)) 0 0 0
186 0 substr($b2to1, 0, $bytes, "");
187 0 ▶ if ($s2_in_closed and !length $b2to1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s2_in_closed and not length $b2to1) 0 0 0
Condition0%0/3
$s2_in_closed and not length $b2to1
!ll&&!rl&&r
000
MC/DC0%0/2
$s2_in_closed and not length $b2to1
$s2_in_closed not length $b2to1
Truth table0%0/3
A and not(B)
A= $s2_in_closedB= not length $b2to1
ABresult
0X0
100
111
188 0 ▶ $debug and _debug "buffer exhausted and s2-in is closed, shutting down s1-out";
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug("buffer exhausted and s2-in is closed, shutting down s1-out") 0 0 0
189 0 ▶ shutdown($s1, 1) unless $ssl1;
Branch: 1 branch
BranchTrueFalseTotal
unless $ssl1 0 0 0
190 0 $s1_out_closed = 1;
191 }
192 0 $write_chunk_size1 = $io_chunk_size;
193 0 undef $ssl_wtr1;
194 }
195 ▶ elsif ($ssl1 and not defined $bytes) {
Condition0%0/3
$ssl1 and not defined $bytes
!ll&&!rl&&r
000
MC/DC0%0/2
$ssl1 and not defined $bytes
$ssl1 not defined $bytes
Truth table0%0/3
A and not(B)
A= $ssl1B= not defined $bytes
ABresult
0X0
100
111
196 0 ▶ if (_ssl_error == _ssl_want_read) {
Branch: 2 branches
BranchTrueFalseTotal
if (_ssl_error() == _ssl_want_read()) { } 0 0 0
elsif (_ssl_error() == _ssl_want_write()) { } 0 0 0
197 0 $ssl_wtr1 = 1;
198 0 ▶ $debug and _debug "s1 wants to read for SSL";
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug("s1 wants to read for SSL") 0 0 0
199 }
200 elsif (_ssl_error == _ssl_want_write) {
201 0 ▶ $write_chunk_size1 = length $b2to1 if length $b2to1 < $write_chunk_size1;
Branch: 1 branch
BranchTrueFalseTotal
if length $b2to1 < $write_chunk_size1 0 0 0
202 0 ▶ $debug and _debug "s1 wants to write more for SSL, wcs1: $write_chunk_size1";
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug("s1 wants to write more for SSL, wcs1: $write_chunk_size1") 0 0 0
203 }
204 else {
205 0 _debug "unexpected SSL error " . _ssl_error;
206 0 $close{s1out} = 1;
207 }
208 }
209 else {
210 0 ▶ $debug and _debug "nothing written to s1, closing schedulled";
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug("nothing written to s1, closing schedulled") 0 0 0
211 0 $close{s1out} = 1;
212 }
213 }
214 0 ▶ if ($wtw2 and vec(($ssl_wtr2 ? $bitsr : $bitsw), $fn2, 1)) {
Branch: 2 branches
BranchTrueFalseTotal
if ($wtw2 and vec $ssl_wtr2 ? $bitsr : $bitsw, $fn2, 1) 0 0 0
$ssl_wtr2 ? : 0 0 0
Condition0%0/3
$wtw2 and vec $ssl_wtr2 ? $bitsr : $bitsw, $fn2, 1
!ll&&!rl&&r
000
MC/DC0%0/2
$wtw2 and vec $ssl_wtr2 ? $bitsr : $bitsw, $fn2, 1
$wtw2 vec $ssl_wtr2 ? $bitsr : $bitsw, $fn2, 1
Truth table0%0/3
A and B
A= $wtw2B= vec $ssl_wtr2 ? $bitsr : $bitsw, $fn2, 1
ABresult
0X0
100
111
215 0 ▶ $debug and _debug "writting to s2...";
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug("writting to s2...") 0 0 0
216 0 my $bytes = syswrite($s2, $b1to2, $write_chunk_size2);
217 0 ▶ $debug and _debug "bytes: " . ($bytes // '<undef>');
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug('bytes: ' . ($bytes // "<undef>")) 0 0 0
Condition0%0/2
$bytes // "<undef>"
l!l
00
MC/DC0%0/1
$bytes // "<undef>"
$bytes
Truth table0%0/2
A
A= $bytes
Aresult
11
00
218 0 ▶ if ($bytes) {
Branch: 2 branches
BranchTrueFalseTotal
if ($bytes) { } 0 0 0
elsif ($ssl2 and not defined $bytes) { } 0 0 0
219 0 ▶ $debug and _debug "s2 wrote: " . substr($b1to2, 0, $bytes);
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug('s2 wrote: ' . substr($b1to2, 0, $bytes)) 0 0 0
220 0 substr($b1to2, 0, $bytes, "");
221 0 ▶ if ($s1_in_closed and length $b1to2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($s1_in_closed and length $b1to2) 0 0 0
Condition0%0/3
$s1_in_closed and length $b1to2
!ll&&!rl&&r
000
MC/DC0%0/2
$s1_in_closed and length $b1to2
$s1_in_closed length $b1to2
Truth table0%0/3
A and B
A= $s1_in_closedB= length $b1to2
ABresult
0X0
100
111
222 0 ▶ $debug and _debug "buffer exhausted and s2-in is closed, shutting down s1-out";
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug("buffer exhausted and s2-in is closed, shutting down s1-out") 0 0 0
223 0 ▶ shutdown($s2, 1) unless $ssl2;
Branch: 1 branch
BranchTrueFalseTotal
unless $ssl2 0 0 0
224 0 $s2_out_closed = 1;
225 }
226 0 $write_chunk_size2 = $io_chunk_size;
227 0 undef $ssl_wtr2;
228 }
229 ▶ elsif ($ssl2 and not defined $bytes) {
Condition0%0/3
$ssl2 and not defined $bytes
!ll&&!rl&&r
000
MC/DC0%0/2
$ssl2 and not defined $bytes
$ssl2 not defined $bytes
Truth table0%0/3
A and not(B)
A= $ssl2B= not defined $bytes
ABresult
0X0
100
111
230 0 ▶ if (_ssl_error == _ssl_want_read) {
Branch: 2 branches
BranchTrueFalseTotal
if (_ssl_error() == _ssl_want_read()) { } 0 0 0
elsif (_ssl_error() == _ssl_want_write()) { } 0 0 0
231 0 $ssl_wtr2 = 1;
232 0 ▶ $debug and _debug "s2 wants to read for SSL";
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug("s2 wants to read for SSL") 0 0 0
233 }
234 elsif (_ssl_error == _ssl_want_write) {
235 0 ▶ $write_chunk_size2 = length $b1to2 if length $b1to2 < $write_chunk_size2;
Branch: 1 branch
BranchTrueFalseTotal
if length $b1to2 < $write_chunk_size2 0 0 0
236 0 ▶ $debug and _debug "s2 wants to write more for SSL, wcs2: $write_chunk_size2";
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug("s2 wants to write more for SSL, wcs2: $write_chunk_size2") 0 0 0
237 }
238 else {
239 0 _debug "unexpected SSL error " . _ssl_error;
240 0 $close{s2out} = 1;
241 }
242 }
243 else {
244 0 ▶ $debug and _debug "nothing written to s1, closing schedulled";
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug("nothing written to s1, closing schedulled") 0 0 0
245 0 $close{s2out} = 1;
246 }
247 }
248 0 ▶ if (%close) {
Branch: 1 branch
BranchTrueFalseTotal
if (%close) 0 0 0
249 0 for (1, 2, 3) { # propagate close flag to dependants
250 0 ▶ if ($ssl1 and ($close{s1in} or $close{s1out})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ssl1 and $close{"s1in"} || $close{"s1out"}) 0 0 0
Condition0%0/6
$ssl1 and $close{"s1in"} || $close{"s1out"}
!ll&&!rl&&r
000
$close{"s1in"} or $close{"s1out"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$ssl1 and $close{"s1in"} || $close{"s1out"}
$ssl1 $close{"s1in"} $close{"s1out"}
Truth table0%0/4
A and B or C
A= $ssl1B= $close{"s1in"}C= $close{"s1out"}
ABCresult
0XX0
1000
11X1
1011
251 0 $close{s1in} = $close{s1out} = 1;
252 }
253 0 ▶ if ($ssl2 and ($close{s2in} or $close{s2out})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ssl2 and $close{"s2in"} || $close{"s2out"}) 0 0 0
Condition0%0/6
$ssl2 and $close{"s2in"} || $close{"s2out"}
!ll&&!rl&&r
000
$close{"s2in"} or $close{"s2out"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$ssl2 and $close{"s2in"} || $close{"s2out"}
$ssl2 $close{"s2in"} $close{"s2out"}
Truth table0%0/4
A and B or C
A= $ssl2B= $close{"s2in"}C= $close{"s2out"}
ABCresult
0XX0
1000
11X1
1011
254 0 $close{s2in} = $close{s2out} = 1;
255 }
256 0 ▶ if ($close{s1in} and !length $b1to2) {
Branch: 1 branch
BranchTrueFalseTotal
if ($close{"s1in"} and not length $b1to2) 0 0 0
Condition0%0/3
$close{"s1in"} and not length $b1to2
!ll&&!rl&&r
000
MC/DC0%0/2
$close{"s1in"} and not length $b1to2
$close{"s1in"} not length $b1to2
Truth table0%0/3
A and not(B)
A= $close{"s1in"}B= not length $b1to2
ABresult
0X0
100
111
257 0 $close{s2out} = 1;
258 }
259 0 ▶ if ($close{s2in} and !length $b2to1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($close{"s2in"} and not length $b2to1) 0 0 0
Condition0%0/3
$close{"s2in"} and not length $b2to1
!ll&&!rl&&r
000
MC/DC0%0/2
$close{"s2in"} and not length $b2to1
$close{"s2in"} not length $b2to1
Truth table0%0/3
A and not(B)
A= $close{"s2in"}B= not length $b2to1
ABresult
0X0
100
111
260 0 $close{s1out} = 1;
261 }
262 }
263 0 ▶ if ($close{s1in}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($close{"s1in"}) 0 0 0
264 0 ▶ $debug and _debug "shutdown s1 in";
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug("shutdown s1 in") 0 0 0
265 0 shutdown($s1, 0);
266 0 $s1_in_closed = 1;
267 }
268 0 ▶ if ($close{s2in}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($close{"s2in"}) 0 0 0
269 0 ▶ $debug and _debug "shutdown s2 in";
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug("shutdown s2 in") 0 0 0
270 0 shutdown($s2, 0);
271 0 $s2_in_closed = 1;
272 }
273 0 ▶ if ($close{s1out}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($close{"s1out"}) 0 0 0
274 0 ▶ $debug and _debug "shutdown s1 out";
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug("shutdown s1 out") 0 0 0
275 0 shutdown($s1, 1);
276 0 $s1_out_closed = 1;
277 }
278 0 ▶ if ($close{s2out}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($close{"s2out"}) 0 0 0
279 0 ▶ $debug and _debug "shutdown s1 out";
Branch: 1 branch
BranchTrueFalseTotal
$debug and _debug("shutdown s1 out") 0 0 0
280 0 shutdown($s2, 1);
281 0 $s2_out_closed = 1;
282 }
283 }
284 0 %close = ();
285 }
286 }
287 0 shutdown($s1, 2);
288 0 shutdown($s2, 2);
289 }
290  
291 1 1;
292  
293 __END__
↑ Summary