Wrapper.pm

filter: Statementstmt 51.4% 107 / 208 Branchbran 44.7% 43 / 96 Conditioncond 57.5% 23 / 40 MC/DCmcdc 38.1% 8 / 21 Subroutinesub 56.2% 18 / 32 Podpod 0.0% 0 / 1 totaltotal 50.0% 199 / 398 CC 65 SCAR 37.4
CC
65
Cov
50%
_connect
143.4
_get_blocking_handle
42.0
__ANON__
42.0
CRAP 42.1
↑ Summary Wrapped.pm »
1 package IO::Socket::Socks::Wrapper;
2  
3 38 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 38 ▶no warnings 'prototype';
Subroutine BEGIN: called CC=1 SCAR=0.0
5 38 ▶no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
6 38 ▶use Socket;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 38 ▶use base 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 38 our $VERSION = '0.11';
10 38 our @EXPORT_OK = ('connect', 'wrap_connection');
11  
12 # cache
13 # pkg -> ref to pkg::sub || undef(if pkg has no connect)
14 38 my %PKGS;
15  
16 # reference to &IO::Socket::connect
17 my $io_socket_connect;
18 sub _io_socket_connect_ref {
19 83 ▶ return $io_socket_connect if $io_socket_connect;
Subroutine _io_socket_connect_ref: called CC=2 SCAR=6.9
Branch: 1 branch
BranchTrueFalseTotal
if $io_socket_connect 63 20 83
20 20 $io_socket_connect = \&IO::Socket::connect;
21 }
22  
23 # fake handle to put under event loop while making socks handshake
24 38 my ($blocking_reader, $blocking_writer);
25 sub _get_blocking_handle {
26 0 ▶ unless ($blocking_reader) {
Subroutine _get_blocking_handle: not called CC=6 SCAR=37.4
Branch: 1 branch
BranchTrueFalseTotal
unless ($blocking_reader) 0 0 0
27 0 ▶ pipe($blocking_reader, $blocking_writer)
Branch: 1 branch
BranchTrueFalseTotal
pipe $blocking_reader, $blocking_writer or die "pipe(): ", $! 0 0 0
28 or die 'pipe(): ', $!;
29
30 0 vec(my $win, fileno($blocking_reader), 1) = 1;
31 0 ▶ if (select(undef, $win, undef, 0)) {
Branch: 1 branch
BranchTrueFalseTotal
if (select undef, $win, undef, 0) 0 0 0
32 # oh shi~, this system is crazy
33 # reader from pipe() marked as ready for write
34 0 ($blocking_reader, $blocking_writer) = ($blocking_writer, $blocking_reader);
35 0 $blocking_reader->blocking(0);
36
37 0 my $garbage = '\0' x 4096;
38 0 my ($writed, $total_writed);
39 0 ▶ while ($writed = syswrite($blocking_reader, $garbage)) {
Branch: 1 branch
BranchTrueFalseTotal
if ($writed = syswrite($blocking_reader, $garbage)) 0 0 0
40 0 $total_writed += $writed;
41
42 0 ▶ if ($total_writed > 2097152) {
Branch: 1 branch
BranchTrueFalseTotal
if ($total_writed > 2097152) 0 0 0
43 # pipe with buffer more than 2 mb
44 # are u kidding me?
45 0 die "Can't create blocking handle";
46 }
47 }
48 }
49 }
50
51 0 return $blocking_reader;
52 }
53  
54 sub import
55 {
56 69 ▶ my $mypkg = shift;
Subroutine import: called CC=16 SCAR=27.8
57
58 69 ▶ if (@_ == 1 && !ref($_[0]) && $_[0] eq 'wrap_connection') {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1 and not ref $_[0] and $_[0] eq "wrap_connection") 0 69 69
Condition50%3/6
@_ == 1 and not ref $_[0] and $_[0] eq "wrap_connection"
!ll&&!rl&&r
6900
@_ == 1 and not ref $_[0]
!ll&&!rl&&r
6540
MC/DC0%0/3
@_ == 1 and not ref $_[0] and $_[0] eq "wrap_connection"
@_ == 1 not ref $_[0] $_[0] eq "wrap_connection"
Truth table50%2/4
A and not(B) and C
A= @_ == 1B= not ref $_[0]C= $_[0] eq "wrap_connection"
ABCresult
0XX0
10X0
1100
1111
59 0 return __PACKAGE__->export_to_level(1, $mypkg, 'wrap_connection');
60 }
61
62 69 ▶ while(my ($pkg, $cfg) = splice @_, 0, 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@_, 0, 2)) 31 69 100
63 31 ▶ unless(defined $cfg) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $cfg) 4 27 31
64 4 $cfg = $pkg;
65 4 $pkg = undef;
66 }
67
68 31 ▶ if($pkg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pkg) { } 27 4 31
69 38 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
70
71 27 my $sub;
72 27 ▶ if ($pkg =~ /^(.+)::([^:]+)\(\)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pkg =~ /^(.+)::([^:]+)\(\)$/) 3 24 27
73 3 $pkg = $1;
74 3 $sub = $2;
75 }
76
77 # override in the package
78
79 # try to load if not already available
80 # and if not requested to do not load
81 27 ▶ unless(delete $cfg->{_norequire} || %{$pkg.'::'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (delete $cfg->{"_norequire"} or %{$pkg . '::';}) 1 26 27
Condition100%3/3
delete $cfg->{"_norequire"} or %{$pkg . '::';}
l!l&&r!l&&!r
2241
MC/DC100%2/2
delete $cfg->{"_norequire"} or %{$pkg . '::';}
delete $cfg->{"_norequire"} %{$pkg . '::';}
Truth table100%3/3
A or B
A= delete $cfg->{"_norequire"}B= %{$pkg . '::';}
ABresult
1X1
011
000
82 1 ▶ eval "require $pkg" # make @ISA available
Branch: 1 branch
BranchTrueFalseTotal
eval "require $pkg" or die $@ 0 1 1
83 or die $@;
84 }
85
86 27 ▶ if ($sub) {
Branch: 2 branches
BranchTrueFalseTotal
if ($sub) { } 3 24 27
elsif ($pkg->isa('IO::Socket')) { } 21 3 24
87 # localize IO::Socket::connect overriding
88 # in the sub where IO::Socket::connect called
89 3 my $symbol = $pkg.'::'.$sub;
90 my $pkg_sub = exists $PKGS{$symbol} ?
91 $PKGS{$symbol} :
92 3 ▶ ($PKGS{$symbol} = \&$symbol);
Branch: 1 branch
BranchTrueFalseTotal
exists $PKGS{$symbol} ? : 1 2 3
93
94 3 _io_socket_connect_ref();
95
96 *$symbol = sub {
97 local *IO::Socket::connect = sub {
98 4 ▶ _connect(@_, $cfg, 1);
Subroutine __ANON__: called CC=1 SCAR=0.0
99 4 ▶ };
Subroutine __ANON__: called CC=1 SCAR=0.0
100
101 4 $pkg_sub->(@_);
102 3 };
103 3 next;
104 }
105 elsif($pkg->isa('IO::Socket')) {
106 # replace IO::Socket::connect
107 # if package inherits from IO::Socket
108 # save replaceable package version of the connect
109 # if it has own
110 # will call it from the our new connect
111 21 my $symbol = $pkg.'::connect';
112 my $pkg_connect = exists $PKGS{$pkg} ?
113 $PKGS{$pkg} :
114 21 ▶ ($PKGS{$pkg} = eval{ *{$symbol}{CODE} } ? \&$symbol : undef);
Branch: 2 branches
BranchTrueFalseTotal
exists $PKGS{$pkg} ? : 1 20 21
eval { do { *{$symbol;}{'CODE'} } } ? : 2 18 20
115
116 *connect = sub {
117 43 ▶ _io_socket_connect_ref();
Subroutine __ANON__: called CC=5 SCAR=16.1
118
119 local(*IO::Socket::connect) = sub {
120 31 ▶ _connect(@_, $cfg, 1);
Subroutine __ANON__: called CC=1 SCAR=0.0
121 43 };
122
123 43 my $self = shift;
124
125 43 ▶ if ($pkg_connect) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pkg_connect) { } 8 35 43
126 # package has its own connect
127 8 $pkg_connect->($self, @_);
128 }
129 else {
130 # get first parent which has connect sub
131 # and call it
132 35 my $ref = ref($self);
133
134 35 foreach my $parent (@{$pkg.'::ISA'}) {
135 70 ▶ if($parent->isa('IO::Socket')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($parent->isa("IO::Socket")) 35 35 70
136 35 bless $self, $parent;
137 35 my $connected = $self->connect(@_);
138 35 bless $self, $ref;
139 35 ▶ return $connected ? $self : undef;
Branch: 1 branch
BranchTrueFalseTotal
$connected ? : 24 11 35
140 }
141 }
142 }
143 }
144 21 }
145 else {
146 # replace package version of connect
147 *connect = sub {
148 4 ▶ _connect(@_, $cfg);
Subroutine __ANON__: called CC=1 SCAR=0.0
149 }
150 3 }
151
152 24 $mypkg->export($pkg, 'connect');
153 }
154 else {
155 # override connect() globally
156 *connect = sub(*$) {
157 20 ▶ my $socket = shift;
Subroutine __ANON__: called CC=2 SCAR=6.9
158 20 ▶ unless (ref $socket) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $socket) 2 18 20
159 # old-style bareword used
160 38 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
161 2 my $caller = caller;
162 2 $socket = $caller . '::' . $socket;
163 2 $socket = \*{$socket};
164 }
165
166 20 _connect($socket, @_, $cfg);
167 4 };
168
169 4 $mypkg->export('CORE::GLOBAL', 'connect');
170 }
171 }
172 }
173  
174 sub wrap_connection {
175 15 ▶ require IO::Socket::Socks::Wrapped;
Subroutine wrap_connection: called CC=1 SCAR=0.0
Pod undocumented
176 15 return IO::Socket::Socks::Wrapped->new(@_);
177 }
178  
179 sub _connect
180 {
181 95 ▶ my ($socket, $name, $cfg, $io_socket) = @_;
Subroutine _connect: called CC=20 SCAR=49.7
182 95 my $ref = ref($socket);
183
184 95 ▶ if (($ref && $socket->isa('IO::Socket::Socks')) || !$cfg) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ref and $socket->isa("IO::Socket::Socks") or not $cfg) 12 83 95
Condition83%5/6
$ref and $socket->isa("IO::Socket::Socks") or not $cfg
l!l&&r!l&&!r
10283
$ref and $socket->isa("IO::Socket::Socks")
!ll&&!rl&&r
08510
MC/DC66%2/3
$ref and $socket->isa("IO::Socket::Socks") or not $cfg
$ref $socket->isa("IO::Socket::Socks") not $cfg
Truth table60%3/5
A and B or not(C)
A= $refB= $socket->isa("IO::Socket::Socks")C= not $cfg
ABCresult
11X1
0X11
1011
0X00
1000
185 12 ▶ unless ($io_socket and ${*$socket}{'io_socket_timeout'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($io_socket and do { *$socket }->{"io_socket_timeout"}) 11 1 12
Condition66%2/3
$io_socket and do { *$socket }->{"io_socket_timeout"}
!ll&&!rl&&r
1101
MC/DC50%1/2
$io_socket and do { *$socket }->{"io_socket_timeout"}
$io_socket do { *$socket }->{"io_socket_timeout"}
Truth table66%2/3
A and B
A= $io_socketB= do { *$socket }->{"io_socket_timeout"}
ABresult
0X0
100
111
186 11 return CORE::connect( $socket, $name );
187 }
188
189 # use IO::Socket::connect for timeout support
190 1 ▶ local *connect = sub { CORE::connect($_[0], $_[1]) };
Subroutine __ANON__: not called CC=1 SCAR=1.2
191 1 return _io_socket_connect_ref->( $socket, $name );
192 }
193
194 83 my ($port, $host) = sockaddr_in($name);
195 83 $host = inet_ntoa($host);
196
197 # global overriding will not work with `use'
198 83 require IO::Socket::Socks;
199 83 my $io_handler = $cfg->{_io_handler};
200
201 83 ▶ unless ($io_handler || exists $cfg->{Timeout}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($io_handler or exists $cfg->{"Timeout"}) 32 51 83
Condition66%2/3
$io_handler or exists $cfg->{"Timeout"}
l!l&&r!l&&!r
05132
MC/DC50%1/2
$io_handler or exists $cfg->{"Timeout"}
$io_handler exists $cfg->{"Timeout"}
Truth table66%2/3
A or B
A= $io_handlerB= exists $cfg->{"Timeout"}
ABresult
1X1
011
000
202 32 ▶ $cfg->{Timeout} = $ref && $socket->isa('IO::Socket') && ${*$socket}{'io_socket_timeout'} || 180;
Condition87%7/8
$ref && $socket->isa('IO::Socket') && do { *$socket }->{'io_socket_timeout'} || 180
l!l
275
$ref and $socket->isa("IO::Socket") and do { *$socket }->{"io_socket_timeout"}
!ll&&!rl&&r
1427
$ref and $socket->isa("IO::Socket")
!ll&&!rl&&r
0131
MC/DC66%2/3
$ref && $socket->isa('IO::Socket') && do { *$socket }->{'io_socket_timeout'} || 180
$ref $socket->isa("IO::Socket") do { *$socket }->{"io_socket_timeout"}
Truth table75%3/4
A and B and C
A= $refB= $socket->isa("IO::Socket")C= do { *$socket }->{"io_socket_timeout"}
ABCresult
1111
0XX0
10X0
1100
203 }
204
205 83 ▶ if ($io_handler) {
Branch: 1 branch
BranchTrueFalseTotal
if ($io_handler) 0 83 83
206 0 $io_handler = $io_handler->();
207 0 require POSIX;
208 0 require Scalar::Util;
209
210 0 my $fd = fileno($socket);
211 0 ▶ my $tmp_fd = POSIX::dup($fd) // die 'dup2(): ', $!;
Condition0%0/2
POSIX::dup($fd) // die("dup2(): ", $!)
l!l
00
MC/DC0%0/1
POSIX::dup($fd) // die("dup2(): ", $!)
POSIX::dup($fd)
Truth table0%0/2
A
A= POSIX::dup($fd)
Aresult
11
00
212 0 ▶ open my $tmp_socket, '+<&=' . $tmp_fd or die 'open(): ', $!;
Branch: 1 branch
BranchTrueFalseTotal
open my $tmp_socket, '+<&=' . $tmp_fd or die "open(): ", $! 0 0 0
213 0 ▶ POSIX::dup2(fileno(_get_blocking_handle()), $fd) // die 'dup(): ', $!;
Condition0%0/2
POSIX::dup2(fileno _get_blocking_handle(), $fd) // die("dup(): ", $!)
l!l
00
MC/DC0%0/1
POSIX::dup2(fileno _get_blocking_handle(), $fd) // die("dup(): ", $!)
POSIX::dup2(fileno _get_blocking_handle(), $fd)
Truth table0%0/2
A
A= POSIX::dup2(fileno _get_blocking_handle(), $fd)
Aresult
11
00
214 0 $io_handler->{orig_socket} = $socket;
215 0 Scalar::Util::weaken($io_handler->{orig_socket});
216 0 $socket = $tmp_socket;
217 }
218
219 IO::Socket::Socks->new_from_socket(
220 83 ▶ $socket,
Branch: 1 branch
BranchTrueFalseTotal
"IO::Socket::Socks"->new_from_socket($socket, "ConnectAddr", $host, "ConnectPort", $port, %$cfg) or return 35 48 83
221 ConnectAddr => $host,
222 ConnectPort => $port,
223 %$cfg
224 ) or return;
225
226 48 ▶ bless $socket, $ref if $ref && !$io_handler; # XXX: should we unbless for GLOB?
Branch: 1 branch
BranchTrueFalseTotal
if $ref and not $io_handler 48 0 48
Condition33%1/3
$ref and not $io_handler
!ll&&!rl&&r
0048
MC/DC0%0/2
$ref and not $io_handler
$ref not $io_handler
Truth table33%1/3
A and not(B)
A= $refB= not $io_handler
ABresult
0X0
100
111
227
228 48 ▶ if ($io_handler) {
Branch: 1 branch
BranchTrueFalseTotal
if ($io_handler) 0 48 48
229 0 my ($r_cb, $w_cb);
230
231 0 tie *{$io_handler->{orig_socket}}, 'IO::Socket::Socks::Wrapper::Handle', $io_handler->{orig_socket}, sub {
232 0 ▶ $io_handler->{unset_read_watcher}->($socket);
Subroutine __ANON__: not called CC=2 SCAR=17.9
233 0 $io_handler->{unset_write_watcher}->($socket);
234
235 0 ▶ if ($io_handler->{destroy_io_watcher}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($io_handler->{"destroy_io_watcher"}) 0 0 0
236 0 $io_handler->{destroy_io_watcher}->($socket);
237 }
238
239 0 close $socket;
240 0 };
241
242 my $on_finish = sub {
243 0 ▶ tied(*{$io_handler->{orig_socket}})->handshake_done(1);
Subroutine __ANON__: not called CC=2 SCAR=17.9
244 0 ▶ POSIX::dup2(fileno($socket), fileno($io_handler->{orig_socket})) // die 'dup2(): ', $!;
Condition0%0/2
POSIX::dup2(fileno $socket, fileno $io_handler->{"orig_socket"}) // die("dup2(): ", $!)
l!l
00
MC/DC0%0/1
POSIX::dup2(fileno $socket, fileno $io_handler->{"orig_socket"}) // die("dup2(): ", $!)
POSIX::dup2(fileno $socket, fileno $io_handler->{"orig_socket"})
Truth table0%0/2
A
A= POSIX::dup2(fileno $socket, fileno $io_handler->{"orig_socket"})
Aresult
11
00
245 0 close $socket;
246 0 };
247
248 my $on_error = sub {
249 0 ▶ tied(*{$io_handler->{orig_socket}})->handshake_done(1);
Subroutine __ANON__: not called CC=2 SCAR=17.9
250 0 shutdown($socket, 0);
251 0 ▶ POSIX::dup2(fileno($socket), fileno($io_handler->{orig_socket})) // die 'dup2(): ', $!;
Condition0%0/2
POSIX::dup2(fileno $socket, fileno $io_handler->{"orig_socket"}) // die("dup2(): ", $!)
l!l
00
MC/DC0%0/1
POSIX::dup2(fileno $socket, fileno $io_handler->{"orig_socket"}) // die("dup2(): ", $!)
POSIX::dup2(fileno $socket, fileno $io_handler->{"orig_socket"})
Truth table0%0/2
A
A= POSIX::dup2(fileno $socket, fileno $io_handler->{"orig_socket"})
Aresult
11
00
252 0 close $socket;
253 0 };
254
255 $r_cb = sub {
256 0 ▶ if ($socket->ready) {
Subroutine __ANON__: not called CC=6 SCAR=37.4
Branch: 3 branches
BranchTrueFalseTotal
if ($socket->ready) { } 0 0 0
elsif ($IO::Socket::Socks::SOCKS_ERROR == &IO::Socket::Socks::SOCKS_WANT_WRITE) { } 0 0 0
elsif ($IO::Socket::Socks::SOCKS_ERROR != &IO::Socket::Socks::SOCKS_WANT_READ) { } 0 0 0
257 0 $io_handler->{unset_read_watcher}->($socket);
258
259 0 ▶ if ($io_handler->{destroy_io_watcher}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($io_handler->{"destroy_io_watcher"}) 0 0 0
260 0 $io_handler->{destroy_io_watcher}->($socket);
261 }
262
263 0 $on_finish->();
264 }
265 elsif ($IO::Socket::Socks::SOCKS_ERROR == &IO::Socket::Socks::SOCKS_WANT_WRITE) {
266 0 $io_handler->{unset_read_watcher}->($socket);
267 0 $io_handler->{set_write_watcher}->($socket, $w_cb);
268 }
269 elsif ($IO::Socket::Socks::SOCKS_ERROR != &IO::Socket::Socks::SOCKS_WANT_READ) {
270 0 $io_handler->{unset_read_watcher}->($socket);
271
272 0 ▶ if ($io_handler->{destroy_io_watcher}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($io_handler->{"destroy_io_watcher"}) 0 0 0
273 0 $io_handler->{destroy_io_watcher}->($socket);
274 }
275
276 0 $on_error->();
277 }
278 0 };
279
280 $w_cb = sub {
281 0 ▶ if ($socket->ready) {
Subroutine __ANON__: not called CC=6 SCAR=37.4
Branch: 3 branches
BranchTrueFalseTotal
if ($socket->ready) { } 0 0 0
elsif ($IO::Socket::Socks::SOCKS_ERROR == &IO::Socket::Socks::SOCKS_WANT_READ) { } 0 0 0
elsif ($IO::Socket::Socks::SOCKS_ERROR != &IO::Socket::Socks::SOCKS_WANT_WRITE) { } 0 0 0
282 0 $io_handler->{unset_write_watcher}->($socket);
283
284 0 ▶ if ($io_handler->{destroy_io_watcher}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($io_handler->{"destroy_io_watcher"}) 0 0 0
285 0 $io_handler->{destroy_io_watcher}->($socket);
286 }
287
288 0 $on_finish->();
289 }
290 elsif ($IO::Socket::Socks::SOCKS_ERROR == &IO::Socket::Socks::SOCKS_WANT_READ) {
291 0 $io_handler->{unset_write_watcher}->($socket);
292 0 $io_handler->{set_read_watcher}->($socket, $r_cb);
293 }
294 elsif ($IO::Socket::Socks::SOCKS_ERROR != &IO::Socket::Socks::SOCKS_WANT_WRITE) {
295 0 $io_handler->{unset_write_watcher}->($socket);
296
297 0 ▶ if ($io_handler->{destroy_io_watcher}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($io_handler->{"destroy_io_watcher"}) 0 0 0
298 0 $io_handler->{destroy_io_watcher}->($socket);
299 }
300
301 0 $on_error->();
302 }
303 0 };
304
305 0 ▶ if ($io_handler->{init_io_watcher}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($io_handler->{"init_io_watcher"}) 0 0 0
306 0 $io_handler->{init_io_watcher}->($socket, $r_cb, $w_cb);
307 }
308
309 0 $io_handler->{set_write_watcher}->($socket, $w_cb);
310 }
311
312 48 return 1;
313 }
314  
315 package IO::Socket::Socks::Wrapper::Handle;
316  
317 38 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
318  
319 sub TIEHANDLE {
320 0 ▶ my ($class, $orig_handle, $cleanup_cb) = @_;
Subroutine TIEHANDLE: not called CC=2 SCAR=17.9
321
322 0 ▶ open my $self, '+<&=' . fileno($orig_handle)
Branch: 1 branch
BranchTrueFalseTotal
open my $self, '+<&=' . fileno($orig_handle) or die "open: ", $! 0 0 0
323 or die 'open: ', $!;
324
325 0 ${*$self}{handshake_done} = 0;
326 0 ${*$self}{cleanup_cb} = $cleanup_cb;
327
328 0 bless $self, $class;
329 }
330  
331 sub handshake_done {
332 0 ▶ my $self = shift;
Subroutine handshake_done: not called CC=2 SCAR=17.9
333
334 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
335 0 ${*$self}{handshake_done} = $_[0];
336 }
337
338 0 return ${*$self}{handshake_done};
339 }
340  
341 sub READ {
342 0 ▶ my $self = shift;
Subroutine READ: not called CC=2 SCAR=17.9
343 0 ▶ sysread($self, $_[0], $_[1], @_ > 2 ? $_[2] : ());
Branch: 1 branch
BranchTrueFalseTotal
@_ > 2 ? : 0 0 0
344 }
345  
346 sub WRITE {
347 0 ▶ my $self = shift;
Subroutine WRITE: not called CC=2 SCAR=17.9
348 0 ▶ syswrite($self, $_[0], $_[1], @_ > 2 ? $_[2] : ());
Branch: 1 branch
BranchTrueFalseTotal
@_ > 2 ? : 0 0 0
349 }
350  
351 sub FILENO {
352 0 ▶ my $self = shift;
Subroutine FILENO: not called CC=1 SCAR=6.9
353 0 fileno($self);
354 }
355  
356 sub CLOSE {
357 0 ▶ my $self = shift;
Subroutine CLOSE: not called CC=2 SCAR=17.9
358
359 0 ▶ unless ($self->handshake_done) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->handshake_done) 0 0 0
360 0 $self->handshake_done(1);
361 0 ${*$self}{cleanup_cb}->();
362 }
363
364 0 close $self;
365 }
366  
367 sub DESTROY {
368 0 ▶ my $self = shift;
Subroutine DESTROY: not called CC=2 SCAR=17.9
369
370 0 ▶ unless ($self->handshake_done) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->handshake_done) 0 0 0
371 0 $self->handshake_done(1);
372 0 ${*$self}{cleanup_cb}->();
373 }
374 }
375  
376 38 1;
377  
378 __END__
↑ Summary Wrapped.pm »