line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package AnyEvent::Task::Util; |
2
|
|
|
|
|
|
|
|
3
|
29
|
|
|
29
|
|
111
|
use common::sense; |
|
29
|
|
|
|
|
37
|
|
|
29
|
|
|
|
|
190
|
|
4
|
|
|
|
|
|
|
|
5
|
29
|
|
|
29
|
|
1199
|
use AnyEvent::Util; |
|
29
|
|
|
|
|
39
|
|
|
29
|
|
|
|
|
7719
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our @children_sockets; |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub fork_anyevent_subprocess { |
11
|
28
|
|
|
28
|
0
|
206
|
my ($code, %args) = @_; |
12
|
|
|
|
|
|
|
|
13
|
28
|
|
|
|
|
138
|
my ($socka, $sockb) = AnyEvent::Util::portable_socketpair; |
14
|
|
|
|
|
|
|
|
15
|
28
|
50
|
|
|
|
1316
|
die "No AnyEvent watchers should be created prior to forking (AE model: $AnyEvent::MODEL)" if defined $AnyEvent::MODEL; |
16
|
28
|
|
|
|
|
21523
|
my $pid = fork; |
17
|
|
|
|
|
|
|
|
18
|
28
|
50
|
|
|
|
1027
|
die "couldn't fork: $!" if !defined $pid; |
19
|
|
|
|
|
|
|
|
20
|
28
|
100
|
|
|
|
796
|
if (!$pid) { |
21
|
14
|
|
|
|
|
411
|
close($socka); |
22
|
|
|
|
|
|
|
|
23
|
14
|
|
|
|
|
153
|
AnyEvent::Util::close_all_fds_except 0, 1, 2, fileno($sockb), @{$args{dont_close_fds}}; |
|
14
|
|
|
|
|
793
|
|
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
## If parent closes its side of the socket we should exit |
26
|
14
|
|
|
14
|
|
7567
|
my $watcher = AE::io $sockb, 0, sub { exit }; |
|
14
|
|
|
|
|
5802922
|
|
27
|
|
|
|
|
|
|
|
28
|
14
|
|
|
|
|
62074
|
$code->(); |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
0
|
die "AnyEvent::Task::Server->run should never return"; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
14
|
|
|
|
|
260
|
close $sockb; |
34
|
|
|
|
|
|
|
|
35
|
14
|
50
|
|
|
|
132
|
return ($socka, $pid) if wantarray; |
36
|
|
|
|
|
|
|
|
37
|
14
|
|
|
|
|
131
|
push @children_sockets, $socka; # keep reference alive |
38
|
14
|
|
|
|
|
751
|
return; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |