line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Twiggy::Prefork::Metabolic::Server; |
2
|
1
|
|
|
1
|
|
929
|
use strict; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
30
|
|
3
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
511
|
use parent qw(Twiggy::Prefork::Server); |
|
1
|
|
|
|
|
285
|
|
|
1
|
|
|
|
|
7
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use constant DEBUG => $ENV{TWIGGY_DEBUG}; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub _accept_handler { |
10
|
|
|
|
|
|
|
my $self = shift; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
my $cb = $self->Twiggy::Server::_accept_handler( @_ ); |
13
|
|
|
|
|
|
|
return $self->{max_reqs_per_child} == 0 ? $cb : sub { |
14
|
|
|
|
|
|
|
my ( $sock, $peer_host, $peer_port ) = @_; |
15
|
|
|
|
|
|
|
$self->{reqs_per_child}++; |
16
|
|
|
|
|
|
|
$cb->( $sock, $peer_host, $peer_port ); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
if ( $self->{reqs_per_child} >= $self->{max_reqs_per_child} ) { |
19
|
|
|
|
|
|
|
DEBUG && warn sprintf "[%s] reach max reqs per child (%d/%d)\n", |
20
|
|
|
|
|
|
|
$$, $self->{reqs_per_child}, $self->{max_reqs_per_child}; |
21
|
|
|
|
|
|
|
$self->{ready_to_exit}++ and return; |
22
|
|
|
|
|
|
|
$self->{exit_guard}->end; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
}; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
1; |
28
|
|
|
|
|
|
|
__END__ |