MCE/Core/Manager.pm

filter: Statementstmt 41.5% 217 / 522 Branchbran 31.1% 91 / 292 Conditioncond 28.6% 35 / 122 MC/DCmcdc 12.0% 9 / 75 Subroutinesub 52.6% 20 / 38 Podpod n/a totaltotal 35.4% 372 / 1049 SCAR 92.8
CC
203
Cov
37%
_output_loop
1066.6
__ANON__
650.0
__ANON__
342.0
CRAP 10682.2
« MCE.pm ↑ Summary MCE/Child.pm »
1 ###############################################################################
2 ## ----------------------------------------------------------------------------
3 ## Core methods for the manager process.
4 ##
5 ## This package provides the loop and relevant methods used internally by the
6 ## manager process.
7 ##
8 ## There is no public API.
9 ##
10 ###############################################################################
11  
12 package MCE::Core::Manager;
13  
14 85 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 85 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
16  
17 85 our $VERSION = '1.889';
18  
19 ## no critic (BuiltinFunctions::ProhibitStringyEval)
20 ## no critic (TestingAndDebugging::ProhibitNoStrict)
21  
22 ## Items below are folded into MCE.
23  
24 package # hide from rpm
25 MCE;
26  
27 85 ▶no warnings qw( threads recursion uninitialized );
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 ## The POSIX module has many symbols. Try not loading it simply
30 ## to have WNOHANG. The following covers most platforms.
31  
32 use constant {
33 85 ▶ _WNOHANG => ( $INC{'POSIX.pm'} )
Branch: 2 branches
BranchTrueFalseTotal
$INC{'POSIX.pm'} ? : 0 85 85
$^O eq 'solaris' ? : 0 85 85
34 ? &POSIX::WNOHANG : ( $^O eq 'solaris' ) ? 64 : 1
35 85 ▶};
Subroutine BEGIN: called CC=3 SCAR=11.0
36  
37 ###############################################################################
38 ## ----------------------------------------------------------------------------
39 ## Call on task_end after task completion.
40 ##
41 ###############################################################################
42  
43 sub _task_end {
44  
45 214 ▶ my ($self, $_task_id) = @_;
Subroutine _task_end: called CC=6 SCAR=18.5
46  
47 214 @_ = ();
48  
49 214 ▶ if (defined $self->{user_tasks}) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $self->{'user_tasks'}) { } 180 34 214
elsif (defined $self->{'task_end'}) { } 0 34 34
50 my $_task_end = (exists $self->{user_tasks}->[$_task_id]->{task_end})
51 ? $self->{user_tasks}->[$_task_id]->{task_end}
52 180 ▶ : $self->{task_end};
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{'user_tasks'}[$_task_id]{'task_end'} ? : 0 180 180
53  
54 180 ▶ if (defined $_task_end) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_task_end) 144 36 180
55 my $_task_name = (exists $self->{user_tasks}->[$_task_id]->{task_name})
56 ? $self->{user_tasks}->[$_task_id]->{task_name}
57 144 ▶ : $self->{task_name};
Branch: 1 branch
BranchTrueFalseTotal
exists $self->{'user_tasks'}[$_task_id]{'task_name'} ? : 144 0 144
58  
59 144 $_task_end->($self, $_task_id, $_task_name);
60 }
61 }
62 elsif (defined $self->{task_end}) {
63 0 $self->{task_end}->($self, 0, $self->{task_name});
64 }
65  
66 214 return;
67 }
68  
69 ###############################################################################
70 ## ----------------------------------------------------------------------------
71 ## Process output.
72 ##
73 ## Awaits and processes events from workers. The sendto/do methods tag the
74 ## output accordingly. The hash structure below is key-driven.
75 ##
76 ###############################################################################
77  
78 85 my %_sendto_fhs;
79  
80 sub _sendto_fhs_close {
81 502 ▶ for my $_p (keys %_sendto_fhs) {
Subroutine _sendto_fhs_close: called CC=2 SCAR=11.6
82 0 close $_sendto_fhs{$_p};
83 0 delete $_sendto_fhs{$_p};
84 }
85 }
86  
87 sub _sendto_fhs_get {
88 0 ▶ my ($self, $_fd) = @_;
Subroutine _sendto_fhs_get: not called CC=5 SCAR=34.0
89  
90 0 ▶ $_sendto_fhs{$_fd} || do {
Branch: 1 branch
BranchTrueFalseTotal
$_sendto_fhs{$_fd} or do { $_sendto_fhs{$_fd} = "IO::Handle"->new; $_sendto_fhs{$_fd}->fdopen($_fd, "w") or _croak("Cannot open file descriptor ($_fd): $!"); binmode $_sendto_fhs{$_fd}; if (not exists $self->{"flush_file"} or $self->{"flush_file"}) { local $!; $_sendto_fhs{$_fd}->autoflush(1); } ; $_sendto_fhs{$_fd} } 0 0 0
91  
92 0 $_sendto_fhs{$_fd} = IO::Handle->new();
93 0 ▶ $_sendto_fhs{$_fd}->fdopen($_fd, 'w')
Branch: 1 branch
BranchTrueFalseTotal
$_sendto_fhs{$_fd}->fdopen($_fd, "w") or _croak("Cannot open file descriptor ($_fd): $!") 0 0 0
94 or _croak "Cannot open file descriptor ($_fd): $!";
95  
96 0 binmode $_sendto_fhs{$_fd};
97  
98 0 ▶ if (!exists $self->{flush_file} || $self->{flush_file}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $self->{"flush_file"} or $self->{"flush_file"}) 0 0 0
Condition0%0/3
not exists $self->{"flush_file"} or $self->{"flush_file"}
l!l&&r!l&&!r
000
MC/DC0%0/2
not exists $self->{"flush_file"} or $self->{"flush_file"}
not exists $self->{"flush_file"} $self->{"flush_file"}
Truth table0%0/3
not(A) or B
A= not exists $self->{"flush_file"}B= $self->{"flush_file"}
ABresult
1X1
011
000
99 0 local $!;
100 0 $_sendto_fhs{$_fd}->autoflush(1)
101 }
102  
103 0 $_sendto_fhs{$_fd};
104 };
105 }
106  
107 sub _output_loop {
108  
109 142 ▶ my ( $self, $_input_data, $_input_glob, $_plugin_function,
Subroutine _output_loop: called CC=61 SCAR=69.7
110 $_plugin_loop_begin, $_plugin_loop_end ) = @_;
111  
112 142 @_ = ();
113  
114 my (
115 142 $_aborted, $_eof_flag, $_max_retries, $_syn_flag, $_win32_ipc,
116 $_cb, $_chunk_id, $_chunk_size, $_file, $_size_completed, $_wa,
117 @_is_c_ref, @_is_h_ref, @_is_q_ref, $_on_post_exit, $_on_post_run,
118 $_has_user_tasks, $_sess_dir, $_task_id, $_user_error, $_user_output,
119 $_input_size, $_offset_pos, $_single_dim, @_gather, $_cs_one_flag,
120 $_exit_id, $_exit_pid, $_exit_status, $_exit_wid, $_len, $_sync_cnt,
121 $_BSB_W_SOCK, $_BSB_R_SOCK, $_DAT_R_SOCK, $_DAU_R_SOCK, $_MCE_STDERR,
122 $_I_FLG, $_O_FLG, $_I_SEP, $_O_SEP, $_RS, $_RS_FLG, $_MCE_STDOUT,
123 @_delay_wid
124 );
125  
126 ## -------------------------------------------------------------------------
127 ## Callback return.
128  
129 my $_cb_reply = sub {
130 285 ▶ local $\ = $_O_SEP if ($_O_FLG);
Subroutine __ANON__: called CC=5 SCAR=16.1
Branch: 1 branch
BranchTrueFalseTotal
if $_O_FLG 0 285 285
131 285 ▶ local $/ = $_I_SEP if ($_I_FLG);
Branch: 1 branch
BranchTrueFalseTotal
if $_I_FLG 0 285 285
132  
133 85 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
134  
135 285 ▶ if ( $_wa == WANTS_UNDEF ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($_wa == 0) { } 274 11 285
elsif ($_wa == 1) { } 2 9 11
136 274 $_cb->(@_);
137 274 return;
138 }
139 elsif ( $_wa == WANTS_ARRAY ) {
140 2 my @_ret = $_cb->(@_);
141 2 my $_buf = $self->{freeze}(\@_ret);
142  
143 2 return print {$_DAU_R_SOCK} length($_buf).$LF, $_buf;
144 }
145  
146 9 my $_ret = $_cb->(@_);
147 9 my $_buf = $self->{freeze}([ $_ret ]);
148  
149 9 return print {$_DAU_R_SOCK} length($_buf).$LF, $_buf;
150 142 };
151  
152 ## -------------------------------------------------------------------------
153 ## Create hash structure containing various output functions.
154  
155 my %_core_output_function = (
156  
157 OUTPUT_W_ABT.$LF => sub { # Worker has aborted
158 0 ▶ $_aborted = 1;
Subroutine __ANON__: not called CC=1 SCAR=6.9
159 0 return;
160 },
161  
162 OUTPUT_W_DNE.$LF => sub { # Worker has completed
163 428 ▶ chomp($_task_id = <$_DAU_R_SOCK>);
Subroutine __ANON__: called CC=10 SCAR=26.7
164 856 $self->{_total_running} -= 1;
165  
166 856 ▶ if ($_has_user_tasks && $_task_id >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_has_user_tasks and $_task_id >= 0) 347 81 428
Condition66%2/3
$_has_user_tasks and $_task_id >= 0
!ll&&!rl&&r
810347
MC/DC50%1/2
$_has_user_tasks and $_task_id >= 0
$_has_user_tasks $_task_id >= 0
Truth table66%2/3
A and B
A= $_has_user_tasksB= $_task_id >= 0
ABresult
0X0
100
111
167 347 $self->{_task}->[$_task_id]->{_total_running} -= 1;
168 }
169  
170 my $_total_running = ($_has_user_tasks)
171 ? $self->{_task}->[$_task_id]->{_total_running}
172 856 ▶ : $self->{_total_running};
Branch: 1 branch
BranchTrueFalseTotal
$_has_user_tasks ? : 347 81 428
173  
174 856 ▶ if ($_task_id == 0 && defined $_syn_flag && $_sync_cnt) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_task_id == 0 and defined $_syn_flag and $_sync_cnt) 0 428 428
Condition50%3/6
$_task_id == 0 and defined $_syn_flag and $_sync_cnt
!ll&&!rl&&r
42800
$_task_id == 0 and defined $_syn_flag
!ll&&!rl&&r
1462820
MC/DC0%0/3
$_task_id == 0 and defined $_syn_flag and $_sync_cnt
$_task_id == 0 defined $_syn_flag $_sync_cnt
Truth table50%2/4
A and B and C
A= $_task_id == 0B= defined $_syn_flagC= $_sync_cnt
ABCresult
0XX0
10X0
1100
1111
175 0 ▶ if ($_sync_cnt == $_total_running) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_sync_cnt == $_total_running) 0 0 0
176 0 for my $_i (1 .. $_total_running) {
177 0 syswrite($_BSB_W_SOCK, $LF);
178 }
179 0 undef $_syn_flag;
180 }
181 }
182  
183 856 ▶ _task_end($self, $_task_id) unless $_total_running;
Branch: 1 branch
BranchTrueFalseTotal
unless $_total_running 214 214 428
184  
185 856 return;
186 },
187  
188 ## ----------------------------------------------------------------------
189  
190 OUTPUT_W_EXT.$LF => sub { # Worker has exited
191 0 ▶ chomp($_task_id = <$_DAU_R_SOCK>);
Subroutine __ANON__: not called CC=25 SCAR=64.8
192  
193 0 $self->{_total_exited} += 1;
194 0 $self->{_total_running} -= 1;
195 0 $self->{_total_workers} -= 1;
196  
197 0 ▶ if ($_has_user_tasks && $_task_id >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_has_user_tasks and $_task_id >= 0) 0 0 0
Condition0%0/3
$_has_user_tasks and $_task_id >= 0
!ll&&!rl&&r
000
MC/DC0%0/2
$_has_user_tasks and $_task_id >= 0
$_has_user_tasks $_task_id >= 0
Truth table0%0/3
A and B
A= $_has_user_tasksB= $_task_id >= 0
ABresult
0X0
100
111
198 0 $self->{_task}->[$_task_id]->{_total_running} -= 1;
199 0 $self->{_task}->[$_task_id]->{_total_workers} -= 1;
200 }
201  
202 my $_total_running = ($_has_user_tasks)
203 ? $self->{_task}->[$_task_id]->{_total_running}
204 0 ▶ : $self->{_total_running};
Branch: 1 branch
BranchTrueFalseTotal
$_has_user_tasks ? : 0 0 0
205  
206 0 ▶ if ($_task_id == 0 && defined $_syn_flag && $_sync_cnt) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_task_id == 0 and defined $_syn_flag and $_sync_cnt) 0 0 0
Condition0%0/6
$_task_id == 0 and defined $_syn_flag and $_sync_cnt
!ll&&!rl&&r
000
$_task_id == 0 and defined $_syn_flag
!ll&&!rl&&r
000
MC/DC0%0/3
$_task_id == 0 and defined $_syn_flag and $_sync_cnt
$_task_id == 0 defined $_syn_flag $_sync_cnt
Truth table0%0/4
A and B and C
A= $_task_id == 0B= defined $_syn_flagC= $_sync_cnt
ABCresult
0XX0
10X0
1100
1111
207 0 ▶ if ($_sync_cnt == $_total_running) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_sync_cnt == $_total_running) 0 0 0
208 0 for my $_i (1 .. $_total_running) {
209 0 syswrite($_BSB_W_SOCK, $LF);
210 }
211 0 undef $_syn_flag;
212 }
213 }
214  
215 0 my ($_exit_msg, $_retry_buf) = ('', '');
216  
217 0 chomp($_exit_wid = <$_DAU_R_SOCK>),
218 chomp($_exit_pid = <$_DAU_R_SOCK>),
219 chomp($_exit_status = <$_DAU_R_SOCK>),
220 chomp($_exit_id = <$_DAU_R_SOCK>),
221 chomp($_len = <$_DAU_R_SOCK>);
222  
223 0 ▶ read($_DAU_R_SOCK, $_exit_msg, $_len) if ($_len);
Branch: 1 branch
BranchTrueFalseTotal
if $_len 0 0 0
224  
225 0 chomp($_len = <$_DAU_R_SOCK>);
226  
227 0 ▶ read($_DAU_R_SOCK, $_retry_buf, $_len) if ($_len);
Branch: 1 branch
BranchTrueFalseTotal
if $_len 0 0 0
228  
229 0 ▶ if (abs($_exit_status) > abs($self->{_wrk_status})) {
Branch: 1 branch
BranchTrueFalseTotal
if (abs $_exit_status > abs $self->{"_wrk_status"}) 0 0 0
230 0 $self->{_wrk_status} = $_exit_status;
231 }
232  
233 ## Reap child/thread. Note: Win32 uses negative PIDs.
234  
235 0 local ($!, $?);
236  
237 0 ▶ if ($_exit_pid =~ /^PID_(-?\d+)/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($_exit_pid =~ /^PID_(-?\d+)/) { } 0 0 0
elsif ($_exit_pid =~ /^TID_(\d+)/) { } 0 0 0
238 0 my $_pid = $1; my $_list = $self->{_pids};
239 0 for my $i (0 .. @{ $_list }) {
240 0 ▶ if ($_list->[$i] && $_list->[$i] == $_pid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_list->[$i] and $_list->[$i] == $_pid) 0 0 0
Condition0%0/3
$_list->[$i] and $_list->[$i] == $_pid
!ll&&!rl&&r
000
MC/DC0%0/2
$_list->[$i] and $_list->[$i] == $_pid
$_list->[$i] $_list->[$i] == $_pid
Truth table0%0/3
A and B
A= $_list->[$i]B= $_list->[$i] == $_pid
ABresult
0X0
100
111
241 0 waitpid $_pid, 0;
242 0 $self->{_pids}->[$i] = undef;
243 0 last;
244 }
245 }
246 }
247 elsif ($_exit_pid =~ /^TID_(\d+)/) {
248 0 my $_tid = $1; my $_list = $self->{_tids};
249 0 for my $i (0 .. @{ $_list }) {
250 0 ▶ if ($_list->[$i] && $_list->[$i] == $_tid) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_list->[$i] and $_list->[$i] == $_tid) 0 0 0
Condition0%0/3
$_list->[$i] and $_list->[$i] == $_tid
!ll&&!rl&&r
000
MC/DC0%0/2
$_list->[$i] and $_list->[$i] == $_tid
$_list->[$i] $_list->[$i] == $_tid
Truth table0%0/3
A and B
A= $_list->[$i]B= $_list->[$i] == $_tid
ABresult
0X0
100
111
251 0 eval { $self->{_thrs}->[$i]->join() };
252 0 $self->{_thrs}->[$i] = undef;
253 0 $self->{_tids}->[$i] = undef;
254 0 last;
255 }
256 }
257 }
258  
259 ## Call on_post_exit callback if defined. Otherwise, append status
260 ## information if on_post_run is defined for later retrieval.
261  
262 0 ▶ if (defined $_on_post_exit) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $_on_post_exit) { } 0 0 0
elsif (defined $_on_post_run) { } 0 0 0
263 0 $self->{_exited_wid} = $_exit_wid;
264  
265 0 ▶ if (length($_retry_buf)) {
Branch: 1 branch
BranchTrueFalseTotal
if (length $_retry_buf) { } 0 0 0
266 0 $self->{_retry} = $self->{thaw}($_retry_buf);
267 0 $self->{_retry_cnt} = $_max_retries - $self->{_retry}[2] - 1;
268  
269 $_on_post_exit->($self, {
270 wid => $_exit_wid, pid => $_exit_pid, status => $_exit_status,
271 msg => $_exit_msg, id => $_exit_id
272 0 }, $self->{_retry_cnt});
273  
274 0 delete $self->{_retry};
275 }
276 else {
277 0 ▶ $_on_post_exit->($self, {
Condition0%0/2
$_max_retries || 0
l!l
00
MC/DC0%0/1
$_max_retries || 0
$_max_retries
Truth table0%0/2
A
A= $_max_retries
Aresult
11
00
278 wid => $_exit_wid, pid => $_exit_pid, status => $_exit_status,
279 msg => $_exit_msg, id => $_exit_id
280 }, $_max_retries || 0 );
281 }
282  
283 0 delete $self->{_exited_wid};
284 }
285 elsif (defined $_on_post_run) {
286 0 push @{ $self->{_status} }, {
287 wid => $_exit_wid, pid => $_exit_pid, status => $_exit_status,
288 msg => $_exit_msg, id => $_exit_id
289 };
290 }
291  
292 0 ▶ _task_end($self, $_task_id) unless $_total_running;
Branch: 1 branch
BranchTrueFalseTotal
unless $_total_running 0 0 0
293  
294 0 return;
295 },
296  
297 ## ----------------------------------------------------------------------
298  
299 OUTPUT_A_REF.$LF => sub { # Input << Array ref
300 376 ▶ my $_buf;
Subroutine __ANON__: called CC=8 SCAR=20.9
301  
302 376 ▶ if ($_offset_pos >= $_input_size || $_aborted) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_offset_pos >= $_input_size or $_aborted) 80 296 376
Condition66%2/3
$_offset_pos >= $_input_size or $_aborted
l!l&&r!l&&!r
800296
MC/DC50%1/2
$_offset_pos >= $_input_size or $_aborted
$_offset_pos >= $_input_size $_aborted
Truth table66%2/3
A or B
A= $_offset_pos >= $_input_sizeB= $_aborted
ABresult
1X1
011
000
303 80 ▶ local $\ = undef if (defined $\);
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 80 80
304 80 print {$_DAU_R_SOCK} '0'.$LF;
305  
306 80 return;
307 }
308  
309 296 ▶ if ($_single_dim && $_cs_one_flag) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_single_dim and $_cs_one_flag) { } 229 67 296
Condition66%2/3
$_single_dim and $_cs_one_flag
!ll&&!rl&&r
067229
MC/DC50%1/2
$_single_dim and $_cs_one_flag
$_single_dim $_cs_one_flag
Truth table66%2/3
A and B
A= $_single_dimB= $_cs_one_flag
ABresult
0X0
100
111
310 229 $_buf = $self->{freeze}( [ $_input_data->[$_offset_pos] ] );
311 }
312 else {
313 67 ▶ if ($_offset_pos + $_chunk_size - 1 < $_input_size) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_offset_pos + $_chunk_size - 1 < $_input_size) { } 54 13 67
314 54 $_buf = $self->{freeze}( [ @{ $_input_data }[
315 $_offset_pos .. $_offset_pos + $_chunk_size - 1
316 ] ] );
317 }
318 else {
319 13 $_buf = $self->{freeze}( [ @{ $_input_data }[
320 $_offset_pos .. $_input_size - 1
321 ] ] );
322 }
323 }
324  
325 296 ▶ $_len = length $_buf; local $\ = undef if (defined $\);
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 296 296
326 296 print {$_DAU_R_SOCK} $_len.$LF . (++$_chunk_id).$LF, $_buf;
327 296 $_offset_pos += $_chunk_size;
328  
329 296 return;
330 },
331  
332 OUTPUT_G_REF.$LF => sub { # Input << Glob ref
333 54 ▶ my $_buf = '';
Subroutine __ANON__: called CC=20 SCAR=46.4
334  
335 ## The logic below honors ('Ctrl/Z' in Windows, 'Ctrl/D' in Unix)
336 ## when reading from standard input. No output will be lost as
337 ## far as what was previously read into the buffer.
338  
339 54 ▶ if ($_eof_flag || $_aborted) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_eof_flag or $_aborted) 36 18 54
Condition66%2/3
$_eof_flag or $_aborted
l!l&&r!l&&!r
36018
MC/DC50%1/2
$_eof_flag or $_aborted
$_eof_flag $_aborted
Truth table66%2/3
A or B
A= $_eof_flagB= $_aborted
ABresult
1X1
011
000
340 36 ▶ local $\ = undef if (defined $\);
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 36 36
341 36 print {$_DAU_R_SOCK} '0'.$LF;
342  
343 36 return;
344 }
345  
346 {
347 18 ▶ local $/ = $_RS if ($_RS_FLG);
Branch: 1 branch
BranchTrueFalseTotal
if $_RS_FLG 0 18 18
348  
349 18 ▶ if ($_chunk_size <= MAX_RECS_SIZE) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_chunk_size <= 8192) { } 0 18 18
350 0 ▶ if ($_chunk_size == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_chunk_size == 1) { } 0 0 0
351 0 ▶ $_buf .= $_input_glob->can('getline')
Branch: 1 branch
BranchTrueFalseTotal
$_input_glob->can('getline') ? : 0 0 0
352 ? $_input_glob->getline : <$_input_glob>;
353 0 ▶ $_eof_flag = 1 unless (length $_buf);
Branch: 1 branch
BranchTrueFalseTotal
unless length $_buf 0 0 0
354 }
355 else {
356 0 my $_last_len = 0;
357 0 for (1 .. $_chunk_size) {
358 0 ▶ $_buf .= $_input_glob->can('getline')
Branch: 1 branch
BranchTrueFalseTotal
$_input_glob->can('getline') ? : 0 0 0
359 ? $_input_glob->getline : <$_input_glob>;
360 0 $_len = length $_buf;
361 0 ▶ if ($_len == $_last_len) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_len == $_last_len) 0 0 0
362 0 $_eof_flag = 1;
363 0 last;
364 }
365 0 $_last_len = $_len;
366 }
367 }
368 }
369 else {
370 18 ▶ if ($_input_glob->can('getline') && $_input_glob->can('read')) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_input_glob->can('getline') and $_input_glob->can('read')) { } 18 0 18
Condition33%1/3
$_input_glob->can("getline") and $_input_glob->can("read")
!ll&&!rl&&r
0018
MC/DC0%0/2
$_input_glob->can("getline") and $_input_glob->can("read")
$_input_glob->can("getline") $_input_glob->can("read")
Truth table33%1/3
A and B
A= $_input_glob->can("getline")B= $_input_glob->can("read")
ABresult
0X0
100
111
371 18 ▶ if ($_input_glob->read($_buf, $_chunk_size) == $_chunk_size) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_input_glob->read($_buf, $_chunk_size) == $_chunk_size) { } 0 18 18
372 0 $_buf .= $_input_glob->getline;
373 0 ▶ $_eof_flag = 1 if (length $_buf == $_chunk_size);
Branch: 1 branch
BranchTrueFalseTotal
if length $_buf == $_chunk_size 0 0 0
374 } else {
375 18 $_eof_flag = 1;
376 }
377 }
378 else {
379 0 ▶ if (read($_input_glob, $_buf, $_chunk_size) == $_chunk_size) {
Branch: 1 branch
BranchTrueFalseTotal
if (read($_input_glob, $_buf, $_chunk_size) == $_chunk_size) { } 0 0 0
380 0 $_buf .= <$_input_glob>;
381 0 ▶ $_eof_flag = 1 if (length $_buf == $_chunk_size);
Branch: 1 branch
BranchTrueFalseTotal
if length $_buf == $_chunk_size 0 0 0
382 } else {
383 0 $_eof_flag = 1;
384 }
385 }
386 }
387 }
388  
389 18 ▶ $_len = length $_buf; local $\ = undef if (defined $\);
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 18 18
390  
391 18 ▶ if ($_len) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_len) { } 18 0 18
392 18 my $_tmp = $self->{freeze}(\$_buf);
393 18 print {$_DAU_R_SOCK} length($_tmp).$LF . (++$_chunk_id).$LF, $_tmp;
394 }
395 else {
396 0 print {$_DAU_R_SOCK} '0'.$LF;
397 }
398  
399 18 return;
400 },
401  
402 OUTPUT_H_REF.$LF => sub { # Input << Hash ref
403 18 ▶ my @_pairs;
Subroutine __ANON__: called CC=8 SCAR=20.9
404  
405 18 ▶ if ($_offset_pos >= $_input_size || $_aborted) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_offset_pos >= $_input_size or $_aborted) 3 15 18
Condition66%2/3
$_offset_pos >= $_input_size or $_aborted
l!l&&r!l&&!r
3015
MC/DC50%1/2
$_offset_pos >= $_input_size or $_aborted
$_offset_pos >= $_input_size $_aborted
Truth table66%2/3
A or B
A= $_offset_pos >= $_input_sizeB= $_aborted
ABresult
1X1
011
000
406 3 ▶ local $\ = undef if (defined $\);
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 3 3
407 3 print {$_DAU_R_SOCK} '0'.$LF;
408  
409 3 return;
410 }
411  
412 15 ▶ if ($_offset_pos + $_chunk_size - 1 < $_input_size) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_offset_pos + $_chunk_size - 1 < $_input_size) { } 12 3 15
413 12 for my $_i ($_offset_pos .. $_offset_pos + $_chunk_size - 1) {
414 24 push @_pairs, each %{ $_input_data };
415 }
416 }
417 else {
418 3 for my $_i ($_offset_pos .. $_input_size - 1) {
419 3 push @_pairs, each %{ $_input_data };
420 }
421 }
422  
423 15 my $_buf = $self->{freeze}(\@_pairs);
424  
425 15 ▶ $_len = length $_buf; local $\ = undef if (defined $\);
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 15 15
426 15 print {$_DAU_R_SOCK} $_len.$LF . (++$_chunk_id).$LF, $_buf;
427 15 $_offset_pos += $_chunk_size;
428  
429 15 return;
430 },
431  
432 OUTPUT_I_REF.$LF => sub { # Input << Iter ref
433 0 ▶ my $_buf;
Subroutine __ANON__: not called CC=7 SCAR=40.3
434  
435 0 ▶ if ($_aborted) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_aborted) 0 0 0
436 0 ▶ local $\ = undef if (defined $\);
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 0 0
437 0 print {$_DAU_R_SOCK} '-1'.$LF;
438  
439 0 return;
440 }
441  
442 0 my @_ret_a = $_input_data->($_chunk_size);
443  
444 0 ▶ if (@_ret_a > 1 || defined $_ret_a[0]) {
Branch: 1 branch
BranchTrueFalseTotal
if (@_ret_a > 1 or defined $_ret_a[0]) 0 0 0
Condition0%0/3
@_ret_a > 1 or defined $_ret_a[0]
l!l&&r!l&&!r
000
MC/DC0%0/2
@_ret_a > 1 or defined $_ret_a[0]
@_ret_a > 1 defined $_ret_a[0]
Truth table0%0/3
A or B
A= @_ret_a > 1B= defined $_ret_a[0]
ABresult
1X1
011
000
445 0 $_buf = $self->{freeze}([ @_ret_a ]);
446 0 ▶ $_len = length $_buf; local $\ = undef if (defined $\);
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 0 0
447 0 print {$_DAU_R_SOCK} $_len.$LF . (++$_chunk_id).$LF, $_buf;
448  
449 0 return;
450 }
451  
452 0 ▶ local $\ = undef if (defined $\);
Branch: 1 branch
BranchTrueFalseTotal
if defined $\ 0 0 0
453 0 print {$_DAU_R_SOCK} '-1'.$LF;
454 0 $_aborted = 1;
455  
456 0 return;
457 },
458  
459 ## ----------------------------------------------------------------------
460  
461 OUTPUT_A_CBK.$LF => sub { # Callback w/ args
462 283 ▶ chomp($_wa = <$_DAU_R_SOCK>),
Subroutine __ANON__: called CC=1 SCAR=0.0
463 chomp($_cb = <$_DAU_R_SOCK>),
464 chomp($_len = <$_DAU_R_SOCK>);
465  
466 283 read $_DAU_R_SOCK, my($_buf), $_len;
467  
468 283 my $_aref = $self->{thaw}($_buf);
469 283 undef $_buf;
470  
471 283 return $_cb_reply->(@{ $_aref });
472 },
473  
474 OUTPUT_N_CBK.$LF => sub { # Callback w/ no args
475 2 ▶ chomp($_wa = <$_DAU_R_SOCK>),
Subroutine __ANON__: called CC=1 SCAR=0.0
476 chomp($_cb = <$_DAU_R_SOCK>);
477  
478 2 return $_cb_reply->();
479 },
480  
481 OUTPUT_A_GTR.$LF => sub { # Gather data
482 1108 ▶ chomp($_task_id = <$_DAU_R_SOCK>),
Subroutine __ANON__: called CC=5 SCAR=19.1
483 chomp($_len = <$_DAU_R_SOCK>);
484  
485 1108 read $_DAU_R_SOCK, my($_buf), $_len;
486  
487 1108 ▶ if ($_is_c_ref[$_task_id]) {
Branch: 3 branches
BranchTrueFalseTotal
if ($_is_c_ref[$_task_id]) { } 579 529 1108
elsif ($_is_h_ref[$_task_id]) { } 0 529 529
elsif ($_is_q_ref[$_task_id]) { } 379 150 529
488 579 local $_ = $self->{thaw}($_buf);
489 579 $_gather[$_task_id]->(@{ $_ });
490 }
491 elsif ($_is_h_ref[$_task_id]) {
492 0 local $_ = $self->{thaw}($_buf);
493 0 while (1) {
494 0 my $_key = shift @{ $_ }; my $_val = shift @{ $_ };
495 0 $_gather[$_task_id]->{$_key} = $_val;
496 0 ▶ last unless (@{ $_ });
Branch: 1 branch
BranchTrueFalseTotal
unless @{$_;} 0 0 0
497 }
498 }
499 elsif ($_is_q_ref[$_task_id]) {
500 379 $_gather[$_task_id]->enqueue(@{ $self->{thaw}($_buf) });
501 }
502 else {
503 150 push @{ $_gather[$_task_id] }, @{ $self->{thaw}($_buf) };
504 }
505  
506 1108 return;
507 },
508  
509 ## ----------------------------------------------------------------------
510  
511 OUTPUT_O_SND.$LF => sub { # Send >> STDOUT
512 0 ▶ chomp($_len = <$_DAU_R_SOCK>);
Subroutine __ANON__: not called CC=2 SCAR=13.7
513  
514 0 read $_DAU_R_SOCK, my($_buf), $_len;
515 0 $_buf = ${ $self->{thaw}($_buf) };
516  
517 0 ▶ if (defined $_user_output) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_user_output) { } 0 0 0
518 0 $_user_output->($_buf);
519 }
520 else {
521 85 ▶ use bytes;
Subroutine BEGIN: called CC=1 SCAR=0.0
522 0 print {$_MCE_STDOUT} $_buf;
523 }
524  
525 0 return;
526 },
527  
528 OUTPUT_E_SND.$LF => sub { # Send >> STDERR
529 0 ▶ chomp($_len = <$_DAU_R_SOCK>);
Subroutine __ANON__: not called CC=2 SCAR=13.7
530  
531 0 read $_DAU_R_SOCK, my($_buf), $_len;
532 0 $_buf = ${ $self->{thaw}($_buf) };
533  
534 0 ▶ if (defined $_user_error) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_user_error) { } 0 0 0
535 0 $_user_error->($_buf);
536 }
537 else {
538 85 ▶ use bytes;
Subroutine BEGIN: called CC=1 SCAR=0.0
539 0 print {$_MCE_STDERR} $_buf;
540 }
541  
542 0 return;
543 },
544  
545 OUTPUT_F_SND.$LF => sub { # Send >> File
546 0 ▶ my ($_buf, $_OUT_FILE);
Subroutine __ANON__: not called CC=5 SCAR=31.3
547  
548 0 chomp($_len = <$_DAU_R_SOCK>);
549 0 read $_DAU_R_SOCK, $_buf, $_len;
550  
551 0 $_buf = $self->{thaw}($_buf);
552 0 $_file = $_buf->[0];
553  
554 0 ▶ unless (exists $_sendto_fhs{$_file}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $_sendto_fhs{$_file}) 0 0 0
555 0 ▶ open $_sendto_fhs{$_file}, ">>", "$_file"
Branch: 1 branch
BranchTrueFalseTotal
open $_sendto_fhs{$_file}, ">>", "$_file" or _croak("Cannot open file for writing ($_file): $!") 0 0 0
556 or _croak "Cannot open file for writing ($_file): $!";
557  
558 0 binmode $_sendto_fhs{$_file};
559  
560 0 ▶ if (!exists $self->{flush_file} || $self->{flush_file}) {
Branch: 1 branch
BranchTrueFalseTotal
if (not exists $self->{"flush_file"} or $self->{"flush_file"}) 0 0 0
Condition0%0/3
not exists $self->{"flush_file"} or $self->{"flush_file"}
l!l&&r!l&&!r
000
MC/DC0%0/2
not exists $self->{"flush_file"} or $self->{"flush_file"}
not exists $self->{"flush_file"} $self->{"flush_file"}
Truth table0%0/3
not(A) or B
A= not exists $self->{"flush_file"}B= $self->{"flush_file"}
ABresult
1X1
011
000
561 0 local $!;
562 0 $_sendto_fhs{$_file}->autoflush(1);
563 }
564 }
565  
566 {
567 85 ▶ use bytes;
Subroutine BEGIN: called CC=1 SCAR=0.2
568 0 $_OUT_FILE = $_sendto_fhs{$_file};
569 0 print {$_OUT_FILE} $_buf->[1];
570 }
571  
572 0 return;
573 },
574  
575 OUTPUT_D_SND.$LF => sub { # Send >> File descriptor
576 0 ▶ my ($_buf, $_OUT_FILE);
Subroutine __ANON__: not called CC=1 SCAR=3.5
577  
578 0 chomp($_len = <$_DAU_R_SOCK>);
579 0 read $_DAU_R_SOCK, $_buf, $_len;
580  
581 0 $_buf = $self->{thaw}($_buf);
582  
583 {
584 85 ▶ use bytes;
Subroutine BEGIN: called CC=1 SCAR=0.2
585 0 $_OUT_FILE = _sendto_fhs_get($self, $_buf->[0]);
586 0 print {$_OUT_FILE} $_buf->[1];
587 }
588  
589 0 return;
590 },
591  
592 ## ----------------------------------------------------------------------
593  
594 OUTPUT_B_SYN.$LF => sub { # Barrier sync - begin
595 0 ▶ if (!defined $_sync_cnt || $_sync_cnt == 0) {
Subroutine __ANON__: not called CC=6 SCAR=37.4
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $_sync_cnt or $_sync_cnt == 0) 0 0 0
Condition0%0/3
not defined $_sync_cnt or $_sync_cnt == 0
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $_sync_cnt or $_sync_cnt == 0
not defined $_sync_cnt $_sync_cnt == 0
Truth table0%0/3
not(A) or B
A= not defined $_sync_cntB= $_sync_cnt == 0
ABresult
1X1
011
000
596 0 $_syn_flag = 1, $_sync_cnt = 0;
597 }
598  
599 my $_total_running = ($_has_user_tasks)
600 ? $self->{_task}->[0]->{_total_running}
601 0 ▶ : $self->{_total_running};
Branch: 1 branch
BranchTrueFalseTotal
$_has_user_tasks ? : 0 0 0
602  
603 0 ▶ if (++$_sync_cnt == $_total_running) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$_sync_cnt == $_total_running) 0 0 0
604 0 for my $_i (1 .. $_total_running) {
605 0 syswrite($_BSB_W_SOCK, $LF);
606 }
607 0 undef $_syn_flag;
608 }
609  
610 0 return;
611 },
612  
613 OUTPUT_E_SYN.$LF => sub { # Barrier sync - end
614 0 ▶ if (--$_sync_cnt == 0) {
Subroutine __ANON__: not called CC=4 SCAR=30.0
Branch: 1 branch
BranchTrueFalseTotal
if (--$_sync_cnt == 0) 0 0 0
615 my $_total_running = ($_has_user_tasks)
616 ? $self->{_task}->[0]->{_total_running}
617 0 ▶ : $self->{_total_running};
Branch: 1 branch
BranchTrueFalseTotal
$_has_user_tasks ? : 0 0 0
618  
619 0 for my $_i (1 .. $_total_running) {
620 0 syswrite($_BSB_R_SOCK, $LF);
621 }
622 }
623  
624 0 return;
625 },
626  
627 OUTPUT_S_IPC.$LF => sub { # Change to win32 IPC
628 0 ▶ syswrite($_DAT_R_SOCK, $LF);
Subroutine __ANON__: not called CC=2 SCAR=17.9
629  
630 0 ▶ $_win32_ipc = 1, goto _LOOP unless $_win32_ipc;
Branch: 1 branch
BranchTrueFalseTotal
unless $_win32_ipc 0 0 0
631  
632 0 return;
633 },
634  
635 OUTPUT_C_NFY.$LF => sub { # Chunk ID notification
636 0 ▶ chomp($_len = <$_DAU_R_SOCK>);
Subroutine __ANON__: not called CC=1 SCAR=6.9
637  
638 0 my ($_pid, $_chunk_id) = split /:/, $_len;
639 0 $self->{_pids_c}{$_pid} = $_chunk_id;
640  
641 0 return;
642 },
643  
644 OUTPUT_P_NFY.$LF => sub { # Progress notification
645 0 ▶ chomp($_len = <$_DAU_R_SOCK>);
Subroutine __ANON__: not called CC=1 SCAR=6.9
646  
647 0 $self->{progress}->( $_size_completed += $_len );
648  
649 0 return;
650 },
651  
652 OUTPUT_S_DIR.$LF => sub { # Make/get sess_dir
653 0 ▶ print {$_DAU_R_SOCK} $self->sess_dir().$LF;
Subroutine __ANON__: not called CC=1 SCAR=6.9
654  
655 0 return;
656 },
657  
658 OUTPUT_T_DIR.$LF => sub { # Make/get tmp_dir
659 0 ▶ print {$_DAU_R_SOCK} $self->tmp_dir().$LF;
Subroutine __ANON__: not called CC=1 SCAR=6.9
660  
661 0 return;
662 },
663  
664 OUTPUT_I_DLY.$LF => sub { # Interval delay
665 0 ▶ my $_tasks = $_has_user_tasks ? $self->{user_tasks} : undef;
Subroutine __ANON__: not called CC=15 SCAR=54.8
Branch: 1 branch
BranchTrueFalseTotal
$_has_user_tasks ? : 0 0 0
666  
667 0 chomp($_task_id = <$_DAU_R_SOCK>);
668  
669 my $_interval = ($_tasks && exists $_tasks->[$_task_id]{interval})
670 ? $_tasks->[$_task_id]{interval}
671 0 ▶ : $self->{interval};
Branch: 1 branch
BranchTrueFalseTotal
$_tasks && exists $_tasks->[$_task_id]{'interval'} ? : 0 0 0
Condition0%0/3
$_tasks and exists $_tasks->[$_task_id]{"interval"}
!ll&&!rl&&r
000
MC/DC0%0/2
$_tasks and exists $_tasks->[$_task_id]{"interval"}
$_tasks exists $_tasks->[$_task_id]{"interval"}
Truth table0%0/3
A and B
A= $_tasksB= exists $_tasks->[$_task_id]{"interval"}
ABresult
0X0
100
111
672  
673 0 ▶ if (!$_interval) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $_interval) { } 0 0 0
elsif ($_interval->{'max_nodes'} == 1) { } 0 0 0
674 0 print {$_DAU_R_SOCK} '0'.$LF;
675 }
676 elsif ($_interval->{max_nodes} == 1) {
677 0 my $_delay = $_interval->{delay};
678 0 my $_lapse = $_interval->{_lapse};
679 0 my $_time = MCE::Util::_time();
680  
681 0 ▶ if (!$_delay || !defined $_lapse) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $_delay && defined $_lapse) { } 0 0 0
elsif ($_lapse + $_delay - $_time < 0) { } 0 0 0
Condition0%0/3
$_delay && defined $_lapse
!ll&&!rl&&r
000
MC/DC0%0/2
$_delay && defined $_lapse
$_delay defined $_lapse
Truth table0%0/3
A && B
A= $_delayB= defined $_lapse
ABresult
0X0
100
111
682 0 $_lapse = $_time;
683 }
684 elsif ($_lapse + $_delay - $_time < 0) {
685 0 $_lapse += int( abs($_time - $_lapse) / $_delay + 0.5 ) * $_delay;
686 }
687  
688 0 $_interval->{_lapse} = ($_lapse += $_delay);
689 0 print {$_DAU_R_SOCK} ($_lapse - $_time).$LF
690 }
691 else {
692 my $_max_workers = ($_tasks)
693 ? $_tasks->[$_task_id]{max_workers}
694 0 ▶ : $self->{max_workers};
Branch: 1 branch
BranchTrueFalseTotal
$_tasks ? : 0 0 0
695  
696 0 ▶ if (++$_delay_wid[$_task_id] > $_max_workers) {
Branch: 1 branch
BranchTrueFalseTotal
if (++$_delay_wid[$_task_id] > $_max_workers) 0 0 0
697 0 $_delay_wid[$_task_id] = 1;
698 }
699  
700 0 my $_nodes = $_interval->{max_nodes};
701 0 my $_id = $_interval->{node_id};
702 0 my $_delay = $_interval->{delay} * $_nodes;
703  
704 0 my $_app_tb = $_delay * $_max_workers;
705 0 my $_app_st = $_interval->{_time} + ($_delay / $_nodes * $_id);
706 0 my $_wrk_st = ($_delay_wid[$_task_id] - 1) * $_delay + $_app_st;
707  
708 0 $_delay = $_wrk_st - MCE::Util::_time();
709  
710 0 ▶ if ($_delay < 0.0 && $_app_tb) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_delay < 0 and $_app_tb) 0 0 0
Condition0%0/3
$_delay < 0 and $_app_tb
!ll&&!rl&&r
000
MC/DC0%0/2
$_delay < 0 and $_app_tb
$_delay < 0 $_app_tb
Truth table0%0/3
A and B
A= $_delay < 0B= $_app_tb
ABresult
0X0
100
111
711 0 my $_count = int($_delay * -1 / $_app_tb + 0.5) + 1;
712 0 $_delay += $_app_tb * $_count;
713 0 ▶ $_interval->{_time} = MCE::Util::_time() if ($_count > 2e9);
Branch: 1 branch
BranchTrueFalseTotal
if $_count > "2000000000" 0 0 0
714 }
715  
716 ($_delay > 0.0)
717 0 ? print {$_DAU_R_SOCK} $_delay.$LF
718 0 ▶ : print {$_DAU_R_SOCK} '0'.$LF;
Branch: 1 branch
BranchTrueFalseTotal
$_delay > 0.0 ? : 0 0 0
719 }
720  
721 0 return;
722 },
723  
724 142 );
725  
726 ## -------------------------------------------------------------------------
727  
728 142 local ($!, $?, $_);
729  
730 142 $_aborted = $_chunk_id = $_eof_flag = $_size_completed = 0;
731 142 ▶ $_has_user_tasks = (defined $self->{user_tasks}) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'user_tasks'} ? : 108 34 142
732 142 ▶ $_cs_one_flag = ($self->{chunk_size} == 1) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$self->{'chunk_size'} == 1 ? : 60 82 142
733  
734 142 $_max_retries = $self->{max_retries};
735 142 $_on_post_exit = $self->{on_post_exit};
736 142 $_on_post_run = $self->{on_post_run};
737 142 $_chunk_size = $self->{chunk_size};
738 142 $_user_output = $self->{user_output};
739 142 $_user_error = $self->{user_error};
740 142 $_single_dim = $self->{_single_dim};
741 142 $_sess_dir = $self->{_sess_dir};
742  
743 142 ▶ if (defined $_max_retries && !$_on_post_exit) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_max_retries and not $_on_post_exit) 0 142 142
Condition33%1/3
defined $_max_retries and not $_on_post_exit
!ll&&!rl&&r
14200
MC/DC0%0/2
defined $_max_retries and not $_on_post_exit
defined $_max_retries not $_on_post_exit
Truth table33%1/3
A and not(B)
A= defined $_max_retriesB= not $_on_post_exit
ABresult
0X0
100
111
744 $_on_post_exit = sub {
745 0 ▶ my ($self, $_e, $_retry_cnt) = @_;
Subroutine __ANON__: not called CC=5 SCAR=34.0
746  
747 0 ▶ if ($_e->{id}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_e->{"id"}) 0 0 0
748 0 my $_cnt = $_retry_cnt + 1;
749 0 my $_msg = "Error: chunk $_e->{id} failed";
750  
751 0 ▶ if (defined $self->{init_relay}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'init_relay'}) { } 0 0 0
752 0 ▶ print {*STDERR} "$_msg, retrying chunk attempt # $_cnt\n"
Branch: 1 branch
BranchTrueFalseTotal
if $_retry_cnt < $_max_retries 0 0 0
753 if ($_retry_cnt < $_max_retries);
754 }
755 else {
756 ($_retry_cnt < $_max_retries)
757 0 ? print {*STDERR} "$_msg, retrying chunk attempt # $_cnt\n"
758 0 ▶ : print {*STDERR} "$_msg\n";
Branch: 1 branch
BranchTrueFalseTotal
$_retry_cnt < $_max_retries ? : 0 0 0
759 }
760  
761 0 $self->restart_worker;
762 }
763 0 };
764 }
765  
766 142 ▶ if ($_has_user_tasks && $self->{user_tasks}->[0]->{chunk_size}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_has_user_tasks and $self->{"user_tasks"}[0]{"chunk_size"}) 0 142 142
Condition66%2/3
$_has_user_tasks and $self->{"user_tasks"}[0]{"chunk_size"}
!ll&&!rl&&r
341080
MC/DC0%0/2
$_has_user_tasks and $self->{"user_tasks"}[0]{"chunk_size"}
$_has_user_tasks $self->{"user_tasks"}[0]{"chunk_size"}
Truth table66%2/3
A and B
A= $_has_user_tasksB= $self->{"user_tasks"}[0]{"chunk_size"}
ABresult
0X0
100
111
767 0 $_chunk_size = $self->{user_tasks}->[0]->{chunk_size};
768 }
769  
770 142 ▶ if ($_has_user_tasks) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_has_user_tasks) 108 34 142
771 108 for my $_i (0 .. @{ $self->{user_tasks} } - 1) {
772 $_gather[$_i] = (defined $self->{user_tasks}->[$_i]->{gather})
773 180 ▶ ? $self->{user_tasks}->[$_i]->{gather} : $self->{gather};
Branch: 1 branch
BranchTrueFalseTotal
defined $self->{'user_tasks'}[$_i]{'gather'} ? : 102 78 180
774  
775 180 ▶ $_is_c_ref[$_i] = ( ref $_gather[$_i] eq 'CODE' ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
ref $_gather[$_i] eq 'CODE' ? : 91 89 180
776 180 ▶ $_is_h_ref[$_i] = ( ref $_gather[$_i] eq 'HASH' ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
ref $_gather[$_i] eq 'HASH' ? : 0 180 180
777  
778 180 ▶ $_is_q_ref[$_i] = (
Branch: 1 branch
BranchTrueFalseTotal
ref $_gather[$_i] eq 'MCE::Queue' || ref $_gather[$_i] eq 'Thread::Queue' ? : 51 129 180
Condition66%2/3
ref $_gather[$_i] eq "MCE::Queue" or ref $_gather[$_i] eq "Thread::Queue"
l!l&&r!l&&!r
510129
MC/DC50%1/2
ref $_gather[$_i] eq "MCE::Queue" or ref $_gather[$_i] eq "Thread::Queue"
ref $_gather[$_i] eq "MCE::Queue" ref $_gather[$_i] eq "Thread::Queue"
Truth table66%2/3
A or B
A= ref $_gather[$_i] eq "MCE::Queue"B= ref $_gather[$_i] eq "Thread::Queue"
ABresult
1X1
011
000
779 ref $_gather[$_i] eq 'MCE::Queue' ||
780 ref $_gather[$_i] eq 'Thread::Queue' ) ? 1 : 0;
781 }
782 }
783  
784 142 ▶ if (defined $self->{gather}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{"gather"}) 62 80 142
785 62 $_gather[0] = $self->{gather};
786  
787 62 ▶ $_is_c_ref[0] = ( ref $_gather[0] eq 'CODE' ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
ref $_gather[0] eq 'CODE' ? : 40 22 62
788 62 ▶ $_is_h_ref[0] = ( ref $_gather[0] eq 'HASH' ) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
ref $_gather[0] eq 'HASH' ? : 0 62 62
789  
790 62 ▶ $_is_q_ref[0] = (
Branch: 1 branch
BranchTrueFalseTotal
ref $_gather[0] eq 'MCE::Queue' || ref $_gather[0] eq 'Thread::Queue' ? : 0 62 62
Condition33%1/3
ref $_gather[0] eq "MCE::Queue" or ref $_gather[0] eq "Thread::Queue"
l!l&&r!l&&!r
0062
MC/DC0%0/2
ref $_gather[0] eq "MCE::Queue" or ref $_gather[0] eq "Thread::Queue"
ref $_gather[0] eq "MCE::Queue" ref $_gather[0] eq "Thread::Queue"
Truth table33%1/3
A or B
A= ref $_gather[0] eq "MCE::Queue"B= ref $_gather[0] eq "Thread::Queue"
ABresult
1X1
011
000
791 ref $_gather[0] eq 'MCE::Queue' ||
792 ref $_gather[0] eq 'Thread::Queue' ) ? 1 : 0;
793 }
794  
795 142 ▶ if (defined $_input_data && ref $_input_data eq 'ARRAY') {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $_input_data and ref $_input_data eq 'ARRAY') { } 40 102 142
elsif (defined $_input_data and ref $_input_data eq 'HASH') { } 3 99 102
Condition100%3/3
defined $_input_data and ref $_input_data eq "ARRAY"
!ll&&!rl&&r
99340
MC/DC100%2/2
defined $_input_data and ref $_input_data eq "ARRAY"
defined $_input_data ref $_input_data eq "ARRAY"
Truth table100%3/3
A and B
A= defined $_input_dataB= ref $_input_data eq "ARRAY"
ABresult
0X0
100
111
796 40 $_input_size = @{ $_input_data };
797 40 $_offset_pos = 0;
798 }
799 ▶ elsif (defined $_input_data && ref $_input_data eq 'HASH') {
Condition66%2/3
defined $_input_data and ref $_input_data eq "HASH"
!ll&&!rl&&r
9903
MC/DC50%1/2
defined $_input_data and ref $_input_data eq "HASH"
defined $_input_data ref $_input_data eq "HASH"
Truth table66%2/3
A and B
A= defined $_input_dataB= ref $_input_data eq "HASH"
ABresult
0X0
100
111
800 3 $_input_size = scalar( keys %{ $_input_data } );
801 3 $_offset_pos = 0;
802 }
803 else {
804 99 $_input_size = $_offset_pos = 0;
805 }
806  
807 ## Set STDOUT/STDERR to user parameters.
808  
809 142 ▶ if (defined $self->{stdout_file}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'stdout_file'}) { } 0 142 142
810 open $_MCE_STDOUT, '>>', $self->{stdout_file}
811 0 ▶ or die $self->{stdout_file} . ": $!\n";
Branch: 1 branch
BranchTrueFalseTotal
open $_MCE_STDOUT, ">>", $self->{"stdout_file"} or die $self->{"stdout_file"} . ": $!\n" 0 0 0
812 0 binmode $_MCE_STDOUT;
813 }
814 else {
815 142 $_MCE_STDOUT = \*STDOUT;
816 }
817  
818 142 ▶ if (defined $self->{stderr_file}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $self->{'stderr_file'}) { } 0 142 142
819 open $_MCE_STDERR, '>>', $self->{stderr_file}
820 0 ▶ or die $self->{stderr_file} . ": $!\n";
Branch: 1 branch
BranchTrueFalseTotal
open $_MCE_STDERR, ">>", $self->{"stderr_file"} or die $self->{"stderr_file"} . ": $!\n" 0 0 0
821 0 binmode $_MCE_STDERR;
822 }
823 else {
824 142 $_MCE_STDERR = \*STDERR;
825 }
826  
827 ## Autoflush STDERR-STDOUT handles if not specified or requested.
828  
829 {
830 142 local $!;
831  
832 $_MCE_STDERR->autoflush(1)
833 142 ▶ if ( !exists $self->{flush_stderr} || $self->{flush_stderr} );
Branch: 1 branch
BranchTrueFalseTotal
if not exists $self->{"flush_stderr"} or $self->{"flush_stderr"} 142 0 142
Condition33%1/3
not exists $self->{"flush_stderr"} or $self->{"flush_stderr"}
l!l&&r!l&&!r
14200
MC/DC0%0/2
not exists $self->{"flush_stderr"} or $self->{"flush_stderr"}
not exists $self->{"flush_stderr"} $self->{"flush_stderr"}
Truth table33%1/3
not(A) or B
A= not exists $self->{"flush_stderr"}B= $self->{"flush_stderr"}
ABresult
1X1
011
000
834  
835 $_MCE_STDOUT->autoflush(1)
836 142 ▶ if ( !exists $self->{flush_stdout} || $self->{flush_stdout} );
Branch: 1 branch
BranchTrueFalseTotal
if not exists $self->{"flush_stdout"} or $self->{"flush_stdout"} 142 0 142
Condition33%1/3
not exists $self->{"flush_stdout"} or $self->{"flush_stdout"}
l!l&&r!l&&!r
14200
MC/DC0%0/2
not exists $self->{"flush_stdout"} or $self->{"flush_stdout"}
not exists $self->{"flush_stdout"} $self->{"flush_stdout"}
Truth table33%1/3
not(A) or B
A= not exists $self->{"flush_stdout"}B= $self->{"flush_stdout"}
ABresult
1X1
011
000
837 }
838  
839 ## -------------------------------------------------------------------------
840  
841 ## Output event loop.
842  
843 142 my $_channels = $self->{_dat_r_sock};
844 142 my $_func;
845  
846 $_win32_ipc = (
847 $ENV{'PERL_MCE_IPC'} eq 'win32' ||
848 defined($self->{max_retries}) ||
849 $INC{'MCE/Child.pm'} ||
850 142 ▶ $INC{'MCE/Hobo.pm'}
Condition33%3/9
$ENV{'PERL_MCE_IPC'} eq 'win32' || defined $self->{'max_retries'} || $INC{'MCE/Child.pm'} || $INC{'MCE/Hobo.pm'}
l!l&&r!l&&!r
00142
$ENV{"PERL_MCE_IPC"} eq "win32" or defined $self->{"max_retries"} or $INC{"MCE/Child.pm"}
l!l&&r!l&&!r
00142
$ENV{"PERL_MCE_IPC"} eq "win32" or defined $self->{"max_retries"}
l!l&&r!l&&!r
00142
MC/DC0%0/4
$ENV{'PERL_MCE_IPC'} eq 'win32' || defined $self->{'max_retries'} || $INC{'MCE/Child.pm'} || $INC{'MCE/Hobo.pm'}
$ENV{"PERL_MCE_IPC"} eq "win32" defined $self->{"max_retries"} $INC{"MCE/Child.pm"} $INC{'MCE/Hobo.pm'}
Truth table20%1/5
A or B or C || D
A= $ENV{"PERL_MCE_IPC"} eq "win32"B= defined $self->{"max_retries"}C= $INC{"MCE/Child.pm"}D= $INC{'MCE/Hobo.pm'}
ABCDresult
1XXX1
01XX1
001X1
00011
00000
851 );
852  
853 142 $_BSB_W_SOCK = $self->{_bsb_w_sock};
854 142 $_BSB_R_SOCK = $self->{_bsb_r_sock};
855 142 $_DAT_R_SOCK = $self->{_dat_r_sock}->[0];
856  
857 142 ▶ $_RS = $self->{RS} || $/;
Condition33%1/3
$self->{'RS'} || $/
l!l&&r!l&&!r
01420
MC/DC0%0/2
$self->{'RS'} || $/
$self->{'RS'} $/
Truth table33%1/3
A || B
A= $self->{'RS'}B= $/
ABresult
1X1
011
000
858 142 $_O_SEP = $\; local $\ = undef;
859 142 $_I_SEP = $/; local $/ = $LF;
860  
861 142 ▶ $_RS_FLG = (!$_RS || $_RS ne $LF) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
!$_RS || $_RS ne $MCE::LF ? : 0 142 142
Condition33%1/3
not $_RS or $_RS ne $MCE::LF
l!l&&r!l&&!r
00142
MC/DC0%0/2
not $_RS or $_RS ne $MCE::LF
not $_RS $_RS ne $MCE::LF
Truth table33%1/3
not(A) or B
A= not $_RSB= $_RS ne $MCE::LF
ABresult
1X1
011
000
862 142 ▶ $_O_FLG = (defined $_O_SEP) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $_O_SEP ? : 0 142 142
863 142 ▶ $_I_FLG = (!$_I_SEP || $_I_SEP ne $LF) ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
!$_I_SEP || $_I_SEP ne $MCE::LF ? : 0 142 142
Condition33%1/3
not $_I_SEP or $_I_SEP ne $MCE::LF
l!l&&r!l&&!r
00142
MC/DC0%0/2
not $_I_SEP or $_I_SEP ne $MCE::LF
not $_I_SEP $_I_SEP ne $MCE::LF
Truth table33%1/3
not(A) or B
A= not $_I_SEPB= $_I_SEP ne $MCE::LF
ABresult
1X1
011
000
864  
865 ## Call module's loop_begin routine for modules plugged into MCE.
866  
867 142 for my $_p (@{ $_plugin_loop_begin }) {
868 103 $_p->($self, \$_DAU_R_SOCK);
869 }
870  
871 ## Wait on requests *with* timeout capability. Exit loop when all workers
872 ## have completed processing or exited prematurely.
873  
874 _LOOP:
875  
876 142 ▶ if ($self->{loop_timeout} && @{ $self->{_tids} } == 0 && $^O ne 'MSWin32') {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'loop_timeout'} and @{$self->{'_tids'};} == 0 and $^O ne 'MSWin32') { } 0 142 142
elsif ($^O eq 'MSWin32') { } 0 142 142
Condition33%2/6
$self->{"loop_timeout"} and @{$self->{"_tids"};} == 0 and $^O ne "MSWin32"
!ll&&!rl&&r
14200
$self->{"loop_timeout"} and @{$self->{"_tids"};} == 0
!ll&&!rl&&r
14200
MC/DC0%0/3
$self->{"loop_timeout"} and @{$self->{"_tids"};} == 0 and $^O ne "MSWin32"
$self->{"loop_timeout"} @{$self->{"_tids"};} == 0 $^O ne "MSWin32"
Truth table25%1/4
A and B and C
A= $self->{"loop_timeout"}B= @{$self->{"_tids"};} == 0C= $^O ne "MSWin32"
ABCresult
0XX0
10X0
1100
1111
877 0 my ($_list, $_timeout) = ($self->{_pids}, $self->{loop_timeout});
878 0 my ($_DAT_W_SOCK, $_pid) = ($self->{_dat_w_sock}->[0]);
879  
880 0 $self->{_pids_c} = {}; # Chunk ID notification
881  
882 0 ▶ $_timeout = 5 if $_timeout < 5;
Branch: 1 branch
BranchTrueFalseTotal
if $_timeout < 5 0 0 0
883  
884 local $SIG{ALRM} = sub {
885 0 ▶ alarm 0; local ($!, $?);
Subroutine __ANON__: not called CC=18 SCAR=58.3
886  
887 0 for my $i (0 .. @{ $_list }) {
888 0 ▶ if ($_pid = $_list->[$i]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_pid = $_list->[$i]) 0 0 0
889 0 ▶ if (waitpid($_pid, _WNOHANG)) {
Branch: 1 branch
BranchTrueFalseTotal
if (waitpid $_pid, 1) 0 0 0
890  
891 0 $_list->[$i] = undef;
892  
893 0 ▶ if ($? > abs($self->{_wrk_status})) {
Branch: 1 branch
BranchTrueFalseTotal
if ($? > abs $self->{"_wrk_status"}) 0 0 0
894 0 $self->{_wrk_status} = $?;
895 }
896  
897 0 my $_task_id = $self->{_pids_t}{$_pid};
898 0 my $_wid = $self->{_pids_w}{$_pid};
899  
900 0 $self->{_total_exited} += 1;
901 0 $self->{_total_running} -= 1;
902 0 $self->{_total_workers} -= 1;
903  
904 0 ▶ if ($_has_user_tasks && $_task_id >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_has_user_tasks and $_task_id >= 0) 0 0 0
Condition0%0/3
$_has_user_tasks and $_task_id >= 0
!ll&&!rl&&r
000
MC/DC0%0/2
$_has_user_tasks and $_task_id >= 0
$_has_user_tasks $_task_id >= 0
Truth table0%0/3
A and B
A= $_has_user_tasksB= $_task_id >= 0
ABresult
0X0
100
111
905 0 $self->{_task}->[$_task_id]->{_total_running} -= 1;
906 0 $self->{_task}->[$_task_id]->{_total_workers} -= 1;
907 }
908  
909 my $_total_running = ($_has_user_tasks)
910 ? $self->{_task}->[$_task_id]->{_total_running}
911 0 ▶ : $self->{_total_running};
Branch: 1 branch
BranchTrueFalseTotal
$_has_user_tasks ? : 0 0 0
912  
913 0 ▶ if ($_task_id == 0 && defined $_syn_flag && $_sync_cnt) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_task_id == 0 and defined $_syn_flag and $_sync_cnt) 0 0 0
Condition0%0/6
$_task_id == 0 and defined $_syn_flag and $_sync_cnt
!ll&&!rl&&r
000
$_task_id == 0 and defined $_syn_flag
!ll&&!rl&&r
000
MC/DC0%0/3
$_task_id == 0 and defined $_syn_flag and $_sync_cnt
$_task_id == 0 defined $_syn_flag $_sync_cnt
Truth table0%0/4
A and B and C
A= $_task_id == 0B= defined $_syn_flagC= $_sync_cnt
ABCresult
0XX0
10X0
1100
1111
914 0 ▶ if ($_sync_cnt == $_total_running) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_sync_cnt == $_total_running) 0 0 0
915 0 for my $_i (1 .. $_total_running) {
916 0 syswrite($_BSB_W_SOCK, $LF);
917 }
918 0 undef $_syn_flag;
919 }
920 }
921  
922 0 ▶ _task_end($self, $_task_id) unless $_total_running;
Branch: 1 branch
BranchTrueFalseTotal
unless $_total_running 0 0 0
923  
924 0 ▶ if (my $_cid = $self->{_pids_c}{$_pid}) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $_cid = $self->{"_pids_c"}{$_pid}) 0 0 0
925 0 warn "Error: process $_pid has ended prematurely\n",
926 "Error: chunk $_cid failed\n";
927  
928 0 ▶ if ($_cid > $self->{_relayed}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($_cid > $self->{"_relayed"}) 0 0 0
929 0 local $SIG{CHLD} = 'IGNORE';
930 0 my $_pid = fork;
931  
932 0 ▶ if (defined $_pid && $_pid == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $_pid and $_pid == 0) 0 0 0
Condition0%0/3
defined $_pid and $_pid == 0
!ll&&!rl&&r
000
MC/DC0%0/2
defined $_pid and $_pid == 0
defined $_pid $_pid == 0
Truth table0%0/3
A and B
A= defined $_pidB= $_pid == 0
ABresult
0X0
100
111
933 0 delete $self->{max_retries};
934  
935 0 $self->{_chunk_id} = $_cid;
936 0 $self->{_task_id} = $_task_id;
937 0 $self->{_wid} = $_wid;
938  
939 0 eval 'MCE::relay';
940  
941 0 CORE::kill('KILL', $$);
942 0 CORE::exit(0);
943 }
944 }
945 }
946  
947 0 delete $self->{_pids_c}{$_pid};
948 0 delete $self->{_pids_t}{$_pid};
949 0 delete $self->{_pids_w}{$_pid};
950 }
951 }
952 }
953  
954 0 print {$_DAT_W_SOCK} 'NOOP'.$LF . '0'.$LF;
955 0 };
956  
957 0 ▶ while ( $self->{_total_running} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_total_running"}) 0 0 0
958 0 alarm($_timeout); $_func = <$_DAT_R_SOCK>, alarm(0);
959 0 $_DAU_R_SOCK = $_channels->[ <$_DAT_R_SOCK> ];
960  
961 0 ▶ if (exists $_core_output_function{$_func}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $_core_output_function{$_func}) { } 0 0 0
elsif (exists $_plugin_function->{$_func}) { } 0 0 0
962 0 $_core_output_function{$_func}();
963 } elsif (exists $_plugin_function->{$_func}) {
964 0 $_plugin_function->{$_func}();
965 }
966 }
967  
968 0 delete $self->{_pids_c};
969 }
970  
971 ## Wait on requests *without* timeout capability.
972  
973 elsif ($^O eq 'MSWin32') {
974 0 ▶ MCE::Util::_nonblocking($_DAT_R_SOCK, 1) if $_win32_ipc;
Branch: 1 branch
BranchTrueFalseTotal
if $_win32_ipc 0 0 0
975  
976 0 ▶ while ($self->{_total_running}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_total_running"}) 0 0 0
977 0 MCE::Util::_sysread2($_DAT_R_SOCK, $_func, 8);
978 0 ▶ last() unless length($_func) == 8;
Branch: 1 branch
BranchTrueFalseTotal
unless length $_func == 8 0 0 0
979 0 $_DAU_R_SOCK = $_channels->[ substr($_func, -2, 2, '') ];
980  
981 0 ▶ if (exists $_core_output_function{$_func}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $_core_output_function{$_func}) { } 0 0 0
elsif (exists $_plugin_function->{$_func}) { } 0 0 0
982 0 $_core_output_function{$_func}();
983 } elsif (exists $_plugin_function->{$_func}) {
984 0 $_plugin_function->{$_func}();
985 }
986 }
987  
988 0 ▶ MCE::Util::_nonblocking($_DAT_R_SOCK, 0) if $_win32_ipc;
Branch: 1 branch
BranchTrueFalseTotal
if $_win32_ipc 0 0 0
989 }
990 else {
991 142 ▶ while ($self->{_total_running}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"_total_running"}) 3751 142 3893
992 3751 $_func = <$_DAT_R_SOCK>;
993 3751 ▶ last() unless length($_func) == 6;
Branch: 1 branch
BranchTrueFalseTotal
unless length $_func == 6 0 3751 3751
994 3751 $_DAU_R_SOCK = $_channels->[ <$_DAT_R_SOCK> ];
995  
996 3751 ▶ if (exists $_core_output_function{$_func}) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $_core_output_function{$_func}) { } 2269 1482 3751
elsif (exists $_plugin_function->{$_func}) { } 1482 0 1482
997 2269 $_core_output_function{$_func}();
998 } elsif (exists $_plugin_function->{$_func}) {
999 1482 $_plugin_function->{$_func}();
1000 }
1001 }
1002 }
1003  
1004 ## Call module's loop_end routine for modules plugged into MCE.
1005  
1006 142 for my $_p (@{ $_plugin_loop_end }) {
1007 103 $_p->($self);
1008 }
1009  
1010 ## Call on_post_run callback.
1011  
1012 142 ▶ $_on_post_run->($self, $self->{_status}) if (defined $_on_post_run);
Branch: 1 branch
BranchTrueFalseTotal
if defined $_on_post_run 0 142 142
1013  
1014 ## Close opened sendto file handles.
1015  
1016 142 _sendto_fhs_close();
1017  
1018 ## Close MCE STDOUT/STDERR handles.
1019  
1020 142 eval q{
1021 close $_MCE_STDOUT if (fileno $_MCE_STDOUT > 2);
1022 close $_MCE_STDERR if (fileno $_MCE_STDERR > 2);
1023 };
1024  
1025 142 return;
1026 }
1027  
1028 85 1;
1029  
1030 __END__
« MCE.pm ↑ Summary MCE/Child.pm »