Shared/Handle.pm

filter: Statementstmt 45.0% 191 / 424 Branchbran 22.0% 53 / 240 Conditioncond 17.3% 16 / 92 MC/DCmcdc 3.9% 2 / 51 Subroutinesub 58.1% 32 / 55 Podpod 100% 1 / 1 totaltotal 34.1% 295 / 863 CC 151 SCAR 42.5
CC
151
Cov
34%
READ
272.0
__ANON__
240.0
open
153.4
CRAP 70.3
« Shared.pm ↑ Summary Shared/Cache.pm »
1 ###############################################################################
2 ## ----------------------------------------------------------------------------
3 ## Handle helper class.
4 ##
5 ###############################################################################
6  
7 package MCE::Shared::Handle;
8  
9 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 2 ▶use 5.010001;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 2 ▶no warnings qw( threads recursion uninitialized numeric );
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 2 our $VERSION = '1.894';
17  
18 ## no critic (BuiltinFunctions::ProhibitStringyEval)
19 ## no critic (InputOutput::ProhibitTwoArgOpen)
20 ## no critic (Subroutines::ProhibitExplicitReturnUndef)
21 ## no critic (Subroutines::ProhibitSubroutinePrototypes)
22 ## no critic (TestingAndDebugging::ProhibitNoStrict)
23  
24 2 ▶use MCE::Shared::Base ();
Subroutine BEGIN: called CC=1 SCAR=0.0
25  
26 2 my $LF = "\012"; Internals::SvREADONLY($LF, 1);
27 2 ▶my $_tid = $INC{'threads.pm'} ? threads->tid() : 0;
Branch: 1 branch
BranchTrueFalseTotal
$INC{'threads.pm'} ? : 0 2 2
28 2 ▶my $_max_fd = eval 'fileno(\*main::DATA)' // 2;
Condition50%1/2
eval "fileno(\\*main::DATA)" // 2
l!l
02
MC/DC0%0/1
eval "fileno(\\*main::DATA)" // 2
eval "fileno(\\*main::DATA)"
Truth table50%1/2
A
A= eval "fileno(\\*main::DATA)"
Aresult
11
00
29 2 my $_reset_flg = 1;
30  
31 0 ▶sub _croak {
Subroutine _croak: not called CC=1 SCAR=6.9
32 0 goto &MCE::Shared::Base::_croak;
33 }
34 0 ▶sub CLONE {
Subroutine CLONE: not called CC=2 SCAR=17.9
35 0 ▶ $_tid = threads->tid() if $INC{'threads.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if $INC{"threads.pm"} 0 0 0
36 }
37  
38 2 ▶sub import {
Subroutine import: called CC=2 SCAR=7.2
39 2 ▶ if (!defined $INC{'MCE/Shared.pm'}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $INC{"MCE/Shared.pm"}) 0 2 2
40 2 ▶ no strict 'refs'; no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine BEGIN: called CC=1 SCAR=0.0
41 0 *{ caller().'::mce_open' } = \&open;
42 }
43 2 return;
44 }
45  
46 3 ▶sub TIEHANDLE {
Subroutine TIEHANDLE: called CC=8 SCAR=30.4
47 3 my $class = shift;
48  
49 3 ▶ if (ref $_[0] eq 'ARRAY') {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq "ARRAY") 3 0 3
50 # For use with MCE::Shared in order to reach the Server process.
51 # Therefore constructed without a GLOB handle initially.
52  
53 MCE::Shared::Object::_reset(), $_reset_flg = ''
54 3 ▶ if $_reset_flg && $INC{'MCE/Shared/Server.pm'};
Branch: 1 branch
BranchTrueFalseTotal
if $_reset_flg and $INC{"MCE/Shared/Server.pm"} 2 1 3
Condition66%2/3
$_reset_flg and $INC{"MCE/Shared/Server.pm"}
!ll&&!rl&&r
102
MC/DC50%1/2
$_reset_flg and $INC{"MCE/Shared/Server.pm"}
$_reset_flg $INC{"MCE/Shared/Server.pm"}
Truth table66%2/3
A and B
A= $_reset_flgB= $INC{"MCE/Shared/Server.pm"}
ABresult
0X0
100
111
55  
56 3 return bless $_[0], $class;
57 }
58  
59 0 ▶ bless my $fh = \do { no warnings 'once'; local *FH }, $class;
Subroutine BEGIN: called CC=1 SCAR=0.6
60  
61 0 ▶ if (@_) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 0 0 0
62 0 ▶ if ( !defined wantarray ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined wantarray) { } 0 0 0
63 0 ▶ $fh->OPEN(@_) or _croak("open error: $!");
Branch: 1 branch
BranchTrueFalseTotal
$fh->OPEN(@_) or _croak("open error: $!") 0 0 0
64 } else {
65 0 ▶ $fh->OPEN(@_) or return '';
Branch: 1 branch
BranchTrueFalseTotal
$fh->OPEN(@_) or return "" 0 0 0
66 }
67 }
68  
69 0 $fh;
70 }
71  
72 ###############################################################################
73 ## ----------------------------------------------------------------------------
74 ## Based on Tie::StdHandle.
75 ##
76 ###############################################################################
77  
78 0 ▶sub EOF { eof($_[0]) }
Subroutine EOF: not called CC=1 SCAR=6.9
79 0 ▶sub TELL { tell($_[0]) }
Subroutine TELL: not called CC=1 SCAR=6.9
80 0 ▶sub FILENO { fileno($_[0]) }
Subroutine FILENO: not called CC=1 SCAR=6.9
81 0 ▶sub SEEK { seek($_[0], $_[1], $_[2]) }
Subroutine SEEK: not called CC=1 SCAR=6.9
82 0 ▶sub CLOSE { close($_[0]) if defined(fileno $_[0]) }
Subroutine CLOSE: not called CC=2 SCAR=17.9
Branch: 1 branch
BranchTrueFalseTotal
if defined fileno $_[0] 0 0 0
83 0 ▶sub BINMODE { binmode($_[0], $_[1] // ':raw') ? 1 : '' }
Subroutine BINMODE: not called CC=3 SCAR=24.8
Branch: 1 branch
BranchTrueFalseTotal
binmode($_[0], $_[1] // ':raw') ? : 0 0 0
Condition0%0/2
$_[1] // ":raw"
l!l
00
MC/DC0%0/1
$_[1] // ":raw"
$_[1]
Truth table0%0/2
A
A= $_[1]
Aresult
11
00
84 0 ▶sub GETC { getc($_[0]) }
Subroutine GETC: not called CC=1 SCAR=6.9
85  
86 0 ▶sub OPEN {
Subroutine OPEN: not called CC=7 SCAR=40.3
87 0 my $ret;
88  
89 0 ▶ close($_[0]) if defined fileno($_[0]);
Branch: 1 branch
BranchTrueFalseTotal
if defined fileno $_[0] 0 0 0
90  
91 0 ▶ if ( @_ == 3 && ref $_[2] && defined( my $_fd = fileno($_[2]) ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 3 and ref $_[2] and defined(my $_fd = fileno $_[2])) { } 0 0 0
Condition0%0/6
@_ == 3 and ref $_[2] and defined(my $_fd = fileno $_[2])
!ll&&!rl&&r
000
@_ == 3 and ref $_[2]
!ll&&!rl&&r
000
MC/DC0%0/3
@_ == 3 and ref $_[2] and defined(my $_fd = fileno $_[2])
@_ == 3 ref $_[2] defined(my $_fd = fileno $_[2])
Truth table0%0/4
A and B and C
A= @_ == 3B= ref $_[2]C= defined(my $_fd = fileno $_[2])
ABCresult
0XX0
10X0
1100
1111
92 0 $ret = CORE::open($_[0], $_[1]."&=$_fd");
93 }
94 else {
95 0 ▶ $ret = ( @_ == 2 )
Branch: 1 branch
BranchTrueFalseTotal
@_ == 2 ? : 0 0 0
96 ? CORE::open($_[0], $_[1])
97 : CORE::open($_[0], $_[1], $_[2]);
98 }
99  
100 # enable autoflush
101 0 ▶ select(( select($_[0]), $| = 1 )[0]) if $ret;
Branch: 1 branch
BranchTrueFalseTotal
if $ret 0 0 0
102  
103 0 $ret;
104 }
105  
106 0 ▶sub open (@) {
Subroutine open: not called CC=13 SCAR=50.3
Pod documented
107 0 ▶ shift if ( defined $_[0] && $_[0] eq 'MCE::Shared::Handle' );
Branch: 1 branch
BranchTrueFalseTotal
if defined $_[0] and $_[0] eq "MCE::Shared::Handle" 0 0 0
Condition0%0/3
defined $_[0] and $_[0] eq "MCE::Shared::Handle"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $_[0] and $_[0] eq "MCE::Shared::Handle"
defined $_[0] $_[0] eq "MCE::Shared::Handle"
Truth table0%0/3
A and B
A= defined $_[0]B= $_[0] eq "MCE::Shared::Handle"
ABresult
0X0
100
111
108  
109 0 my $item;
110  
111 0 ▶ if ( ref $_[0] eq 'GLOB' && tied *{ $_[0] } &&
Branch: 2 branches
BranchTrueFalseTotal
if (ref $_[0] eq 'GLOB' and tied *{$_[0];} and ref tied *{$_[0];} eq __PACKAGE__) { } 0 0 0
elsif (@_) { } 0 0 0
Condition0%0/6
ref $_[0] eq "GLOB" and tied *{$_[0];} and ref tied *{$_[0];} eq __PACKAGE__
!ll&&!rl&&r
000
ref $_[0] eq "GLOB" and tied *{$_[0];}
!ll&&!rl&&r
000
MC/DC0%0/3
ref $_[0] eq "GLOB" and tied *{$_[0];} and ref tied *{$_[0];} eq __PACKAGE__
ref $_[0] eq "GLOB" tied *{$_[0];} ref tied *{$_[0];} eq __PACKAGE__
Truth table0%0/4
A and B and C
A= ref $_[0] eq "GLOB"B= tied *{$_[0];}C= ref tied *{$_[0];} eq __PACKAGE__
ABCresult
0XX0
10X0
1100
1111
112 0 ref tied(*{ $_[0] }) eq __PACKAGE__ ) {
113 0 $item = tied *{ $_[0] };
114 }
115 elsif ( @_ ) {
116 0 ▶ if ( ref $_[0] eq 'GLOB' && tied *{ $_[0] } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $_[0] eq "GLOB" and tied *{$_[0];}) 0 0 0
Condition0%0/3
ref $_[0] eq "GLOB" and tied *{$_[0];}
!ll&&!rl&&r
000
MC/DC0%0/2
ref $_[0] eq "GLOB" and tied *{$_[0];}
ref $_[0] eq "GLOB" tied *{$_[0];}
Truth table0%0/3
A and B
A= ref $_[0] eq "GLOB"B= tied *{$_[0];}
ABresult
0X0
100
111
117 0 ▶ close $_[0] if defined ( fileno $_[0] );
Branch: 1 branch
BranchTrueFalseTotal
if defined fileno $_[0] 0 0 0
118 }
119 0 ▶ $_[0] = \do { no warnings 'once'; local *FH };
Subroutine BEGIN: called CC=1 SCAR=0.6
120 0 $item = tie *{ $_[0] }, __PACKAGE__;
121 }
122  
123 0 ▶ shift; _croak("Not enough arguments for open") unless @_;
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 0 0 0
124  
125 0 ▶ if ( !defined wantarray ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined wantarray) { } 0 0 0
126 0 ▶ $item->OPEN(@_) or _croak("open error: $!");
Branch: 1 branch
BranchTrueFalseTotal
$item->OPEN(@_) or _croak("open error: $!") 0 0 0
127 } else {
128 0 $item->OPEN(@_);
129 }
130 }
131  
132 0 ▶sub READ {
Subroutine READ: not called CC=16 SCAR=56.1
133 0 my ($fh, $len, $auto) = ($_[0], $_[2]);
134  
135 0 ▶ if (lc(substr $len, -1, 1) eq 'm') {
Branch: 2 branches
BranchTrueFalseTotal
if (lc substr($len, -1, 1) eq 'm') { } 0 0 0
elsif (lc substr($len, -1, 1) eq 'k') { } 0 0 0
136 0 $auto = 1, chop $len; $len *= 1024 * 1024;
137 } elsif (lc(substr $len, -1, 1) eq 'k') {
138 0 $auto = 1, chop $len; $len *= 1024;
139 }
140  
141 # normal use-case
142  
143 0 ▶ if (!$auto) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($auto) 0 0 0
144 0 ▶ return @_ == 4 ? read($fh, $_[1], $len, $_[3]) : read($fh, $_[1], $len);
Branch: 1 branch
BranchTrueFalseTotal
@_ == 4 ? : 0 0 0
145 }
146  
147 # chunk IO, read up to record separator or eof
148 # support special case; e.g. $/ = "\n>" for bioinformatics
149 # anchoring ">" at the start of line
150  
151 0 my ($tmp, $ret);
152  
153 0 ▶ if (!eof($fh)) {
Branch: 1 branch
BranchTrueFalseTotal
if (not eof $fh) { } 0 0 0
154 0 ▶ if (length $/ > 1 && substr($/, 0, 1) eq "\n") {
Branch: 2 branches
BranchTrueFalseTotal
if (length $/ > 1 and substr($/, 0, 1) eq "\n") { } 0 0 0
elsif (defined($ret = read($fh, $tmp, $len))) { } 0 0 0
Condition0%0/3
length $/ > 1 and substr($/, 0, 1) eq "\n"
!ll&&!rl&&r
000
MC/DC0%0/2
length $/ > 1 and substr($/, 0, 1) eq "\n"
length $/ > 1 substr($/, 0, 1) eq "\n"
Truth table0%0/3
A and B
A= length $/ > 1B= substr($/, 0, 1) eq "\n"
ABresult
0X0
100
111
155 0 my $len = length($/) - 1;
156  
157 0 ▶ if (tell $fh) {
Branch: 1 branch
BranchTrueFalseTotal
if (tell $fh) { } 0 0 0
158 0 $tmp = substr($/, 1);
159 0 $ret = read($fh, $tmp, $len, length($tmp));
160 } else {
161 0 $ret = read($fh, $tmp, $len);
162 }
163  
164 0 ▶ if (defined $ret) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ret) 0 0 0
165 0 ▶ $. += 1 if eof($fh);
Branch: 1 branch
BranchTrueFalseTotal
if eof $fh 0 0 0
166 0 $tmp .= readline($fh);
167  
168 0 ▶ substr($tmp, -$len, $len, '')
Branch: 1 branch
BranchTrueFalseTotal
if substr($tmp, -$len) eq substr($/, 1) 0 0 0
169 if (substr($tmp, -$len) eq substr($/, 1));
170 }
171 }
172 elsif (defined ($ret = CORE::read($fh, $tmp, $len))) {
173 0 ▶ $. += 1 if eof($fh);
Branch: 1 branch
BranchTrueFalseTotal
if eof $fh 0 0 0
174 0 $tmp .= readline($fh);
175 }
176 }
177 else {
178 0 $tmp = '', $ret = 0;
179 }
180  
181 0 ▶ if (defined $ret) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ret) { } 0 0 0
182 0 ▶ my $pos = $_[3] || 0;
Condition0%0/2
$_[3] || 0
l!l
00
MC/DC0%0/1
$_[3] || 0
$_[3]
Truth table0%0/2
A
A= $_[3]
Aresult
11
00
183 0 substr($_[1], $pos, length($_[1]) - $pos, $tmp);
184 0 length($tmp);
185 }
186 else {
187 0 undef;
188 }
189 }
190  
191 0 ▶sub READLINE {
Subroutine READLINE: not called CC=6 SCAR=37.4
192 # support special case; e.g. $/ = "\n>" for bioinformatics
193 # anchoring ">" at the start of line
194  
195 0 ▶ if (length $/ > 1 && substr($/, 0, 1) eq "\n" && !eof($_[0])) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $/ > 1 and substr($/, 0, 1) eq "\n" and not eof $_[0]) { } 0 0 0
Condition0%0/6
length $/ > 1 and substr($/, 0, 1) eq "\n" and not eof $_[0]
!ll&&!rl&&r
000
length $/ > 1 and substr($/, 0, 1) eq "\n"
!ll&&!rl&&r
000
MC/DC0%0/3
length $/ > 1 and substr($/, 0, 1) eq "\n" and not eof $_[0]
length $/ > 1 substr($/, 0, 1) eq "\n" not eof $_[0]
Truth table0%0/4
A and B and not(C)
A= length $/ > 1B= substr($/, 0, 1) eq "\n"C= not eof $_[0]
ABCresult
0XX0
10X0
1100
1111
196 0 my ($len, $buf) = (length($/) - 1);
197  
198 0 ▶ if (tell $_[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (tell $_[0]) { } 0 0 0
199 0 $buf = substr($/, 1), $buf .= readline($_[0]);
200 } else {
201 0 $buf = readline($_[0]);
202 }
203  
204 0 ▶ substr($buf, -$len, $len, '')
Branch: 1 branch
BranchTrueFalseTotal
if substr($buf, -$len) eq substr($/, 1) 0 0 0
205 if (substr($buf, -$len) eq substr($/, 1));
206  
207 0 $buf;
208 }
209 else {
210 0 scalar(readline($_[0]));
211 }
212 }
213  
214 0 ▶sub PRINT {
Subroutine PRINT: not called CC=3 SCAR=24.8
215 0 my $fh = shift;
216 0 ▶ my $buf = join(defined $, ? $, : "", @_);
Branch: 1 branch
BranchTrueFalseTotal
defined $, ? : 0 0 0
217 0 ▶ $buf .= $\ if defined $\;
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 0 0
218 0 local $\; # don't print any line terminator
219 0 print $fh $buf;
220 }
221  
222 0 ▶sub PRINTF {
Subroutine PRINTF: not called CC=1 SCAR=6.9
223 0 my $fh = shift;
224 0 my $buf = sprintf(shift, @_);
225 0 local $\; # ditto
226 0 print $fh $buf;
227 }
228  
229 0 ▶sub WRITE {
Subroutine WRITE: not called CC=8 SCAR=39.6
230 2 ▶ use bytes;
Subroutine BEGIN: called CC=1 SCAR=0.0
231  
232 # based on IO::SigGuard::syswrite 0.011 by Felipe Gasper (FELIPE)
233 0 my $wrote = 0;
234  
235 WRITE: {
236 0 $wrote += (
237 ( @_ == 2 )
238 ? syswrite($_[0], $_[1], length($_[1]) - $wrote, $wrote)
239 : ( @_ == 3 )
240 ? syswrite($_[0], $_[1], $_[2] - $wrote, $wrote)
241 : syswrite($_[0], $_[1], $_[2] - $wrote, $_[3] + $wrote)
242 0 ▶ ) or do {
Branch: 3 branches
BranchTrueFalseTotal
$wrote += @_ == 2 ? syswrite($_[0], $_[1], length($_[1]) - $wrote, $wrote) : (@_ == 3 ? syswrite($_[0], $_[1], $_[2] - $wrote, $wrote) : syswrite($_[0], $_[1], $_[2] - $wrote, $_[3] + $wrote)) or do { unless (defined $wrote) { redo WRITE if $!{"EINTR"} or $!{"EAGAIN"} or $!{"EWOULDBLOCK"}; return undef; } } 0 0 0
@_ == 2 ? : 0 0 0
@_ == 3 ? : 0 0 0
243 0 ▶ unless ( defined $wrote ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $wrote) 0 0 0
244 0 ▶ redo WRITE if $!{EINTR} || $!{EAGAIN} || $!{EWOULDBLOCK};
Branch: 1 branch
BranchTrueFalseTotal
if $!{"EINTR"} or $!{"EAGAIN"} or $!{"EWOULDBLOCK"} 0 0 0
Condition0%0/6
$!{"EINTR"} or $!{"EAGAIN"} or $!{"EWOULDBLOCK"}
l!l&&r!l&&!r
000
$!{"EINTR"} or $!{"EAGAIN"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$!{"EINTR"} or $!{"EAGAIN"} or $!{"EWOULDBLOCK"}
$!{"EINTR"} $!{"EAGAIN"} $!{"EWOULDBLOCK"}
Truth table0%0/4
A or B or C
A= $!{"EINTR"}B= $!{"EAGAIN"}C= $!{"EWOULDBLOCK"}
ABCresult
1XX1
01X1
0011
0000
245 0 return undef;
246 }
247 };
248 }
249  
250 0 $wrote;
251 }
252  
253 {
254 2 ▶ no strict 'refs'; *{ __PACKAGE__.'::new' } = \&TIEHANDLE;
Subroutine BEGIN: called CC=1 SCAR=0.0
255 }
256  
257 ###############################################################################
258 ## ----------------------------------------------------------------------------
259 ## Server functions.
260 ##
261 ###############################################################################
262  
263 {
264 2 ▶ use constant {
Subroutine BEGIN: called CC=1 SCAR=0.0
265 2 SHR_O_CLO => 'O~CLO', # Handle CLOSE
266 SHR_O_OPN => 'O~OPN', # Handle OPEN
267 SHR_O_REA => 'O~REA', # Handle READ
268 SHR_O_RLN => 'O~RLN', # Handle READLINE
269 SHR_O_PRI => 'O~PRI', # Handle PRINT
270 SHR_O_WRI => 'O~WRI', # Handle WRITE
271 2 };
272  
273 my (
274 2 $_DAU_R_SOCK_REF, $_DAU_R_SOCK, $_obj, $_freeze, $_thaw,
275 $_id, $_len, $_ret
276 );
277  
278 my %_output_function = (
279  
280 0 ▶ SHR_O_CLO.$LF => sub { # Handle CLOSE
Subroutine __ANON__: not called CC=2 SCAR=17.9
281 0 $_DAU_R_SOCK = ${ $_DAU_R_SOCK_REF };
282 0 chomp($_id = <$_DAU_R_SOCK>);
283  
284 0 ▶ close $_obj->{ $_id } if defined fileno($_obj->{ $_id });
Branch: 1 branch
BranchTrueFalseTotal
if defined fileno $_obj->{$_id} 0 0 0
285 0 print {$_DAU_R_SOCK} '1'.$LF;
286  
287 0 return;
288 },
289  
290 0 ▶ SHR_O_OPN.$LF => sub { # Handle OPEN
Subroutine __ANON__: not called CC=8 SCAR=42.8
291 0 $_DAU_R_SOCK = ${ $_DAU_R_SOCK_REF };
292 0 my ($_fd, $_buf, $_err); local $!;
293  
294 0 chomp($_id = <$_DAU_R_SOCK>),
295 chomp($_fd = <$_DAU_R_SOCK>),
296 chomp($_len = <$_DAU_R_SOCK>),
297  
298 read($_DAU_R_SOCK, $_buf, $_len);
299 0 print {$_DAU_R_SOCK} $LF;
300  
301 0 ▶ if ($_fd > $_max_fd) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_fd > $_max_fd) 0 0 0
302 0 ▶ $_fd = IO::FDPass::recv(fileno $_DAU_R_SOCK); $_fd >= 0
Branch: 1 branch
BranchTrueFalseTotal
$_fd >= 0 or _croak("cannot receive file handle: $!") 0 0 0
303 or _croak("cannot receive file handle: $!");
304 }
305  
306 0 ▶ close $_obj->{ $_id } if defined fileno($_obj->{ $_id });
Branch: 1 branch
BranchTrueFalseTotal
if defined fileno $_obj->{$_id} 0 0 0
307  
308 0 my $_args = $_thaw->($_buf);
309 0 my $_fh;
310  
311 0 ▶ if (@{ $_args } == 2) {
Branch: 1 branch
BranchTrueFalseTotal
if (@{$_args;} == 2) { } 0 0 0
312 # remove tainted'ness from $_args
313 0 ($_args->[0]) = $_args->[0] =~ /(.*)/;
314 0 ($_args->[1]) = $_args->[1] =~ /(.*)/;
315  
316 0 ▶ CORE::open($_fh, "$_args->[0]", $_args->[1]) or do { $_err = 0+$! };
Branch: 1 branch
BranchTrueFalseTotal
CORE::open $_fh, "$_args->[0]", $_args->[1] or do { $_err = 0 + $! } 0 0 0
317 }
318 else {
319 # remove tainted'ness from $_args
320 0 ($_args->[0]) = $_args->[0] =~ /(.*)/;
321  
322 0 ▶ CORE::open($_fh, $_args->[0]) or do { $_err = 0+$! };
Branch: 1 branch
BranchTrueFalseTotal
CORE::open $_fh, $_args->[0] or do { $_err = 0 + $! } 0 0 0
323 }
324  
325 # enable autoflush
326 0 ▶ select(( select($_fh), $| = 1 )[0]) unless $_err;
Branch: 1 branch
BranchTrueFalseTotal
unless $_err 0 0 0
327  
328 0 *{ $_obj->{ $_id } } = *{ $_fh };
329 0 print {$_DAU_R_SOCK} $_err.$LF;
330  
331 0 return;
332 },
333  
334 0 ▶ SHR_O_REA.$LF => sub { # Handle READ
Subroutine __ANON__: not called CC=15 SCAR=54.8
335 0 $_DAU_R_SOCK = ${ $_DAU_R_SOCK_REF };
336 0 my ($_a3, $_auto);
337  
338 0 chomp($_id = <$_DAU_R_SOCK>),
339 chomp($_a3 = <$_DAU_R_SOCK>),
340 chomp($_len = <$_DAU_R_SOCK>);
341  
342 0 ▶ if (lc(substr $_a3, -1, 1) eq 'm') {
Branch: 2 branches
BranchTrueFalseTotal
if (lc substr($_a3, -1, 1) eq 'm') { } 0 0 0
elsif (lc substr($_a3, -1, 1) eq 'k') { } 0 0 0
343 0 $_auto = 1, chop $_a3; $_a3 *= 1024 * 1024;
344 } elsif (lc(substr $_a3, -1, 1) eq 'k') {
345 0 $_auto = 1, chop $_a3; $_a3 *= 1024;
346 }
347  
348 0 ▶ local $/; read($_DAU_R_SOCK, $/, $_len) if $_len;
Branch: 1 branch
BranchTrueFalseTotal
if $_len 0 0 0
349 0 my ($_fh, $_buf) = ($_obj->{ $_id }); local ($!, $.);
350  
351 # support special case; e.g. $/ = "\n>" for bioinformatics
352 # anchoring ">" at the start of line
353  
354 0 ▶ if (!$_auto) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $_auto) { } 0 0 0
elsif (not eof $_fh) { } 0 0 0
355 0 $. = 0, $_ret = read($_fh, $_buf, $_a3);
356 }
357 elsif (!eof($_fh)) {
358 0 ▶ if (length $/ > 1 && substr($/, 0, 1) eq "\n") {
Branch: 2 branches
BranchTrueFalseTotal
if (length $/ > 1 and substr($/, 0, 1) eq "\n") { } 0 0 0
elsif (defined($_ret = read($_fh, $_buf, $_a3))) { } 0 0 0
Condition0%0/3
length $/ > 1 and substr($/, 0, 1) eq "\n"
!ll&&!rl&&r
000
MC/DC0%0/2
length $/ > 1 and substr($/, 0, 1) eq "\n"
length $/ > 1 substr($/, 0, 1) eq "\n"
Truth table0%0/3
A and B
A= length $/ > 1B= substr($/, 0, 1) eq "\n"
ABresult
0X0
100
111
359 0 $_len = length($/) - 1;
360  
361 0 ▶ if (tell $_fh) {
Branch: 1 branch
BranchTrueFalseTotal
if (tell $_fh) { } 0 0 0
362 0 $_buf = substr($/, 1);
363 0 $_ret = read($_fh, $_buf, $_a3, length($_buf));
364 } else {
365 0 $_ret = read($_fh, $_buf, $_a3);
366 }
367  
368 0 ▶ if (defined $_ret) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_ret) 0 0 0
369 0 ▶ $. += 1 if eof($_fh);
Branch: 1 branch
BranchTrueFalseTotal
if eof $_fh 0 0 0
370 0 $_buf .= readline($_fh);
371  
372 0 ▶ substr($_buf, -$_len, $_len, '')
Branch: 1 branch
BranchTrueFalseTotal
if substr($_buf, -$_len) eq substr($/, 1) 0 0 0
373 if (substr($_buf, -$_len) eq substr($/, 1));
374 }
375 }
376 elsif (defined ($_ret = read($_fh, $_buf, $_a3))) {
377 0 ▶ $. += 1 if eof($_fh);
Branch: 1 branch
BranchTrueFalseTotal
if eof $_fh 0 0 0
378 0 $_buf .= readline($_fh);
379 }
380 }
381 else {
382 0 $_buf = '', $_ret = 0;
383 }
384  
385 0 ▶ if (defined $_ret) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_ret) { } 0 0 0
386 0 $_ret = length($_buf), $_buf = $_freeze->(\$_buf);
387 0 print {$_DAU_R_SOCK} "$.$LF" . length($_buf).$LF, $_buf, $_ret.$LF;
388 }
389 else {
390 0 print {$_DAU_R_SOCK} "$.$LF" . ( (0+$!) * -1 ).$LF;
391 }
392  
393 0 return;
394 },
395  
396 0 ▶ SHR_O_RLN.$LF => sub { # Handle READLINE
Subroutine __ANON__: not called CC=8 SCAR=42.8
397 0 $_DAU_R_SOCK = ${ $_DAU_R_SOCK_REF };
398  
399 0 chomp($_id = <$_DAU_R_SOCK>),
400 chomp($_len = <$_DAU_R_SOCK>);
401  
402 0 ▶ local $/; read($_DAU_R_SOCK, $/, $_len) if $_len;
Branch: 1 branch
BranchTrueFalseTotal
if $_len 0 0 0
403 0 my ($_fh, $_buf) = ($_obj->{ $_id }); local ($!, $.);
404  
405 # support special case; e.g. $/ = "\n>" for bioinformatics
406 # anchoring ">" at the start of line
407  
408 0 ▶ if (length $/ > 1 && substr($/, 0, 1) eq "\n" && !eof($_fh)) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $/ > 1 and substr($/, 0, 1) eq "\n" and not eof $_fh) { } 0 0 0
Condition0%0/6
length $/ > 1 and substr($/, 0, 1) eq "\n" and not eof $_fh
!ll&&!rl&&r
000
length $/ > 1 and substr($/, 0, 1) eq "\n"
!ll&&!rl&&r
000
MC/DC0%0/3
length $/ > 1 and substr($/, 0, 1) eq "\n" and not eof $_fh
length $/ > 1 substr($/, 0, 1) eq "\n" not eof $_fh
Truth table0%0/4
A and B and not(C)
A= length $/ > 1B= substr($/, 0, 1) eq "\n"C= not eof $_fh
ABCresult
0XX0
10X0
1100
1111
409 0 $_len = length($/) - 1;
410  
411 0 ▶ if (tell $_fh) {
Branch: 1 branch
BranchTrueFalseTotal
if (tell $_fh) { } 0 0 0
412 0 $_buf = substr($/, 1), $_buf .= readline($_fh);
413 } else {
414 0 $_buf = readline($_fh);
415 }
416  
417 0 ▶ substr($_buf, -$_len, $_len, '')
Branch: 1 branch
BranchTrueFalseTotal
if substr($_buf, -$_len) eq substr($/, 1) 0 0 0
418 if (substr($_buf, -$_len) eq substr($/, 1));
419 }
420 else {
421 0 $_buf = readline($_fh);
422 }
423  
424 0 ▶ if (defined $_buf) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_buf) { } 0 0 0
425 0 $_buf = $_freeze->(\$_buf);
426 0 print {$_DAU_R_SOCK} "$.$LF" . length($_buf).$LF, $_buf;
427 } else {
428 0 print {$_DAU_R_SOCK} "$.$LF" . ( (0+$!) * -1 ).$LF;
429 }
430  
431 0 return;
432 },
433  
434 0 ▶ SHR_O_PRI.$LF => sub { # Handle PRINT
Subroutine __ANON__: not called CC=1 SCAR=6.9
435 0 $_DAU_R_SOCK = ${ $_DAU_R_SOCK_REF };
436  
437 0 chomp($_id = <$_DAU_R_SOCK>),
438 chomp($_len = <$_DAU_R_SOCK>),
439  
440 read($_DAU_R_SOCK, my($_buf), $_len);
441 0 print {$_obj->{ $_id }} ${ $_thaw->($_buf) };
442  
443 0 return;
444 },
445  
446 0 ▶ SHR_O_WRI.$LF => sub { # Handle WRITE
Subroutine __ANON__: not called CC=6 SCAR=34.6
447 0 $_DAU_R_SOCK = ${ $_DAU_R_SOCK_REF };
448 2 ▶ use bytes;
Subroutine BEGIN: called CC=1 SCAR=0.0
449  
450 0 chomp($_id = <$_DAU_R_SOCK>),
451 chomp($_len = <$_DAU_R_SOCK>),
452  
453 read($_DAU_R_SOCK, my($_buf), $_len);
454  
455 0 my $_wrote = 0;
456  
457 WRITE: {
458 0 $_wrote += ( syswrite (
459 $_obj->{ $_id }, $_buf, length($_buf) - $_wrote, $_wrote
460 0 ▶ )) or do {
Branch: 1 branch
BranchTrueFalseTotal
$_wrote += syswrite($_obj->{$_id}, $_buf, length($_buf) - $_wrote, $_wrote) or do { unless (defined $_wrote) { redo WRITE if $!{"EINTR"} or $!{"EAGAIN"} or $!{"EWOULDBLOCK"}; print {$_DAU_R_SOCK;} '' . $LF; return; } } 0 0 0
461 0 ▶ unless ( defined $_wrote ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $_wrote) 0 0 0
462 0 ▶ redo WRITE if $!{EINTR} || $!{EAGAIN} || $!{EWOULDBLOCK};
Branch: 1 branch
BranchTrueFalseTotal
if $!{"EINTR"} or $!{"EAGAIN"} or $!{"EWOULDBLOCK"} 0 0 0
Condition0%0/6
$!{"EINTR"} or $!{"EAGAIN"} or $!{"EWOULDBLOCK"}
l!l&&r!l&&!r
000
$!{"EINTR"} or $!{"EAGAIN"}
l!l&&r!l&&!r
000
MC/DC0%0/3
$!{"EINTR"} or $!{"EAGAIN"} or $!{"EWOULDBLOCK"}
$!{"EINTR"} $!{"EAGAIN"} $!{"EWOULDBLOCK"}
Truth table0%0/4
A or B or C
A= $!{"EINTR"}B= $!{"EAGAIN"}C= $!{"EWOULDBLOCK"}
ABCresult
1XX1
01X1
0011
0000
463 0 print {$_DAU_R_SOCK} ''.$LF;
464  
465 0 return;
466 }
467 };
468 }
469  
470 0 print {$_DAU_R_SOCK} $_wrote.$LF;
471  
472 0 return;
473 },
474  
475 2 );
476  
477 0 ▶ sub _init_mgr {
Subroutine _init_mgr: not called CC=3 SCAR=24.8
478 0 my $_function;
479 0 ( $_DAU_R_SOCK_REF, $_obj, $_function, $_freeze, $_thaw ) = @_;
480  
481 0 for my $key ( keys %_output_function ) {
482 0 ▶ last if exists($_function->{$key});
Branch: 1 branch
BranchTrueFalseTotal
if exists $_function->{$key} 0 0 0
483 0 $_function->{$key} = $_output_function{$key};
484 }
485  
486 0 return;
487 }
488 }
489  
490 ###############################################################################
491 ## ----------------------------------------------------------------------------
492 ## Object package.
493 ##
494 ###############################################################################
495  
496 ## Items below are folded into MCE::Shared::Object.
497  
498 package # hide from rpm
499 2 MCE::Shared::Object;
500  
501 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
502 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
503  
504 2 ▶no warnings qw( threads recursion uninitialized numeric once );
Subroutine BEGIN: called CC=1 SCAR=0.0
505  
506 2 ▶use bytes;
Subroutine BEGIN: called CC=1 SCAR=0.0
507  
508 2 ▶no overloading;
Subroutine BEGIN: called CC=1 SCAR=0.0
509  
510 2 ▶my $_is_MSWin32 = ($^O eq 'MSWin32') ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$^O eq 'MSWin32' ? : 0 2 2
511  
512 2 my ($_DAT_LOCK, $_DAT_W_SOCK, $_DAU_W_SOCK, $_dat_ex, $_dat_un, $_chn, $_obj,
513 $_freeze, $_thaw);
514  
515 4 ▶sub _init_handle {
Subroutine _init_handle: called CC=1 SCAR=0.0
516 4 ($_DAT_LOCK, $_DAT_W_SOCK, $_DAU_W_SOCK, $_dat_ex, $_dat_un, $_chn, $_obj,
517 $_freeze, $_thaw) = @_;
518  
519 4 return;
520 }
521  
522 9 ▶sub CLOSE {
Subroutine CLOSE: called CC=1 SCAR=0.0
523 9 _req1('O~CLO', $_[0]->[0].$LF);
524 }
525  
526 9 ▶sub OPEN {
Subroutine OPEN: called CC=21 SCAR=40.2
527 9 my ($_id, $_fd, $_buf) = (shift()->[0]);
528 9 ▶ return unless defined $_[0];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $_[0] 0 9 9
529  
530 9 ▶ if (ref $_[-1] && reftype($_[-1]) ne 'GLOB') {
Branch: 4 branches
BranchTrueFalseTotal
if (ref $_[-1] and builtin::reftype($_[-1]) ne 'GLOB') { } 0 9 9
elsif (@_ == 1 and ref $_[0] and defined($_fd = fileno $_[0])) { } 0 9 9
elsif (@_ == 2 and ref $_[1] and defined($_fd = fileno $_[1])) { } 0 9 9
elsif (not ref $_[-1]) { } 9 0 9
Condition33%1/3
ref $_[-1] and builtin::reftype($_[-1]) ne "GLOB"
!ll&&!rl&&r
900
MC/DC0%0/2
ref $_[-1] and builtin::reftype($_[-1]) ne "GLOB"
ref $_[-1] builtin::reftype($_[-1]) ne "GLOB"
Truth table33%1/3
A and B
A= ref $_[-1]B= builtin::reftype($_[-1]) ne "GLOB"
ABresult
0X0
100
111
531 0 _croak("open error: not a GLOB reference");
532 }
533 ▶ elsif (@_ == 1 && ref $_[0] && defined($_fd = fileno($_[0]))) {
Condition33%2/6
@_ == 1 and ref $_[0] and defined($_fd = fileno $_[0])
!ll&&!rl&&r
900
@_ == 1 and ref $_[0]
!ll&&!rl&&r
900
MC/DC0%0/3
@_ == 1 and ref $_[0] and defined($_fd = fileno $_[0])
@_ == 1 ref $_[0] defined($_fd = fileno $_[0])
Truth table25%1/4
A and B and C
A= @_ == 1B= ref $_[0]C= defined($_fd = fileno $_[0])
ABCresult
0XX0
10X0
1100
1111
534 0 $_buf = $_freeze->([ "<&=$_fd" ]);
535 }
536 ▶ elsif (@_ == 2 && ref $_[1] && defined($_fd = fileno($_[1]))) {
Condition33%2/6
@_ == 2 and ref $_[1] and defined($_fd = fileno $_[1])
!ll&&!rl&&r
900
@_ == 2 and ref $_[1]
!ll&&!rl&&r
090
MC/DC0%0/3
@_ == 2 and ref $_[1] and defined($_fd = fileno $_[1])
@_ == 2 ref $_[1] defined($_fd = fileno $_[1])
Truth table25%1/4
A and B and C
A= @_ == 2B= ref $_[1]C= defined($_fd = fileno $_[1])
ABCresult
0XX0
10X0
1100
1111
537 0 $_buf = $_freeze->([ $_[0]."&=$_fd" ]);
538 }
539 elsif (!ref $_[-1]) {
540 9 ▶ $_fd = ($_[-1] =~ /&=(\d+)$/) ? $1 : -1;
Branch: 1 branch
BranchTrueFalseTotal
$_[-1] =~ /&=(\d+)$/ ? : 0 9 9
541 9 $_buf = $_freeze->([ @_ ]);
542 }
543 else {
544 0 _croak("open error: unsupported use-case");
545 }
546  
547 9 ▶ if ($_fd > $_max_fd && !$INC{'IO/FDPass.pm'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_fd > $_max_fd and not $INC{"IO/FDPass.pm"}) 0 9 9
Condition33%1/3
$_fd > $_max_fd and not $INC{"IO/FDPass.pm"}
!ll&&!rl&&r
900
MC/DC0%0/2
$_fd > $_max_fd and not $INC{"IO/FDPass.pm"}
$_fd > $_max_fd not $INC{"IO/FDPass.pm"}
Truth table33%1/3
A and not(B)
A= $_fd > $_max_fdB= not $INC{"IO/FDPass.pm"}
ABresult
0X0
100
111
548 0 _croak(
549 "\nSharing a handle object while the server is running\n",
550 "requires the IO::FDPass module.\n\n"
551 );
552 }
553  
554 9 ▶ local $\ = undef if (defined $\);
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 9 9
555 9 ▶ local $/ = $LF if ($/ ne $LF);
Branch: 1 branch
BranchTrueFalseTotal
if $/ ne $LF 0 9 9
556 9 local $MCE::Signal::SIG;
557  
558 9 my $_err;
559  
560 {
561 9 local $MCE::Signal::IPC = 1;
562 9 ▶ $_is_MSWin32 ? CORE::lock $_DAT_LOCK : $_dat_ex->();
Branch: 1 branch
BranchTrueFalseTotal
$_is_MSWin32 ? : 0 9 9
563  
564 9 print({$_DAT_W_SOCK} 'O~OPN'.$LF . $_chn.$LF),
565 9 print({$_DAU_W_SOCK} $_id.$LF . $_fd.$LF . length($_buf).$LF . $_buf);
566 9 <$_DAU_W_SOCK>;
567  
568 9 ▶ IO::FDPass::send( fileno $_DAU_W_SOCK, fileno $_fd ) if ($_fd > $_max_fd);
Branch: 1 branch
BranchTrueFalseTotal
if $_fd > $_max_fd 0 9 9
569 9 chomp($_err = <$_DAU_W_SOCK>);
570  
571 9 ▶ $_dat_un->() if !$_is_MSWin32;
Branch: 1 branch
BranchTrueFalseTotal
unless $_is_MSWin32 9 0 9
572 }
573  
574 9 ▶ CORE::kill($MCE::Signal::SIG, $$) if $MCE::Signal::SIG;
Branch: 1 branch
BranchTrueFalseTotal
if $MCE::Signal::SIG 0 9 9
575  
576 9 ▶ if ($_err) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_err) { } 0 9 9
577 0 $! = $_err;
578 0 '';
579 } else {
580 9 $! = 0;
581 9 1;
582 }
583 }
584  
585 7 ▶sub READ {
Subroutine READ: called CC=12 SCAR=25.9
586 7 ▶ local $\ = undef if (defined $\);
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 7 7
587 7 local $MCE::Signal::SIG;
588  
589 7 my ($_len, $_ret);
590  
591 {
592 7 local $MCE::Signal::IPC = 1;
593 7 ▶ $_is_MSWin32 ? CORE::lock $_DAT_LOCK : $_dat_ex->();
Branch: 1 branch
BranchTrueFalseTotal
$_is_MSWin32 ? : 0 7 7
594  
595 7 print({$_DAT_W_SOCK} 'O~REA'.$LF . $_chn.$LF),
596 7 print({$_DAU_W_SOCK} $_[0]->[0].$LF . $_[2].$LF . length($/).$LF . $/);
597  
598 7 ▶ local $/ = $LF if ($/ ne $LF);
Branch: 1 branch
BranchTrueFalseTotal
if $/ ne $LF 0 7 7
599 7 chomp($_ret = <$_DAU_W_SOCK>);
600 7 chomp($_len = <$_DAU_W_SOCK>);
601  
602 7 ▶ if ($_len && $_len > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_len and $_len > 0) 7 0 7
Condition33%1/3
$_len and $_len > 0
!ll&&!rl&&r
007
MC/DC0%0/2
$_len and $_len > 0
$_len $_len > 0
Truth table33%1/3
A and B
A= $_lenB= $_len > 0
ABresult
0X0
100
111
603 7 read($_DAU_W_SOCK, my $_buf, $_len);
604 7 chomp($_len = <$_DAU_W_SOCK>);
605  
606 7 my $_ref = \$_[1];
607 7 ▶ if (defined $_[3]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[3]) { } 1 6 7
608 2 ▶ no bytes;
Subroutine BEGIN: called CC=1 SCAR=0.0
609 1 substr($$_ref, $_[3], length($$_ref) - $_[3], '');
610 1 substr($$_ref, $_[3], $_len, ${ $_thaw->($_buf) });
611 }
612 else {
613 6 $$_ref = ${ $_thaw->($_buf) };
614 }
615 }
616  
617 7 ▶ $_dat_un->() if !$_is_MSWin32;
Branch: 1 branch
BranchTrueFalseTotal
unless $_is_MSWin32 7 0 7
618 }
619  
620 7 ▶ CORE::kill($MCE::Signal::SIG, $$) if $MCE::Signal::SIG;
Branch: 1 branch
BranchTrueFalseTotal
if $MCE::Signal::SIG 0 7 7
621  
622 7 ▶ if ($_len) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_len) { } 6 1 7
623 6 ▶ if ($_len < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_len < 0) 0 6 6
624 0 $. = 0, $! = $_len * -1;
625 0 return undef;
626 }
627 }
628 else {
629 1 my $_ref = \$_[1];
630 1 ▶ if (defined $_[3]) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_[3]) { } 0 1 1
631 2 ▶ no bytes;
Subroutine BEGIN: called CC=1 SCAR=0.0
632 0 substr($$_ref, $_[3], length($$_ref) - $_[3], '');
633 }
634 else {
635 1 $$_ref = '';
636 }
637 }
638  
639 7 $. = $_ret, $! = 0;
640 7 $_len;
641 }
642  
643 29 ▶sub READLINE {
Subroutine READLINE: called CC=11 SCAR=25.2
644 29 ▶ local $\ = undef if (defined $\);
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 29 29
645 29 local $MCE::Signal::SIG;
646  
647 29 my ($_buf, $_len, $_ret);
648  
649 {
650 29 local $MCE::Signal::IPC = 1;
651 29 ▶ $_is_MSWin32 ? CORE::lock $_DAT_LOCK : $_dat_ex->();
Branch: 1 branch
BranchTrueFalseTotal
$_is_MSWin32 ? : 0 29 29
652  
653 29 print({$_DAT_W_SOCK} 'O~RLN'.$LF . $_chn.$LF),
654 29 print({$_DAU_W_SOCK} $_[0]->[0].$LF . length($/).$LF . $/);
655  
656 29 ▶ local $/ = $LF if ($/ ne $LF);
Branch: 1 branch
BranchTrueFalseTotal
if $/ ne $LF 0 29 29
657 29 chomp($_ret = <$_DAU_W_SOCK>);
658 29 chomp($_len = <$_DAU_W_SOCK>);
659  
660 29 ▶ if ($_len && $_len > 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_len and $_len > 0) 27 2 29
Condition66%2/3
$_len and $_len > 0
!ll&&!rl&&r
2027
MC/DC50%1/2
$_len and $_len > 0
$_len $_len > 0
Truth table66%2/3
A and B
A= $_lenB= $_len > 0
ABresult
0X0
100
111
661 27 read($_DAU_W_SOCK, $_buf, $_len);
662 }
663  
664 29 ▶ $_dat_un->() if !$_is_MSWin32;
Branch: 1 branch
BranchTrueFalseTotal
unless $_is_MSWin32 29 0 29
665 }
666  
667 29 ▶ CORE::kill($MCE::Signal::SIG, $$) if $MCE::Signal::SIG;
Branch: 1 branch
BranchTrueFalseTotal
if $MCE::Signal::SIG 0 29 29
668  
669 29 ▶ if ($_len && $_len < 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_len and $_len < 0) 0 29 29
Condition66%2/3
$_len and $_len < 0
!ll&&!rl&&r
2270
MC/DC0%0/2
$_len and $_len < 0
$_len $_len < 0
Truth table66%2/3
A and B
A= $_lenB= $_len < 0
ABresult
0X0
100
111
670 0 $. = 0, $! = $_len * -1;
671 0 return undef;
672 }
673  
674 29 $. = $_ret, $! = 0;
675 29 ▶ $_buf ? ${ $_thaw->($_buf) } : $_buf;
Branch: 1 branch
BranchTrueFalseTotal
$_buf ? : 27 2 29
676 }
677  
678 212 ▶sub PRINT {
Subroutine PRINT: called CC=4 SCAR=14.5
679 2 ▶ no bytes;
Subroutine BEGIN: called CC=1 SCAR=0.0
680 212 my $_id = shift()->[0];
681 212 ▶ my $_buf = join(defined $, ? $, : "", @_);
Branch: 1 branch
BranchTrueFalseTotal
defined $, ? : 0 212 212
682  
683 212 ▶ $_buf .= $\ if defined $\;
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 212 212
684  
685 212 ▶ if (length $_buf) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $_buf) { } 212 0 212
686 212 $_buf = $_freeze->(\$_buf);
687 212 _req2('O~PRI', $_id.$LF . length($_buf).$LF, $_buf);
688 } else {
689 0 1;
690 }
691 }
692  
693 10 ▶sub PRINTF {
Subroutine PRINTF: called CC=2 SCAR=7.1
694 2 ▶ no bytes;
Subroutine BEGIN: called CC=1 SCAR=0.0
695 10 my $_id = shift()->[0];
696 10 my $_buf = sprintf(shift, @_);
697  
698 10 ▶ if (length $_buf) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $_buf) { } 10 0 10
699 10 $_buf = $_freeze->(\$_buf);
700 10 _req2('O~PRI', $_id.$LF . length($_buf).$LF, $_buf);
701 } else {
702 0 1;
703 }
704 }
705  
706 1 ▶sub WRITE {
Subroutine WRITE: called CC=11 SCAR=29.5
707 1 my $_id = shift()->[0];
708  
709 1 ▶ local $\ = undef if (defined $\);
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 1 1
710 1 ▶ local $/ = $LF if ($/ ne $LF);
Branch: 1 branch
BranchTrueFalseTotal
if $/ ne $LF 0 1 1
711 1 local $MCE::Signal::SIG;
712  
713 1 my $_ret;
714  
715 {
716 1 local $MCE::Signal::IPC = 1;
717 1 ▶ $_is_MSWin32 ? CORE::lock $_DAT_LOCK : $_dat_ex->();
Branch: 1 branch
BranchTrueFalseTotal
$_is_MSWin32 ? : 0 1 1
718  
719 1 ▶ if (@_ == 1 || (@_ == 2 && $_[1] == length($_[0]))) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ == 1 or @_ == 2 and $_[1] == length $_[0]) { } 1 0 1
Condition33%2/6
@_ == 1 or @_ == 2 and $_[1] == length $_[0]
l!l&&r!l&&!r
010
@_ == 2 and $_[1] == length $_[0]
!ll&&!rl&&r
001
MC/DC0%0/3
@_ == 1 or @_ == 2 and $_[1] == length $_[0]
@_ == 1 @_ == 2 $_[1] == length $_[0]
Truth table25%1/4
A or B and C
A= @_ == 1B= @_ == 2C= $_[1] == length $_[0]
ABCresult
1XX1
0111
00X0
0100
720 1 print({$_DAT_W_SOCK} 'O~WRI'.$LF . $_chn.$LF),
721 1 print({$_DAU_W_SOCK} $_id.$LF . length($_[0]).$LF, $_[0]);
722 }
723 else {
724 0 ▶ my $_buf = substr($_[0], ($_[2] || 0), $_[1]);
Condition0%0/2
$_[2] || 0
l!l
00
MC/DC0%0/1
$_[2] || 0
$_[2]
Truth table0%0/2
A
A= $_[2]
Aresult
11
00
725 0 print({$_DAT_W_SOCK} 'O~WRI'.$LF . $_chn.$LF),
726 0 print({$_DAU_W_SOCK} $_id.$LF . length($_buf).$LF, $_buf);
727 }
728  
729 1 chomp($_ret = <$_DAU_W_SOCK>);
730  
731 1 ▶ $_dat_un->() if !$_is_MSWin32;
Branch: 1 branch
BranchTrueFalseTotal
unless $_is_MSWin32 1 0 1
732 }
733  
734 1 ▶ CORE::kill($MCE::Signal::SIG, $$) if $MCE::Signal::SIG;
Branch: 1 branch
BranchTrueFalseTotal
if $MCE::Signal::SIG 0 1 1
735  
736 1 ▶ (length $_ret) ? $_ret : undef;
Branch: 1 branch
BranchTrueFalseTotal
length $_ret ? : 1 0 1
737 }
738  
739 2 1;
740  
741 __END__
« Shared.pm ↑ Summary Shared/Cache.pm »