| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package FCGI::EV::Std::Nonblock; |
|
2
|
1
|
|
|
1
|
|
950
|
use 5.010001; |
|
|
1
|
|
|
|
|
2
|
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
18
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
23
|
|
|
5
|
1
|
|
|
1
|
|
6
|
use utf8; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
5
|
|
|
6
|
1
|
|
|
1
|
|
40
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
68
|
|
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = 'v2.0.1'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
5
|
use Scalar::Util qw( weaken refaddr ); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
36
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
4
|
use FCGI::EV::Std; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
480
|
|
|
13
|
|
|
|
|
|
|
$FCGI::EV::Std::BLOCKING= 0; |
|
14
|
|
|
|
|
|
|
$FCGI::EV::Std::MAIN = \&new; |
|
15
|
|
|
|
|
|
|
$FCGI::EV::Std::HUP = \&HUP; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my $CB_START = \&main::START; |
|
18
|
|
|
|
|
|
|
my $CB_PRE = \&main::PRE; |
|
19
|
|
|
|
|
|
|
my $CB_POST = \&main::POST; |
|
20
|
|
|
|
|
|
|
my $CB_ERROR = \&main::ERROR; |
|
21
|
|
|
|
|
|
|
#my $HUP = undef; |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
my (%Active, %Server); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub new { |
|
27
|
0
|
|
|
0
|
0
|
|
my ($server) = @_; |
|
28
|
0
|
|
|
|
|
|
my $self = bless {}, __PACKAGE__; |
|
29
|
0
|
|
|
|
|
|
$Active{ refaddr($self) } = $server; |
|
30
|
0
|
|
|
|
|
|
$Server{ refaddr($server) } = $self; |
|
31
|
0
|
|
|
|
|
|
weaken( $Active{ refaddr($self) } ); |
|
32
|
0
|
|
|
|
|
|
$self->_wrapper($CB_START); |
|
33
|
0
|
|
|
|
|
|
return; |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub done { |
|
37
|
0
|
|
|
0
|
1
|
|
my ($self) = @_; |
|
38
|
0
|
0
|
|
|
|
|
if (exists $Active{ refaddr($self) }) { |
|
39
|
0
|
|
|
|
|
|
my $server = delete $Active{ refaddr($self) }; |
|
40
|
0
|
0
|
|
|
|
|
if ($server) { |
|
41
|
0
|
|
|
|
|
|
delete $Server{ refaddr($server) }; |
|
42
|
0
|
|
|
|
|
|
$server->stdout(q{}, 1); |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
else { |
|
46
|
0
|
|
|
|
|
|
croak 'this request already done()'; |
|
47
|
|
|
|
|
|
|
} |
|
48
|
0
|
|
|
|
|
|
return; |
|
49
|
|
|
|
|
|
|
} |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub HUP { |
|
52
|
0
|
|
|
0
|
0
|
|
my ($server) = @_; |
|
53
|
0
|
0
|
|
|
|
|
return if !$server; # may happens during global destruction |
|
54
|
0
|
0
|
|
|
|
|
if (exists $Server{ refaddr($server) }) { |
|
55
|
0
|
|
|
|
|
|
my $self = delete $Server{ refaddr($server) }; |
|
56
|
|
|
|
|
|
|
# $HUP && $HUP->($self); |
|
57
|
|
|
|
|
|
|
} |
|
58
|
0
|
|
|
|
|
|
return; |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub send { ## no critic (ProhibitBuiltinHomonyms) |
|
62
|
0
|
|
|
0
|
1
|
|
my ($self, $buf) = @_; |
|
63
|
0
|
|
|
|
|
|
my $server = $Active{ refaddr($self) }; |
|
64
|
0
|
0
|
|
|
|
|
if ($server) { |
|
65
|
0
|
|
|
|
|
|
$server->stdout($buf, 0); |
|
66
|
|
|
|
|
|
|
} |
|
67
|
0
|
|
|
|
|
|
return; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub wrap_cb { |
|
71
|
0
|
|
|
0
|
1
|
|
my ($self, $cb, @p) = @_; |
|
72
|
0
|
|
|
|
|
|
weaken(my $this = $self); |
|
73
|
0
|
0
|
|
0
|
|
|
return sub { $this && $this->_wrapper($cb, @p, @_) }; |
|
|
0
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub _wrapper { |
|
77
|
0
|
|
|
0
|
|
|
my ($this, $cb, @p) = @_; |
|
78
|
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
$CB_PRE->($this); |
|
80
|
0
|
0
|
|
|
|
|
my $err = eval { $cb->($this, @p); 1 } ? undef : $@; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
81
|
0
|
|
|
|
|
|
$CB_POST->($this); |
|
82
|
|
|
|
|
|
|
|
|
83
|
0
|
0
|
|
|
|
|
if (defined $err) { |
|
84
|
0
|
|
|
|
|
|
$CB_ERROR->($this, $err); |
|
85
|
|
|
|
|
|
|
} |
|
86
|
0
|
|
|
|
|
|
return; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
1; # Magic true value required at end of module |
|
91
|
|
|
|
|
|
|
__END__ |