| 1 | package POEx::HTTP::Server; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | 14 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | 14 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | 14 | ▶ | use Carp qw( carp croak confess cluck ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | 14 | ▶ | use POE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | 14 | ▶ | use POE::Wheel::SocketFactory; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | 14 | ▶ | use POE::Session::PlainCall; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | 14 | ▶ | use POE::Session::Multiplex qw( ev evo evos ), 0.0500; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | 14 | ▶ | use POEx::HTTP::Server::Error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 14 | ▶ | use POEx::URI; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | 14 | ▶ | use Data::Dump qw( pp ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 14 | ▶ | use Scalar::Util qw( blessed ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 14 | ▶ | use Storable qw( dclone ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 14 | our $VERSION = '0.0902'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | sub DEBUG () { 0 and not $INC{'Test/More.pm'} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # Methods common to both the Server and the Client | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | package POEx::HTTP::Server::Base; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | 14 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | 14 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | 14 | ▶ | use POE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 14 | ▶ | use POE::Session::PlainCall; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | 14 | ▶ | use HTTP::Status; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 14 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 14 | ▶ | use Carp::Heavy; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 14 | ▶ | use Data::Dump qw( pp ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | 14 | ▶ | BEGIN { *DEBUG = \&POEx::HTTP::Server::DEBUG } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | # Virtual methods | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 0 | ▶ | sub _psm_begin { die "OVERLOAD ME" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_psm_begin: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub _psm_end { return } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_psm_end: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 5 | ▶ | sub _stop { return } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stop: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub error { return } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | ▶ | sub shutdown { return } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
shutdown: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | # record the current running state | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | sub state | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 142 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
state: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 142 | my( $self, $state ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 142 | my $rv = $self->{state}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 142 | ▶ | if( 2==@_ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 142 | $self->{state} = $state; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | 142 | $self->{S} = { $state => 1 }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 142 | return $rv; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | sub D | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
D: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | $self->_D( 1, @_ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | sub D1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
D1: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 0 | $self->_D(2,@_); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | sub _D | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_D: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | my $level = shift; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | my $prefix = "$$:$self->{name}:"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | ▶ | $prefix .= "$self->{state}:" if $self->{state}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | my $msg = join '', @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | $msg =~ s/^/$prefix /m; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | $DB::single = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | ▶ | unless( $msg =~ /\n$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | my %i = Carp::caller_info($level); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | $msg .= " at $i{file} line $i{line}\n"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | print STDERR $msg; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | # Dispatch a call to a special handler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | sub special_dispatch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 80 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
special_dispatch: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 80 | my( $self, $why, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 80 | my $handler = $self->{specials}{$why}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 80 | ▶ | return unless $handler; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 20 | $self->invoke( $why, $handler, @args ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | # Invoke an HTTP or special handler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | sub invoke | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 36 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
invoke: called CC=3 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 36 | my( $self, $why, $handler, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | 36 | DEBUG and $self->D( "Invoke handler for '$why' ($handler)" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 36 | eval { $poe_kernel->call( @$handler, @args ) }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 36 | ▶ | if( $@ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | warn $@; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | if( $self->{resp} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $self->{resp}->error( RC_INTERNAL_SERVER_ERROR, $@ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | sub net_error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
net_error: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | my( $self, $op, $errnum, $errstr ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | unless( $self->{specials}{on_error} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | # skip out early | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | $self->D( "$op error ($errnum) $errstr" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | die "$$: Failed to bind\n" if $op eq 'bind' and $errnum == 98; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$op eq "bind" and $errnum == 98
MC/DC0%0/2
$op eq "bind" and $errnum == 98
$op eq "bind"
$errnum == 98
Truth table0%0/3
A and B
A= $op eq "bind"B= $errnum == 98
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | DEBUG and $self->D( "$op error ($errnum) $errstr" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | my $err = POEx::HTTP::Server->build_error; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | $err->details( $op, $errnum, $errstr ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $self->special_dispatch( on_error => $err ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | package POEx::HTTP::Server; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 14 | ▶ | use base qw( POEx::HTTP::Server::Base ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | sub spawn | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
spawn: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 5 | my( $package, %options ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 5 | my $self = $package->new( %options ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 5 | my $session = $self->build_session; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | 5 | return $self->{alias}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | sub new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 6 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 6 | my( $package, %options ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 6 | my $self = bless {}, $package; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | 6 | $self->__init( \%options ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 6 | $self->state( 'new' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 6 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | sub __init | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 6 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__init: called CC=24 SCAR=34.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 6 | my( $self, $opt ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 6 | $self->{N} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 6 | $self->{C} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 6 | $self->{options} = delete $opt->{options}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 6 | ▶ | $self->{options} ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"options"} ||= {}
MC/DC0%0/1
$self->{"options"} ||= {}
$self->{"options"}
Truth table50%1/2
A
A= $self->{"options"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 6 | $self->{headers} = delete $opt->{headers}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | 6 | ▶ | $self->{headers} ||= { Server => join '/', ref( $self ), $VERSION }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"headers"} ||= {"Server", join("/", ref $self, $POEx::HTTP::Server::VERSION)}
MC/DC100%1/1
$self->{"headers"} ||= {"Server", join("/", ref $self, $POEx::HTTP::Server::VERSION)}
$self->{"headers"}
Truth table100%2/2
A
A= $self->{"headers"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | 6 | $self->{retry} = delete $opt->{retry}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 6 | ▶ | $self->{retry} = 60 unless defined $self->{retry}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | 6 | $self->{concurrency} = delete $opt->{concurrency}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 6 | ▶ | $self->{concurrency} = -1 unless defined $self->{concurrency}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 6 | $self->{prefork} = delete $opt->{prefork}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 6 | $self->{inet} = delete $opt->{inet}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 6 | ▶ | my $I = $self->{inet} || {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'inet'} || {}
MC/DC0%0/1
$self->{'inet'} || {}
$self->{'inet'}
Truth table50%1/2
A
A= $self->{'inet'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 6 | ▶ | $I->{Listen} ||= 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$I->{"Listen"} ||= 1
MC/DC0%0/1
$I->{"Listen"} ||= 1
$I->{"Listen"}
Truth table50%1/2
A
A= $I->{"Listen"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | 6 | ▶ | $I->{Reuse} = 1 unless defined $I->{Reuse}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | 6 | ▶ | $I->{LocalPort} = 80 unless defined $I->{LocalPort}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | $I->{BindAddr} = delete $I->{LocalAddr} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 6 | ▶ | if $I->{LocalAddr} and not defined $I->{BindAddr}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$I->{"LocalAddr"} and not defined $I->{"BindAddr"}
MC/DC0%0/2
$I->{"LocalAddr"} and not defined $I->{"BindAddr"}
$I->{"LocalAddr"}
not defined $I->{"BindAddr"}
Truth table33%1/3
A and not(B)
A= $I->{"LocalAddr"}B= not defined $I->{"BindAddr"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | $I->{BindPort} = delete $I->{LocalPort} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 6 | ▶ | if $I->{LocalPort} and not defined $I->{BindPort}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$I->{"LocalPort"} and not defined $I->{"BindPort"}
MC/DC50%1/2
$I->{"LocalPort"} and not defined $I->{"BindPort"}
$I->{"LocalPort"}
not defined $I->{"BindPort"}
Truth table66%2/3
A and not(B)
A= $I->{"LocalPort"}B= not defined $I->{"BindPort"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | 6 | $self->{alias} = delete $opt->{alias}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 6 | ▶ | $self->{alias} ||= 'HTTPd'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"alias"} ||= "HTTPd"
MC/DC100%1/1
$self->{"alias"} ||= "HTTPd"
$self->{"alias"}
Truth table100%2/2
A
A= $self->{"alias"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 6 | $self->{name} = $self->{alias}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 6 | ▶ | if( $opt->{error} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | $self->{error} = POEx::URI->new( delete $opt->{error} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 6 | $self->{blocksize} = delete $opt->{blocksize}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 6 | ▶ | $self->{blocksize} ||= 5*1500; # 10 ethernet frames | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{"blocksize"} ||= 7500
MC/DC0%0/1
$self->{"blocksize"} ||= 7500
$self->{"blocksize"}
Truth table50%1/2
A
A= $self->{"blocksize"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 6 | $self->{keepalive} = delete $opt->{keepalive}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 6 | ▶ | if( defined $self->{keepalive} and $self->{keepalive} and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%6/9
defined $self->{"keepalive"} and $self->{"keepalive"} and !($self->{"keepalive"} =~ /^\d+$/) || $self->{"keepalive"} == 1
defined $self->{"keepalive"} and $self->{"keepalive"}
not $self->{"keepalive"} =~ /^\d+$/ or $self->{"keepalive"} == 1
MC/DC0%0/4
defined $self->{"keepalive"} and $self->{"keepalive"} and !($self->{"keepalive"} =~ /^\d+$/) || $self->{"keepalive"} == 1
defined $self->{"keepalive"}
$self->{"keepalive"}
not $self->{"keepalive"} =~ /^\d+$/
$self->{"keepalive"} == 1
Truth table60%3/5
A and B and not(C) or D
A= defined $self->{"keepalive"}B= $self->{"keepalive"}C= not $self->{"keepalive"} =~ /^\d+$/D= $self->{"keepalive"} == 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | ( $self->{keepalive} !~ /^\d+$/ or $self->{keepalive} == 1) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | # Apache 1 default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | #$self->{keepalive} = 15; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | # Apache 2 default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | $self->{keepalive} = 100; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 6 | ▶ | $self->{keepalive} ||= 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{"keepalive"} ||= 0
MC/DC100%1/1
$self->{"keepalive"} ||= 0
$self->{"keepalive"}
Truth table100%2/2
A
A= $self->{"keepalive"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | # warn "keepalive=$self->{keepalive}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 6 | $self->{timeout} = delete $opt->{timeout}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 6 | ▶ | if( not defined $self->{timeout} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | # Apache 1 default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | #$self->{timeout} = 1200; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | # Apache 2 default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | 6 | $self->{timeout} = 300; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 6 | $self->{keepalivetimeout} = delete $opt->{keepalivetimeout}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 6 | ▶ | if( not defined $self->{keepalivetimeout} and $self->{keepalive} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not defined $self->{"keepalivetimeout"} and $self->{"keepalive"}
MC/DC50%1/2
not defined $self->{"keepalivetimeout"} and $self->{"keepalive"}
not defined $self->{"keepalivetimeout"}
$self->{"keepalive"}
Truth table66%2/3
not(A) and B
A= not defined $self->{"keepalivetimeout"}B= $self->{"keepalive"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | # Apache 1 default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | #$self->{keepalivetimeout} = 15; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | # Apache 2 default | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 1 | $self->{keepalivetimeout} = 5; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | # if( $self->{concurrency} > 0 and $self->{prefork} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | # croak "Concurrency and prefork are incompatible. Choose one or the other"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | # } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 6 | $self->__init_handlers( $opt ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | sub __is_special | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 60 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__is_special: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 60 | $_[0] =~ /^(on_error|on_connect|on_disconnect|pre_request|stream_request|post_request)$/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | sub __init_handlers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | 12 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__init_handlers: called CC=10 SCAR=23.3
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | 12 | my( $self, $opt ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | 12 | $self->{handlers} = delete $opt->{handlers}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | # handler => URI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 12 | ▶ | unless( $self->{handlers} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | croak "Missing required handler or handlers param" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | unless $self->{handler}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | $self->{handlers} = { '' => delete $self->{handler} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 12 | $self->{todo} = []; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | # handlers => URI | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 12 | ▶ | unless( ref $self->{handlers} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | 2 | $self->{todo} = [ '' ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 2 | $self->{handlers} = { '' => $self->{handlers} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | # handlers => { match => URI, ... } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | elsif( 'HASH' eq ref $self->{handlers} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | 2 | $self->{todo} = [ keys %{ $self->{handlers} } ]; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | # handlers => [ match => URI, ... } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 8 | my %h; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 8 | ▶ | while( @{ $self->{handlers} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 25 | my $re = shift @{ $self->{handlers} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 25 | ▶ | push @{ $self->{todo} }, $re unless __is_special( $re ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 25 | $h{$re} = shift @{ $self->{handlers} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 8 | $self->{handlers} = \%h; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | # Get a list of special handlers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 12 | my $H = $self->{handlers}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 12 | my $S = $self->{specials} = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 12 | foreach my $re ( keys %$H ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | 30 | ▶ | $H->{$re} = POEx::URI->new( $H->{$re}, 'poe' ) unless blessed $H->{$re}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | 30 | ▶ | next unless __is_special( $re ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | 9 | $S->{$re} = delete $H->{$re}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | 12 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | sub build_session | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_session: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 5 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 5 | my $package = __PACKAGE__; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | return POEx::HTTP::Server::Session->create( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | options => $self->{options}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | 5 | package_states => [ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 'POEx::HTTP::Server::Base' => | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | [ qw( _psm_begin _stop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | error shutdown ) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | $package => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | qw( _start build_server | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | accept retry do_retry close | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | handlers_get handlers_add handlers_remove | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | prefork_child prefork_accept error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | prefork_parent prefork_shutdown | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | ) ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 'POEx::HTTP::Server::Client' => [ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | qw( input timeout | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | respond send | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | sendfile_start | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | flushed done error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | ) ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | args => [ $self ], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | heap => { O=>$self } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | sub build_handle | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_handle: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 5 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 5 | return %{ $self->{inet} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | sub build_error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_error: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | my( $package, $uri ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | $uri ||= '/'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$uri ||= "/"
MC/DC0%0/1
$uri ||= "/"
$uri
Truth table0%0/2
A
A= $uri
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | return POEx::HTTP::Server::Error->new( HTTP::Status::RC_INTERNAL_SERVER_ERROR() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | sub build_server | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_server: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | 5 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | 5 | DEBUG and $self->D( "build_server" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 5 | my %invoke = $self->build_handle; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 5 | DEBUG and $self->D( pp \%invoke ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 5 | $self->{server} = POE::Wheel::SocketFactory->new( | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | %invoke, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | SuccessEvent => ev 'accept', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | FailureEvent => ev 'error' | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | 5 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | sub drop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
drop: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 5 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | 5 | DEBUG and $self->D( "drop" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 5 | delete $self->{server}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | 5 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | sub _start | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_start: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 5 | my( $package, $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 5 | DEBUG and $self->D( "_start" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 5 | $poe_kernel->alias_set( $self->{alias} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | 5 | poe->session->object( HTTPd => $self ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | 5 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | sub _psm_begin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_psm_begin: called CC=2 SCAR=7.5
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | 5 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | 5 | DEBUG and $self->D( "setup" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | 5 | $self->state( 'listen' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | 5 | $poe_kernel->sig( shutdown => ev"shutdown" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | 5 | $self->build_server; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | 5 | ▶ | if( $self->{prefork} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | $self->__init_prefork; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | $self->{server}->pause_accept; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | sub done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
done: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 5 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 5 | DEBUG and $self->D( "done" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 5 | poe->session->object_unregister( 'HTTPd' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | sub _stop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_stop: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | my( $package ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | my $self = poe->heap->{O}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | DEBUG and $self->D( "_stop" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | sub shutdown | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 5 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
shutdown: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 5 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 5 | $self->state( 'shutdown' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 5 | DEBUG and $self->D( "Shutdown" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 5 | ▶ | $poe_kernel->alias_remove( delete $self->{alias} ) if $self->{alias}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 5 | ▶ | foreach my $name ( keys %{ $self->{clients}||{} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'clients'} || {}
MC/DC0%0/1
$self->{'clients'} || {}
$self->{'clients'}
Truth table50%1/2
A
A= $self->{'clients'}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 7 | DEBUG and $self->D( "shutdown client=$name" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 7 | $poe_kernel->yield( evo $name => 'shutdown' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 5 | $self->drop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | sub accept | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 17 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
accept: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 17 | my( $self, $socket, $peer ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | # T->start( 'connection' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 17 | DEBUG and $self->D( "accept" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 17 | $self->state( 'accept' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 17 | my $obj = $self->build_client( $self->{N}++, $socket ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 17 | poe->session->object( $obj->name, $obj ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 17 | $obj->build_wheel( $socket ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | # Starting the timeout here prevents the client from keeping a connection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | # open by never sending a request | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 17 | $obj->timeout_start; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 17 | $self->concurrency_up; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 17 | $self->{clients}{$obj->name} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 17 | DEBUG and $self->D( "accept ".$obj->name." socket=".$socket ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 17 | $self->prefork_accepted; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 17 | $self->state( 'listen' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | sub close | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 17 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
close: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 17 | my( $self, $name ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 17 | DEBUG and | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | $self->D( "close $name" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 17 | $self->concurrency_down; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 17 | delete $self->{clients}{$name}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | # Only close if we really are closed... | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 17 | ▶ | if( $self->{C} == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 13 | $self->prefork_close; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | 17 | ▶ | unless( $self->{C} > 0 or $self->{server} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->{"C"} > 0 or $self->{"server"}
MC/DC100%2/2
$self->{"C"} > 0 or $self->{"server"}
$self->{"C"} > 0
$self->{"server"}
Truth table100%3/3
A or B
A= $self->{"C"} > 0B= $self->{"server"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 5 | $self->done; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | sub concurrency_up | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | 17 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
concurrency_up: called CC=3 SCAR=16.7
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | 17 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 17 | $self->{C}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 17 | ▶ | return unless $self->{concurrency} > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | ▶ | if( $self->{C} >= $self->{concurrency} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | DEBUG and | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | $self->D( "pause_accept C=$self->{C}" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | $self->{server}->pause_accept; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | $self->{paused} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | sub concurrency_down | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | 17 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
concurrency_down: called CC=5 SCAR=27.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 17 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 17 | $self->{C}--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | 17 | ▶ | return unless $self->{concurrency} > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | ▶ | unless( $self->{C} >= $self->{concurrency} and $self->{paused} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"C"} >= $self->{"concurrency"} and $self->{"paused"}
MC/DC0%0/2
$self->{"C"} >= $self->{"concurrency"} and $self->{"paused"}
$self->{"C"} >= $self->{"concurrency"}
$self->{"paused"}
Truth table0%0/3
A and B
A= $self->{"C"} >= $self->{"concurrency"}B= $self->{"paused"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | ▶ | if( $self->{server} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | DEBUG and | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | $self->D( "resume_accept C=$self->{C}" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | $self->{server}->resume_accept; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | $self->{paused} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | sub error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | my( $self, $op, $errnum, $errstr, $id ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | $self->net_error( $op, $errnum, $errstr ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | delete $self->{server}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | $self->retry; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | sub retry | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
retry: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | ▶ | return unless $self->{retry}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | my $tid = $poe_kernel->delay_set( ev"do_retry" => $self->{retry} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | DEBUG and $self->D( "Retry in $self->{retry} seconds. tid=$tid." ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | return $tid; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | sub do_retry | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
do_retry: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | DEBUG and $self->D( "do_retry" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | $self->build_server; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | sub handlers_get | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handlers_get: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | my $ret = dclone $self->{handlers}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | my $S = dclone $self->{specials}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | @{ $ret }{ keys %$S } = values %$S; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | return $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | sub handlers_set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handlers_set: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | my( $self, $H ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | $self->__init_handlers( { handlers=>$H } ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | sub handlers_add | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handlers_add: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 3 | my( $self, $new ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | 3 | ▶ | return unless defined $new; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 3 | my $H = $self->{handlers}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | 3 | my $S = $self->{specials}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | 3 | my $T = $self->{todo}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 3 | $self->__init_handlers( {handlers=>$new} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 3 | delete @{ $S }{ keys %{ $self->{specials} } }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 3 | @{ $self->{specials} }{ keys %$S } = values %$S; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 3 | delete @{ $H }{ keys %{ $self->{handlers} } }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 3 | my @todo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | 3 | foreach my $re ( @$T ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | 12 | ▶ | next if $self->{handlers}{$re}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 12 | push @todo, $re; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 3 | push @todo, @{ $self->{todo} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 3 | $self->{todo} = \@todo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 3 | @{ $self->{handlers} }{ keys %$H } = values %$H; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | sub handlers_remove | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
handlers_remove: called CC=7 SCAR=19.5
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 3 | my( $self, $del ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 3 | my @list; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | my %R; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 3 | ▶ | unless( ref $del ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | 1 | @list = $del; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | elsif( 'HASH' eq ref $del ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 1 | @list = keys %$del; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 1 | @list = @$del; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 3 | foreach my $re ( @list ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 5 | ▶ | if( __is_special( $re ) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | delete $self->{specials}{ $re }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 5 | $R{$re} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 5 | delete $self->{handlers}{ $re }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | 3 | my @todo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | 3 | foreach my $re ( @{ $self->{todo} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | 14 | ▶ | next if $R{$re}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 9 | push @todo, $re; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 3 | $self->{todo} = \@todo; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | sub __init_prefork | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__init_prefork: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | ▶ | return unless $self->{prefork}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | DEBUG and $self->D( "__init_prefork" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | $self->{parent} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | $poe_kernel->sig( daemon_child => ev 'prefork_child' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | 0 | $poe_kernel->sig( daemon_parent => ev 'prefork_parent' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | $poe_kernel->sig( daemon_accept => ev 'prefork_accept' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | $poe_kernel->sig( daemon_shutdown => ev 'prefork_shutdown' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | sub prefork | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prefork: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | my( $package, $status ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | 0 | $poe_kernel->call( Daemon => update_status => $status ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | # Called to tell us we are the child | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | sub prefork_child | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prefork_child: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | DEBUG and | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | $self->D( "prefork_child" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | delete $self->{parent}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | $self->prefork( 'wait' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | # Called when we are the child, and we move to wait state | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | sub prefork_accept | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prefork_accept: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | 0 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | DEBUG and | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | $self->D( "prefork_accept resume_once=".($self->{resume_once}||'') ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | ▶ | if( $self->{resume_once} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | # Daemon->peek( 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | $self->{resume_once} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | 0 | $self->{server}->resume_accept; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | # Called when a new connection opens | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | sub prefork_accepted | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | 17 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prefork_accepted: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | 17 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | 17 | DEBUG and $self->D( "prefork_accepted" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 17 | ▶ | return unless $self->{prefork}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | $self->prefork( 'req' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | # 2012/07 - server handles the pause_accept() etc in concurrency_down | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | #$self->{server}->pause_accept unless $self->{concurrency} > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | # Called when a connection is closed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | sub prefork_close | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | 13 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prefork_close: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 13 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 13 | DEBUG and | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | $self->D( "prefork_close" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 13 | ▶ | return unless $self->{prefork}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | 0 | $self->prefork( 'done' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | # Called when it is clear we are the parent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | sub prefork_parent | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prefork_parent: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | 0 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | 0 | DEBUG and | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | $self->D( "prefork_parent" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | 0 | $self->{parent} = $$; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | sub prefork_shutdown | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
prefork_shutdown: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | DEBUG and | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | $self->D( "prefork_shutdown" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | $self->shutdown; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | sub build_client | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 17 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_client: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 17 | my( $self, $N, $socket ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 17 | my $name = join '-', $self->{alias}, $N; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | return POEx::HTTP::Server::Client->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | socket => $socket, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | __close => ev"close", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | alias => $self->{alias}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | name => $name, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | todo => $self->{todo}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | handlers => dclone $self->{handlers}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | specials => dclone $self->{specials}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | headers => $self->{headers}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | error => $self->{error}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | blocksize => $self->{blocksize}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | timeout => $self->{timeout}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | keepalive => $self->{keepalive}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | keepalivetimeout => $self->{keepalivetimeout}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | 17 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | package POEx::HTTP::Server::Client; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 14 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | 14 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | 14 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | 14 | ▶ | use HTTP::Status; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | 14 | ▶ | use POE; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | 14 | ▶ | use POE::Wheel::ReadWrite; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | 14 | ▶ | use POE::Filter::HTTPD; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | 14 | ▶ | use POEx::HTTP::Server::Request; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 14 | ▶ | use POEx::HTTP::Server::Response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 14 | ▶ | use POEx::HTTP::Server::Connection; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | 14 | ▶ | use POEx::HTTP::Server::Error; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 14 | ▶ | use POE::Session::PlainCall; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | 14 | ▶ | use POE::Session::Multiplex qw( ev evo rsvp ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | 14 | ▶ | use POE::Filter::Stream; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | 14 | ▶ | use base qw( POEx::HTTP::Server::Base ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | 14 | ▶ | use Data::Dump qw( pp ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 14 | ▶ | BEGIN { *DEBUG = \&POEx::HTTP::Server::DEBUG } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | # sub DEBUG () { 1 } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 14 | our $HAVE_SENDFILE; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 14 | ▶ | BEGIN { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=3 SCAR=11.6
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | 14 | ▶ | unless( defined $HAVE_SENDFILE ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 12 | $HAVE_SENDFILE = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | 0 | ▶ | eval " | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | use Sys::Sendfile 0.11; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | "; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 743 | # warn $@ if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 12 | ▶ | $HAVE_SENDFILE = 1 unless $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 749 | sub new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 17 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | 17 | my( $package, %param ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | 17 | my $self = bless { %param }, $package; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | 17 | $self->state( 'waiting' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | 17 | $self->build_connect( delete $self->{socket} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | 17 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | 95 | ▶ | sub name () { $_[0]->{name} } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
name: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | sub build_wheel | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | 17 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_wheel: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 17 | my( $self, $socket ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 17 | my $filter = $self->build_filter; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 768 | $self->{wheel} = POE::Wheel::ReadWrite->new( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | Handle => $socket, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | InputEvent => evo( $self->{name}, 'input' ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | ErrorEvent => evo( $self->{name}, 'error' ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 17 | FlushedEvent => evo( $self->{name}, 'flushed' ), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 773 | Filter => $filter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | sub build_filter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 17 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_filter: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 17 | return POE::Filter::HTTPD->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 780 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | sub build_stream_filter | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_stream_filter: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 784 | 2 | return POE::Filter::Stream->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | sub build_connect | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | 17 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_connect: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | 17 | my( $self, $socket ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | $self->{connection} = | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | 17 | POEx::HTTP::Server::Connection->new( $self->{name}, $socket ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | sub build_response | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 16 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
build_response: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | 16 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 16 | my $resp = POEx::HTTP::Server::Response->new(RC_OK); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 16 | $resp->header( 'X-PID' => $$ ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 16 | ▶ | $resp->request( $self->{req} ) if $self->{req}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | 16 | $resp->{__respond} = rsvp"respond"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 16 | $resp->{__send} = rsvp"send"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 16 | $resp->{__sendfile} = rsvp"sendfile_start"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 16 | $resp->{__done} = rsvp"done"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 805 | 16 | return $resp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | sub _psm_begin | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 17 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_psm_begin: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 17 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 17 | $self->on_connect; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 813 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 815 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 816 | sub on_connect | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 17 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
on_connect: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 17 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 17 | $self->special_dispatch( on_connect => $self->{connection} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 820 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | sub on_disconnect | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 17 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
on_disconnect: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 17 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 17 | $self->special_dispatch( on_disconnect => $self->{connection} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 826 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 827 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 828 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 829 | sub error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
error: called CC=3 SCAR=12.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 3 | my( $self, $op, $errnum, $errstr, $id ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 832 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | 3 | ▶ | if( $op eq 'read' and $errnum == 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$op eq "read" and $errnum == 0
MC/DC0%0/2
$op eq "read" and $errnum == 0
$op eq "read"
$errnum == 0
Truth table33%1/3
A and B
A= $op eq "read"B= $errnum == 0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | # this is a normal error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 3 | DEBUG and | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 836 | $self->D( "$op error ($errnum) $errstr" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 838 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | $self->net_error( $op, $errnum, $errstr ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 840 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | # 2013-04 - We use ->yield and not ->close so that POE can empty the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | # queue of all events provoked by the last select(). This way the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | # explicit socket->close will not cause problems. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | 3 | $poe_kernel->yield( ev "close" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 849 | sub close | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 17 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
close: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | 17 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | 17 | $self->state( 'closing' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 17 | DEBUG and | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | $self->D( "Close" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 855 | 17 | $poe_kernel->yield( $self->{__close}, $self->name ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 17 | poe->session->object_unregister( $self->{name} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 17 | $self->on_disconnect; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 17 | $self->close_connection; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 17 | $self->keepalive_stop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | 17 | $self->timeout_stop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | # use POE::Component::Daemon; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | # Daemon->peek( 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 865 | sub close_connection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 866 | 17 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
close_connection: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | 17 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | 17 | DEBUG and $self->D( "close_connection" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | 17 | my $C = delete $self->{connection}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | 17 | $C->{aborted} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 17 | my $W = delete $self->{wheel}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 17 | ▶ | if( $W ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 17 | my $socket = $W->get_input_handle; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 17 | $W->DESTROY; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 875 | 17 | ▶ | if( $socket ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | 17 | DEBUG and $self->D( "Shutdown socket=$socket" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | # Do an explicit shutdown, for Windows problems | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | 17 | shutdown( $socket, 2 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | 17 | $socket->close; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | # T->end( 'connection' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | 17 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | sub drop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | 18 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
drop: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | 18 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | 18 | delete $self->{req}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | 18 | delete $self->{resp}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | sub input | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | 18 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
input: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | 18 | my( $self, $req ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | # T->start( 'REQ' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | 18 | DEBUG and $self->D( "input" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | 18 | $self->state( 'handling' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | # stop the timer that was started on accept | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | 18 | $self->timeout_stop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | # stop any keepalive timer we might have | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | 18 | $self->keepalive_stop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | 18 | ▶ | if( $self->{req} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | warn "New request while we still have a request"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | 0 | $self->pending_push( $req ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | 18 | ▶ | if ( $req->isa("HTTP::Response") ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | 2 | $self->input_error( $req ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | 2 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | # Rebless to our package | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | 16 | $self->{req} = bless $req, 'POEx::HTTP::Server::Request'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | 16 | $req->connection( $self->{connection} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | # Tell the user code | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | 16 | $self->special_dispatch( 'pre_request', $req ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | # Build response | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | 16 | $self->{resp} = $self->build_response; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | 16 | $self->reset_req; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | 16 | $self->dispatch; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | sub input_error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | 2 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
input_error: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | 2 | my( $self, $resp ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | 2 | DEBUG and $self->D( "ERROR ", $resp->status_line ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | 2 | bless $resp, 'POEx::HTTP::Server::Error'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | 2 | $self->special_dispatch( on_error => $resp ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | 2 | $self->{req} = POEx::HTTP::Server::Request->new( ERROR => '/' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | 2 | $self->{req}->connection( $self->{connection} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | 2 | $self->{req}->protocol( "HTTP/1.1" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | 2 | $self->{resp} = $resp; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | 2 | $self->reset_req; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | 2 | $self->{shutdown} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | 2 | $self->respond; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | sub reset_req | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | 18 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
reset_req: called CC=2 SCAR=7.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | 18 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | 18 | ▶ | if( delete $self->{stream_wheel} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | # Second request on a keep-alive wheel. Switch back to Filter::HTTPD | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | 0 | $self->{wheel}->set_output_filter( $self->build_filter ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | 18 | $self->{will_close} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | 18 | $self->{once} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | 18 | $self->{flushing} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | sub output | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | 29 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
output: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | 29 | my( $self, $something ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | 29 | $self->{flushing} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | # T->point( REQ => 'output' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | 29 | $self->{wheel}->put( $something ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | ## POE::Wheel::ReadWrite is telling us that what we wrote has been written | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | sub flushed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | 29 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
flushed: called CC=6 SCAR=18.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | 29 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | 29 | $self->{flushing} = 0; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | 29 | DEBUG and $self->D( "Flushed" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | # wrote a bit of a file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | 29 | ▶ | if( $self->{sendfile} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | 1 | return $self->sendfile_next; # send some more | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | # Request has finished | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | 28 | ▶ | if( not $self->{resp} or $self->{S}{done} or $self->{resp}->finished ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition83%5/6
not $self->{"resp"} or $self->{"S"}{"done"} or $self->{"resp"}->finished
not $self->{"resp"} or $self->{"S"}{"done"}
MC/DC66%2/3
not $self->{"resp"} or $self->{"S"}{"done"} or $self->{"resp"}->finished
not $self->{"resp"}
$self->{"S"}{"done"}
$self->{"resp"}->finished
Truth table75%3/4
not(A) or B or C
A= not $self->{"resp"}B= $self->{"S"}{"done"}C= $self->{"resp"}->finished
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | 18 | return $self->finish_request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | # streaming? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | elsif( $self->{resp}->streaming ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | 10 | return $self->send_more; # send some more | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | # The last possiblity is that calls to ->send have filled up the Wheel's | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | # or the driver's buffer and it was flushed. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | # Clean up after a request | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | sub finish_request | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | 18 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
finish_request: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | 18 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | 18 | $self->state( 'done' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | 18 | DEBUG and $self->D( 'finish_request' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | 18 | ▶ | if( $self->keepalive_start ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | # if we have keepalive set, then we don't need the TCP timeout | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | 4 | $self->timeout_stop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | # If we don't have a keepalive, {will_close} will be true and that will | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | # force a socket close | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | # next 3 MUST be in this order if we want post_request to always come | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | # before on_disconnect (which is posted from ->close()) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | 18 | $self->special_dispatch( 'post_request', $self->{req}, $self->{resp} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | 18 | ▶ | $self->close if $self->{will_close}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | 18 | $self->drop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | 18 | $self->pending_next; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | # T->end( 'REQ' ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | sub dispatch | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | 16 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dispatch: called CC=4 SCAR=15.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | 16 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | my $path = $self->{req} && $self->{req}->uri ? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | 16 | ▶ | $self->{req}->uri->path : '/'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"req"} and $self->{"req"}->uri
MC/DC0%0/2
$self->{"req"} and $self->{"req"}->uri
$self->{"req"}
$self->{"req"}->uri
Truth table33%1/3
A and B
A= $self->{"req"}B= $self->{"req"}->uri
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | 16 | my( $why, $handler ) = $self->find_handler( $path ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | 16 | ▶ | if( $handler ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | # T->point( REQ => "handler $re" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | 16 | $self->invoke( $why, $handler, $self->{req}, $self->{resp} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | 0 | $self->{resp}->error( RC_NOT_FOUND, "No handler for path $path.\n" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | sub find_handler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | 20 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
find_handler: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | 20 | my( $self, $path ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | 20 | DEBUG and $self->D( "Request for $path" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | 20 | foreach my $re ( @{ $self->{todo} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | 39 | ▶ | next unless $re eq '' or $path =~ /$re/; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$re eq "" or $path =~ /$re/
MC/DC100%2/2
$re eq "" or $path =~ /$re/
$re eq ""
$path =~ /$re/
Truth table100%3/3
A or B
A= $re eq ""B= $path =~ /$re/
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | 19 | return( $re, $self->{handlers}{$re} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | 1 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | sub respond | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | 16 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
respond: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | 16 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | 16 | DEBUG and $self->D( "respond" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | # XXX - make this next bit a POE-croak | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | 16 | ▶ | confess "Responding more then once to a request" if $self->{once}++; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | 16 | ▶ | unless( $self->{resp}->headers_sent ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | 16 | $self->should_close; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | 16 | $self->send_headers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | 16 | $self->{resp}->content( undef() ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | 16 | $self->timeout_start(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | 16 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | sub send_headers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | 18 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_headers: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | 18 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | 18 | DEBUG and $self->D( "Response: ".$self->{resp}->status_line ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | 18 | $self->__fix_headers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | 18 | $self->output( $self->{resp} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | 18 | $self->{resp}->headers_sent( 1 ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | sub __fix_headers | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | 18 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__fix_headers: called CC=7 SCAR=20.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | 18 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | 18 | ▶ | while( my( $h, $v ) = each %{$self->{headers}} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | 18 | ▶ | next if $self->{resp}->header( $h ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | 18 | $self->{resp}->header( $h => $v); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | # Tell the browser the connection should close | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | 18 | ▶ | if( $self->{will_close} and $self->{req} and $self->{req}->protocol eq 'HTTP/1.1' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
$self->{"will_close"} and $self->{"req"} and $self->{"req"}->protocol eq "HTTP/1.1"
$self->{"will_close"} and $self->{"req"}
MC/DC33%1/3
$self->{"will_close"} and $self->{"req"} and $self->{"req"}->protocol eq "HTTP/1.1"
$self->{"will_close"}
$self->{"req"}
$self->{"req"}->protocol eq "HTTP/1.1"
Truth table50%2/4
A and B and C
A= $self->{"will_close"}B= $self->{"req"}C= $self->{"req"}->protocol eq "HTTP/1.1"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | 14 | my $c = $self->{resp}->header( 'Connection' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | 0 | ▶ | if( $c ) { $c .= ",close" } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | 14 | else { $c = 'close' } | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | 14 | $self->{resp}->header( 'Connection', $c ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | sub should_close | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | 18 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
should_close: called CC=10 SCAR=23.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | 18 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | 18 | $self->{will_close} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | 18 | ▶ | if ( $self->{req} and $self->{req}->protocol eq 'HTTP/1.1' ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"req"} and $self->{"req"}->protocol eq "HTTP/1.1"
MC/DC0%0/2
$self->{"req"} and $self->{"req"}->protocol eq "HTTP/1.1"
$self->{"req"}
$self->{"req"}->protocol eq "HTTP/1.1"
Truth table33%1/3
A and B
A= $self->{"req"}B= $self->{"req"}->protocol eq "HTTP/1.1"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | 18 | $self->{will_close} = 0; # keepalive | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | # It turns out the connection field can contain multiple | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | # comma separated values | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | 18 | ▶ | my $conn = $self->{req}->header('Connection')||''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition100%2/2
$self->{'req'}->header('Connection') || ''
MC/DC100%1/1
$self->{'req'}->header('Connection') || ''
$self->{'req'}->header('Connection')
Truth table100%2/2
A
A= $self->{'req'}->header('Connection')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | 18 | ▶ | $self->{will_close} = 1 if qq(,$conn,) =~ /,\s*close\s*,/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | #warn "$$:conn=$conn will_close=$self->{will_close}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | # Allow handler code to control the connection | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | 18 | ▶ | $conn = $self->{resp}->header('Connection')||''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$self->{'resp'}->header('Connection') || ''
MC/DC0%0/1
$self->{'resp'}->header('Connection') || ''
$self->{'resp'}->header('Connection')
Truth table50%1/2
A
A= $self->{'resp'}->header('Connection')
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | 18 | ▶ | $self->{will_close} = 1 if qq(,$conn,) =~ /,\s*close\s*,/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | #warn "$$:conn=$conn will_close=$self->{will_close}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | # HTTP/1.0-style keep-alives fail | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | #my $conn = $self->{req}->header('Connection')||''; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | #$self->{will_close} = 0 if qq(,$conn,) =~ /,\s*keep-alive\s*,/i; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | #warn "$$:conn=$conn will_close=$self->{will_close}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | 18 | ▶ | $self->{will_close} = 1 if $self->{resp}->streaming; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | #warn "$$:post streaming will_close=$self->{will_close}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | 18 | ▶ | $self->{will_close} = 1 unless $self->{keepalive} > 1; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | #warn "$$:post keepalive will_close=$self->{will_close}"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | 18 | ▶ | $self->{will_close} = 1 if $self->{shutdown}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | 18 | DEBUG and | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | $self->D( "will_close=$self->{will_close}" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | 18 | return $self->{will_close}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | sub send | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | 13 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send: called CC=8 SCAR=20.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | 13 | my( $self, $something ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | 13 | DEBUG and $self->D("send"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | 13 | ▶ | confess "Responding more then once to a request" unless $self->{resp}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | 13 | ▶ | unless( $self->{resp}->headers_sent ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | 2 | $self->should_close; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | 2 | $self->send_headers; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | 2 | $self->{stream_wheel} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | 2 | $self->{wheel}->set_output_filter( $self->build_stream_filter ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | 2 | ▶ | if( $self->{resp}->streaming ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | 1 | eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | 1 | $SIG{__DIE__} = 'DEFAULT'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | 1 | $self->__tcp_hot; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | 1 | ▶ | warn $@ if $@; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | 13 | ▶ | $self->output( $something ) if defined $something; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | 13 | ▶ | if( $self->{resp}->streaming and $self->{wheel} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"resp"}->streaming and $self->{"wheel"}
MC/DC50%1/2
$self->{"resp"}->streaming and $self->{"wheel"}
$self->{"resp"}->streaming
$self->{"wheel"}
Truth table66%2/3
A and B
A= $self->{"resp"}->streamingB= $self->{"wheel"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | 11 | $self->{wheel}->flush; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | 13 | $self->timeout_start(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | 13 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | # We are in streaming mode. The last chunk has flushed. Send a new one | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | sub send_more | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | 10 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_more: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | 10 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | 10 | $self->timeout_stop(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | 10 | $self->special_dispatch( 'stream_request', $self->{req}, $self->{resp} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | # We are in streaming mode. Turn off Nagle's algorithm | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | # This isn't as effective as you might think | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | sub __tcp_hot | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__tcp_hot: called CC=3 SCAR=11.2
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | 1 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | 1 | DEBUG and | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | $self->D( "TCP_NODELAY" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | 1 | my $h = $self->{wheel}->get_output_handle; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | 1 | ▶ | setsockopt($h, Socket::IPPROTO_TCP(), Socket::TCP_NODELAY(), 1) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | or die "setsockopt TCP_NODELAY: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | # Note: On linux, even if we set the buffer size to 576, the minimum | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | # is 2048. However, this still allows us to by-pass Nagle's algorithm. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | 1 | ▶ | setsockopt($h, Socket::SOL_SOCKET(), Socket::SO_SNDBUF(), 576) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | or die "setsockopt SO_SNDBUF: $!"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | 1 | DEBUG and $self->D( "SO_SNDBUF=", unpack "i", | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | getsockopt($h, Socket::SOL_SOCKET(), Socket::SO_SNDBUF())); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | sub __tcp_sndbuf | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__tcp_sndbuf: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | 0 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | 0 | my $h = $self->{wheel}->get_output_handle; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | 0 | my $bs = eval { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | 0 | $SIG{__DIE__} = 'DEFAULT'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | 0 | return unpack "i", getsockopt($h, Socket::SOL_SOCKET(), Socket::SO_SNDBUF()); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | 0 | return $bs; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | # Send an entire file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | # This is a callback from Response | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | # $path is what should be reported in errors | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | # $file is the full path to a readable file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | # $size is the amount of the file to send. Should be entire file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | sub sendfile_start | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sendfile_start: called CC=3 SCAR=11.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | 1 | my( $self, $path, $file, $size ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | 1 | ▶ | die "Already sending a file" if $self->{sendfile}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | 1 | DEBUG and $self->D( "sendfile path=$path size=$size" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | # Open the file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | 1 | my $fh = IO::File->new; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | 1 | ▶ | unless( $fh->open($file) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | 0 | $self->{resp}->error(RC_INTERNAL_SERVER_ERROR, "Unable to open $path: $!" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | $self->{sendfile} = { offset=>0, size=>$size, fh=>$fh, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | 1 | path=>$path, bs=>$self->{blocksize} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | 1 | $self->send; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | # we wait for the 'flush' event to invoke sendfile. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | 1 | $self->timeout_start(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | sub sendfile_next | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | 1 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sendfile_next: called CC=6 SCAR=20.1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | 1 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | 1 | my $S = $self->{sendfile}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | 14 | ▶ | use bytes; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | 1 | my $len; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | 1 | ▶ | if( $HAVE_SENDFILE ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | 0 | DEBUG and $self->D( "sendfile path=$S->{path} offset=$S->{offset}" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | 0 | my $socket = $self->{wheel}->get_output_handle; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | 0 | $len = sendfile( $socket, $S->{fh}, 0, $S->{offset} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | 0 | ▶ | unless( defined $len ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | 0 | $self->net_error( 'sendfile', 0+$!, "$!" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | 0 | $poe_kernel->select_resume_write( $socket ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | 1 | DEBUG and $self->D( "sysread path=$S->{path} offset=$S->{offset}" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | 1 | my $c = ''; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | 1 | $len = sysread( $S->{fh}, $c, $S->{bs} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | 1 | ▶ | if( $len > 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | 1 | DEBUG and $self->D( "send bytes=".length $c ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | 1 | $self->send( $c ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | 1 | $S->{offset} += $len; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | 1 | ▶ | if( $S->{offset} >= $S->{size} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | 1 | DEBUG and $self->D( "sendfile done" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | 1 | ▶ | $self->D( "Sendfile sent to many bytes!" ) if $S->{offset} > $S->{size}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | 1 | $self->done; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | 1 | delete $self->{sendfile}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | 1 | $self->timeout_start(); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | 1 | return $len; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | sub done | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | 15 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
done: called CC=3 SCAR=12.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | 15 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | 15 | $self->state( 'done' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | 15 | DEBUG and $self->D( "Done" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | # If we don't have a {req}, then the request has already finished | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | # But wait until request is flushed to finish it. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | 15 | ▶ | if( not $self->{flushing} and $self->{req} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $self->{"flushing"} and $self->{"req"}
MC/DC0%0/2
not $self->{"flushing"} and $self->{"req"}
not $self->{"flushing"}
$self->{"req"}
Truth table33%1/3
not(A) and B
A= not $self->{"flushing"}B= $self->{"req"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | 0 | $self->finish_request; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | sub keepalive_start | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | 18 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
keepalive_start: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | 18 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | # $self->D( "will_close=$self->{will_close} keepalive=$self->{keepalive}" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | 18 | ▶ | return if $self->{will_close}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | 4 | $self->{keepalive}--; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | 4 | ▶ | return unless $self->{keepalive} > 0; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | 4 | DEBUG and | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | $self->D( "keep-alive=$self->{keepalive}" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | 4 | DEBUG and $self->D( "keep-alive timeout=$self->{keepalivetimeout}" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | $self->{KAID} = $poe_kernel->delay_set( ev"timeout", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | $self->{keepalivetimeout} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | 4 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | 4 | DEBUG and $self->D1( "keep-alive start tid=$self->{KAID}" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | 4 | $self->state( 'waiting' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | 4 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | sub timeout | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
timeout: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | 0 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | 0 | $self->keepalive_stop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | 0 | $self->timeout_stop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | 0 | $self->close; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | sub keepalive_stop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | 38 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
keepalive_stop: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | 38 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | 38 | ▶ | return unless $self->{KAID}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | 4 | DEBUG and $self->D1( "keep-alive stop tid=$self->{KAID}" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | 4 | $poe_kernel->alarm_remove( delete $self->{KAID} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | sub timeout_start | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | 48 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
timeout_start: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | 48 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | 48 | ▶ | return unless $self->{timeout} and $self->{connection}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"timeout"} and $self->{"connection"}
MC/DC50%1/2
$self->{"timeout"} and $self->{"connection"}
$self->{"timeout"}
$self->{"connection"}
Truth table66%2/3
A and B
A= $self->{"timeout"}B= $self->{"connection"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | 47 | ▶ | if( $self->{TID} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | 3 | DEBUG and | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | $self->D1( "timeout restart tid=$self->{TID}" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | 3 | $poe_kernel->delay_adjust( $self->{TID}, $self->{timeout} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | 44 | DEBUG and $self->D( "timeout timeout=$self->{timeout}" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | $self->{TID} = $poe_kernel->delay_set( evo( $self->name, "timeout" ), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | $self->{timeout} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | 44 | ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | 44 | DEBUG and | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | $self->D1( "timeout start tid=$self->{TID}" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | sub timeout_stop | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | 49 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
timeout_stop: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | 49 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | 49 | ▶ | return unless $self->{TID}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | 44 | DEBUG and | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | $self->D1( "timeout stop tid=$self->{TID}" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | 44 | $poe_kernel->alarm_remove( delete $self->{TID} ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | sub shutdown | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | 3 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
shutdown: called CC=3 SCAR=11.4
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | 3 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | 3 | my $state = $self->state( 'shutdown' ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | 3 | DEBUG and $self->D( "shutdown flushing=$self->{flushing} state=$state" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | 3 | $self->{shutdown} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | 3 | $self->{will_close} = 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | # If we are handling a request or flushing it's output, we wait | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | # until that's completed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | 3 | ▶ | $self->close unless $self->{flushing} or $state eq 'handling'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"flushing"} or $state eq "handling"
MC/DC0%0/2
$self->{"flushing"} or $state eq "handling"
$self->{"flushing"}
$state eq "handling"
Truth table33%1/3
A or B
A= $self->{"flushing"}B= $state eq "handling"
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | 3 | $self->keepalive_stop; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | sub pending_push | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pending_push: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | 0 | my( $self, $req ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | 0 | push @{ $self->{pending} }, $req; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | sub pending_next | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | 18 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pending_next: called CC=6 SCAR=32.7
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | 18 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | 0 | ▶ | return unless $self->{pending} and @{ $self->{pending} }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"pending"} and @{$self->{"pending"};}
MC/DC0%0/2
$self->{"pending"} and @{$self->{"pending"};}
$self->{"pending"}
@{$self->{"pending"};}
Truth table33%1/3
A and B
A= $self->{"pending"}B= @{$self->{"pending"};}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | 0 | ▶ | if( $self->{S}{shutdown} or $self->{S}{closing} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->{"S"}{"shutdown"} or $self->{"S"}{"closing"}
MC/DC0%0/2
$self->{"S"}{"shutdown"} or $self->{"S"}{"closing"}
$self->{"S"}{"shutdown"}
$self->{"S"}{"closing"}
Truth table0%0/3
A or B
A= $self->{"S"}{"shutdown"}B= $self->{"S"}{"closing"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | 0 | $self->D( "We are closing down with pending requests" ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | 0 | $self->pending_no_reply; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | 0 | my $next = shift @{ $self->{pending} }; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | 0 | ▶ | return unless $next; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | 0 | $self->input( $next ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | ####################################### | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | sub pending_no_reply | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
pending_no_reply: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | 0 | my( $self ) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | 0 | ▶ | return unless $self->{wheel}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | 0 | foreach my $req ( @{ $self->{pending} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | 0 | my $resp = $self->build_error_response( RC_SERVICE_UNAVAILABLE, | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | "This request could not be handled." ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | 0 | $self->{wheel}->put( $resp ); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | last unless $self->{wheel} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | 0 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | 0 | ▶ | $self->{wheel}->flush() if $self->{wheel}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | ############################################################################## | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | package POEx::HTTP::Server::Session; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | 14 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | 14 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | 14 | ▶ | use POE::Session::PlainCall; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | 14 | ▶ | use POE::Session::Multiplex; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | 14 | ▶ | use base qw( POE::Session::Multiplex POE::Session::PlainCall ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | 14 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||