| 1 | package Sprocket::Connection; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use POE qw( Wheel::SocketFactory Wheel::ReadWrite ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use Sprocket; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use Class::Accessor::Fast; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use Time::HiRes qw( time ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use base qw( Class::Accessor::Fast ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use Scalar::Util qw( weaken ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 5 | ▶ | use overload '""' => sub { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 12 | 75 | my $self = shift; | |||||||||||||||||||||||||||
| 13 | 75 | my $id = $self->ID(); | |||||||||||||||||||||||||||
| 14 | 75 | ▶ | return $id ? __PACKAGE__.'/'.$id : $self; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 15 | 5 | }; | |||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 5 | __PACKAGE__->mk_accessors( qw( | |||||||||||||||||||||||||||
| 18 | sf | ||||||||||||||||||||||||||||
| 19 | wheel | ||||||||||||||||||||||||||||
| 20 | connected | ||||||||||||||||||||||||||||
| 21 | close_on_flush | ||||||||||||||||||||||||||||
| 22 | error | ||||||||||||||||||||||||||||
| 23 | plugin | ||||||||||||||||||||||||||||
| 24 | active_time | ||||||||||||||||||||||||||||
| 25 | create_time | ||||||||||||||||||||||||||||
| 26 | parent_id | ||||||||||||||||||||||||||||
| 27 | event_manager | ||||||||||||||||||||||||||||
| 28 | fused | ||||||||||||||||||||||||||||
| 29 | peer_ip | ||||||||||||||||||||||||||||
| 30 | peer_ips | ||||||||||||||||||||||||||||
| 31 | peer_port | ||||||||||||||||||||||||||||
| 32 | peer_addr | ||||||||||||||||||||||||||||
| 33 | peer_hostname | ||||||||||||||||||||||||||||
| 34 | local_ip | ||||||||||||||||||||||||||||
| 35 | local_port | ||||||||||||||||||||||||||||
| 36 | state | ||||||||||||||||||||||||||||
| 37 | time_out | ||||||||||||||||||||||||||||
| 38 | time_out_id | ||||||||||||||||||||||||||||
| 39 | ID | ||||||||||||||||||||||||||||
| 40 | ssl | ||||||||||||||||||||||||||||
| 41 | x | ||||||||||||||||||||||||||||
| 42 | socket | ||||||||||||||||||||||||||||
| 43 | ) ); | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 8 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=14.8
Pod
documented
| |||||||||||||||||||||||||||||
| 46 | 8 | my $class = shift; | |||||||||||||||||||||||||||
| 47 | 8 | my $time = time(); | |||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | 8 | ▶ | my $self = bless({ | ||||||||||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||||||||||
| 50 | sf => undef, | ||||||||||||||||||||||||||||
| 51 | wheel => undef, | ||||||||||||||||||||||||||||
| 52 | connected => 0, | ||||||||||||||||||||||||||||
| 53 | close_on_flush => 0, | ||||||||||||||||||||||||||||
| 54 | plugin => undef, | ||||||||||||||||||||||||||||
| 55 | active_time => $time, | ||||||||||||||||||||||||||||
| 56 | create_time => $time, | ||||||||||||||||||||||||||||
| 57 | parent_id => undef, | ||||||||||||||||||||||||||||
| 58 | event_manager => 'eventman', # XXX | ||||||||||||||||||||||||||||
| 59 | fused => undef, | ||||||||||||||||||||||||||||
| 60 | peer_ip => undef, | ||||||||||||||||||||||||||||
| 61 | peer_port => undef, | ||||||||||||||||||||||||||||
| 62 | state => undef, | ||||||||||||||||||||||||||||
| 63 | channels => {}, | ||||||||||||||||||||||||||||
| 64 | alarms => {}, | ||||||||||||||||||||||||||||
| 65 | clid => undef, | ||||||||||||||||||||||||||||
| 66 | destroy_events => {}, | ||||||||||||||||||||||||||||
| 67 | peer_ips => [], | ||||||||||||||||||||||||||||
| 68 | socket => undef, | ||||||||||||||||||||||||||||
| 69 | error => undef, | ||||||||||||||||||||||||||||
| 70 | time_out_id => undef, # use for client connections | ||||||||||||||||||||||||||||
| 71 | ssl => undef, | ||||||||||||||||||||||||||||
| 72 | x => {}, | ||||||||||||||||||||||||||||
| 73 | @_ | ||||||||||||||||||||||||||||
| 74 | }, ref $class || $class ); | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | # generate the connection ID | ||||||||||||||||||||||||||||
| 77 | 8 | $self->ID( ( "$self" =~ m/\(0x([^\)]+)\)/o )[ 0 ] ); | |||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | # XXX keep this? | ||||||||||||||||||||||||||||
| 80 | 8 | ▶ | if ( $self->{peer_ip} && !@{$self->{peer_ips}} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->{"peer_ip"} and not @{$self->{"peer_ips"};}
MC/DC0%0/2
$self->{"peer_ip"} and not @{$self->{"peer_ips"};}
$self->{"peer_ip"}
not @{$self->{"peer_ips"};}
Truth table33%1/3
A and not(B)
A= $self->{"peer_ip"}B= not @{$self->{"peer_ips"};}
| |||||||||||||||||||||||||||||
| 81 | 8 | push( @{$self->{peer_ips}}, $self->{peer_ip} ); | |||||||||||||||||||||||||||
| 82 | } | ||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | 8 | return $self; | |||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | 47 | ▶ | sub event { | ||||||||||||||||||||||||||
|
Subroutine
event: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 88 | 47 | return $_[ 0 ]->ID.'/'.$_[ 1 ]; | |||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||
| 91 | 4 | ▶ | sub socket_factory { | ||||||||||||||||||||||||||
|
Subroutine
socket_factory: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 92 | 4 | my $self = shift; | |||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 4 | $self->sf( | |||||||||||||||||||||||||||
| 95 | POE::Wheel::SocketFactory->new( @_ ) | ||||||||||||||||||||||||||||
| 96 | ); | ||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||
| 98 | 4 | return; | |||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||
| 101 | 8 | ▶ | sub wheel_readwrite { | ||||||||||||||||||||||||||
|
Subroutine
wheel_readwrite: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 102 | 8 | my $self = shift; | |||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | 8 | $self->wheel( | |||||||||||||||||||||||||||
| 105 | POE::Wheel::ReadWrite->new( @_ ) | ||||||||||||||||||||||||||||
| 106 | ); | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 8 | return; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 12 | ▶ | sub filter { | ||||||||||||||||||||||||||
|
Subroutine
filter: called CC=2 SCAR=7.1
Pod
documented
| |||||||||||||||||||||||||||||
| 112 | 12 | my $self = shift; | |||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 12 | ▶ | $self->wheel->set_filter( @_ ) if ( @_ ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 12 | return $self->wheel->get_input_filter; | |||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||
| 119 | 0 | ▶ | sub filter_in { | ||||||||||||||||||||||||||
|
Subroutine
filter_in: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 120 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 0 | ▶ | $self->wheel->set_input_filter( @_ ) if ( @_ ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 0 | return $self->wheel->get_input_filter; | |||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 0 | ▶ | sub filter_out { | ||||||||||||||||||||||||||
|
Subroutine
filter_out: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 128 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||
| 130 | 0 | ▶ | $self->wheel->set_output_filter( @_ ) if ( @_ ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||
| 132 | 0 | return $self->wheel->get_output_filter; | |||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||
| 135 | 5 | *write = *send; | |||||||||||||||||||||||||||
| 136 | |||||||||||||||||||||||||||||
| 137 | 13 | ▶ | sub send { | ||||||||||||||||||||||||||
|
Subroutine
send: called CC=4 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 138 | 13 | my $self = shift; | |||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||
| 140 | 13 | ▶ | unless ( $self->connected ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 141 | 0 | $self->_log( v => 1, msg => "cannot send data. not connected, or disconnecting after flush" ); | |||||||||||||||||||||||||||
| 142 | 0 | return; | |||||||||||||||||||||||||||
| 143 | } | ||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | 13 | ▶ | if ( my $wheel = $self->wheel ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | 13 | $self->active(); | |||||||||||||||||||||||||||
| 147 | 13 | return $wheel->put(@_); | |||||||||||||||||||||||||||
| 148 | } else { | ||||||||||||||||||||||||||||
| 149 | # XXX does this happen | ||||||||||||||||||||||||||||
| 150 | 0 | ▶ | $self->_log( v => 1, msg => "cannot send data. where did my wheel go?! !EMAIL XANTUS! ". | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 151 | ( $self->error ? $self->error : '' ) ); | ||||||||||||||||||||||||||||
| 152 | } | ||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | 1 | ▶ | sub set_time_out { | ||||||||||||||||||||||||||
|
Subroutine
set_time_out: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 156 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 1 | $self->active(); | |||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||
| 160 | 1 | $self->time_out( shift ); | |||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 0 | ▶ | sub alarm_set { | ||||||||||||||||||||||||||
|
Subroutine
alarm_set: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 164 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 165 | 0 | my $event = $self->event( shift ); | |||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 0 | $self->active(); | |||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | 0 | my $id = $poe_kernel->call( $self->parent_id => call_in_ses_context => alarm_set => $event => @_ ); | |||||||||||||||||||||||||||
| 170 | 0 | $self->{alarms}->{ $id } = $event; | |||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | 0 | return $id; | |||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||
| 175 | 0 | ▶ | sub alarm_adjust { | ||||||||||||||||||||||||||
|
Subroutine
alarm_adjust: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 176 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 0 | $self->active(); | |||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||
| 180 | 0 | $poe_kernel->call( $self->parent_id => call_in_ses_context => alarm_adjust => @_ ); | |||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||
| 183 | 0 | ▶ | sub alarm_remove { | ||||||||||||||||||||||||||
|
Subroutine
alarm_remove: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 184 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 185 | 0 | my $id = shift; | |||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 0 | $self->active(); | |||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||
| 189 | # XXX exists | ||||||||||||||||||||||||||||
| 190 | 0 | delete $self->{alarms}->{ $id }; | |||||||||||||||||||||||||||
| 191 | 0 | $poe_kernel->call( $self->parent_id => call_in_ses_context => alarm_remove => $id => @_ ); | |||||||||||||||||||||||||||
| 192 | } | ||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||
| 194 | 0 | ▶ | sub alarm_remove_all { | ||||||||||||||||||||||||||
|
Subroutine
alarm_remove_all: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 195 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 0 | $self->active(); | |||||||||||||||||||||||||||
| 198 | |||||||||||||||||||||||||||||
| 199 | 0 | foreach ( keys %{$self->{alarms}} ) { | |||||||||||||||||||||||||||
| 200 | 0 | $self->_log( v => 4, "removed alarm $_ for client" ); | |||||||||||||||||||||||||||
| 201 | 0 | $poe_kernel->call( $self->parent_id => call_in_ses_context => alarm_remove => $_ ); | |||||||||||||||||||||||||||
| 202 | } | ||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||
| 204 | 0 | return; | |||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | 0 | ▶ | sub delay_set { | ||||||||||||||||||||||||||
|
Subroutine
delay_set: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 208 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||
| 210 | 0 | $self->active(); | |||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | 0 | $poe_kernel->call( $self->parent_id => call_in_ses_context => delay_set => $self->event( shift ) => @_ ); | |||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||
| 215 | 0 | ▶ | sub delay_adjust { | ||||||||||||||||||||||||||
|
Subroutine
delay_adjust: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 216 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 217 | |||||||||||||||||||||||||||||
| 218 | 0 | $self->active(); | |||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 0 | $poe_kernel->call( $self->parent_id => call_in_ses_context => delay_adjust => @_ ); | |||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||
| 223 | 0 | ▶ | sub yield { | ||||||||||||||||||||||||||
|
Subroutine
yield: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 224 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 225 | |||||||||||||||||||||||||||||
| 226 | 0 | $self->active(); | |||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||
| 228 | 0 | $poe_kernel->post( $self->parent_id => $self->event( shift ) => @_ ); | |||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | 0 | ▶ | sub call { | ||||||||||||||||||||||||||
|
Subroutine
call: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 232 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||
| 234 | 0 | $self->active(); | |||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||
| 236 | 0 | $poe_kernel->call( $self->parent_id => $self->event( shift ) => @_ ); | |||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||
| 239 | 0 | ▶ | sub post { | ||||||||||||||||||||||||||
|
Subroutine
post: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 240 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | 0 | $self->active(); | |||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | # XXX instead? | ||||||||||||||||||||||||||||
| 245 | #poe_kernel->call( $self->parent_id => call_in_ses_context => post => @_ ); | ||||||||||||||||||||||||||||
| 246 | 0 | $poe_kernel->post( @_ ); | |||||||||||||||||||||||||||
| 247 | } | ||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | 0 | ▶ | sub fuse { | ||||||||||||||||||||||||||
|
Subroutine
fuse: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 250 | 0 | my ( $self, $con ) = @_; | |||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||
| 252 | 0 | $self->active(); | |||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||
| 254 | 0 | $self->fused( $con ); | |||||||||||||||||||||||||||
| 255 | 0 | weaken( $self->{fused} ); | |||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||
| 257 | 0 | $con->fused( $self ); | |||||||||||||||||||||||||||
| 258 | 0 | weaken( $con->{fused} ); | |||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||
| 260 | # TODO some code to fuse the socket or other method | ||||||||||||||||||||||||||||
| 261 | 0 | return; | |||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||
| 264 | |||||||||||||||||||||||||||||
| 265 | 8 | ▶ | sub accept { | ||||||||||||||||||||||||||
|
Subroutine
accept: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 266 | 8 | my $self = shift; | |||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | 8 | $self->active(); | |||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||
| 270 | 8 | $self->connected( 1 ); | |||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | 8 | $poe_kernel->call( $self->parent_id => $self->event( 'accept' ) => @_ ); | |||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||
| 275 | 0 | ▶ | sub reject { | ||||||||||||||||||||||||||
|
Subroutine
reject: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 276 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||
| 278 | 0 | $self->connected( 0 ); | |||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | 0 | $poe_kernel->call( $self->parent_id => $self->event( 'reject' ) => @_ ); | |||||||||||||||||||||||||||
| 281 | } | ||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | 18 | ▶ | sub close { | ||||||||||||||||||||||||||
|
Subroutine
close: called CC=8 SCAR=21.3
Pod
documented
| |||||||||||||||||||||||||||||
| 284 | 18 | my ( $self, $force ) = @_; | |||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | # XXX | ||||||||||||||||||||||||||||
| 287 | 18 | $self->active(); | |||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||
| 289 | 18 | ▶ | if ( my $wheel = $self->wheel ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 290 | 12 | my $out = $wheel->get_driver_out_octets; | |||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||
| 292 | 12 | ▶ | if ( !$force && $out ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $force and $out
MC/DC100%2/2
not $force and $out
not $force
$out
Truth table100%3/3
not(A) and B
A= not $forceB= $out
| |||||||||||||||||||||||||||||
| 293 | 1 | $self->close_on_flush( 1 ); | |||||||||||||||||||||||||||
| 294 | 1 | return; | |||||||||||||||||||||||||||
| 295 | } else { | ||||||||||||||||||||||||||||
| 296 | 11 | $wheel->shutdown_input(); | |||||||||||||||||||||||||||
| 297 | 11 | $wheel->shutdown_output(); | |||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||
| 300 | 17 | ▶ | $self->wheel( undef ) if ( $force ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | 17 | $self->time_out( undef ); | |||||||||||||||||||||||||||
| 303 | |||||||||||||||||||||||||||||
| 304 | # kill the socket factory if any | ||||||||||||||||||||||||||||
| 305 | 17 | $self->sf( undef ); | |||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||
| 307 | # socket is only here during the accept phase | ||||||||||||||||||||||||||||
| 308 | 17 | ▶ | if ( my $socket = $self->socket ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 309 | 0 | eval { | |||||||||||||||||||||||||||
| 310 | 0 | close( $socket ); | |||||||||||||||||||||||||||
| 311 | }; | ||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||
| 313 | |||||||||||||||||||||||||||||
| 314 | # fused sockets closes its peer | ||||||||||||||||||||||||||||
| 315 | 17 | ▶ | if ( my $con = $self->fused() ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 316 | # avoid a loop by removing the fusion first | ||||||||||||||||||||||||||||
| 317 | 0 | $con->fused( undef ); | |||||||||||||||||||||||||||
| 318 | 0 | $self->fused( undef ); | |||||||||||||||||||||||||||
| 319 | # then close | ||||||||||||||||||||||||||||
| 320 | 0 | $con->close( $force ); | |||||||||||||||||||||||||||
| 321 | } | ||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | 17 | ▶ | if ( $self->connected ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 324 | 8 | $self->connected( 0 ); | |||||||||||||||||||||||||||
| 325 | 8 | $poe_kernel->call( $self->parent_id => cleanup => $self->ID ); | |||||||||||||||||||||||||||
| 326 | } | ||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | 17 | return; | |||||||||||||||||||||||||||
| 329 | } | ||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||
| 331 | 0 | ▶ | sub reconnect { | ||||||||||||||||||||||||||
|
Subroutine
reconnect: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 332 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | 0 | $self->active(); | |||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | 0 | $poe_kernel->call( $self->parent_id => $self->event( 'reconnect' ) => @_ ); | |||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||
| 339 | 0 | ▶ | sub get_driver_out_octets { | ||||||||||||||||||||||||||
|
Subroutine
get_driver_out_octets: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 340 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | 0 | ▶ | if ( my $wheel = $self->wheel ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 343 | 0 | $self->active(); | |||||||||||||||||||||||||||
| 344 | 0 | return $wheel->get_driver_out_octets(); | |||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||
| 347 | 0 | return 0; | |||||||||||||||||||||||||||
| 348 | } | ||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | 43 | ▶ | sub active { | ||||||||||||||||||||||||||
|
Subroutine
active: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 351 | 43 | shift->active_time( time() ); | |||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | 1 | ▶ | sub callback { | ||||||||||||||||||||||||||
|
Subroutine
callback: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 355 | 1 | my ($self, $event, @etc) = @_; | |||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||
| 357 | 1 | $self->active(); | |||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||
| 359 | 1 | return $sprocket->callback( $self->parent_id => $self->event( $event ) => @etc ); | |||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||
| 361 | |||||||||||||||||||||||||||||
| 362 | 2 | ▶ | sub postback { | ||||||||||||||||||||||||||
|
Subroutine
postback: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||
| 363 | 2 | my ($self, $event, @etc) = @_; | |||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||
| 365 | 2 | $self->active(); | |||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||
| 367 | 2 | return $sprocket->postback( $self->parent_id => $self->event( $event ) => @etc ); | |||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||
| 370 | 0 | ▶ | sub _log { | ||||||||||||||||||||||||||
|
Subroutine
_log: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 371 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||
| 373 | 0 | $poe_kernel->call( $self->parent_id => _log => ( l => 1, @_ ) ); | |||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||
| 376 | # XXX not used yet | ||||||||||||||||||||||||||||
| 377 | 0 | ▶ | sub aio_sendfile { | ||||||||||||||||||||||||||
|
Subroutine
aio_sendfile: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 378 | 0 | my ( $self, $in_fh, $in_offset, $length, $callback ) = @_; | |||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | 0 | $self->active(); | |||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | 0 | $self->wheel->pause_output(); | |||||||||||||||||||||||||||
| 383 | 0 | $self->wheel->pause_input(); | |||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||
| 385 | 0 | ▶ | return aio_sendfile( $self->socket, $in_fh, $in_offset, $length, sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 386 | 0 | $self->wheel->resume_output(); | |||||||||||||||||||||||||||
| 387 | 0 | $self->wheel->resume_input(); | |||||||||||||||||||||||||||
| 388 | 0 | return $callback->( @_ ); | |||||||||||||||||||||||||||
| 389 | 0 | } ); | |||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | # Danga::Socket type compat | ||||||||||||||||||||||||||||
| 393 | # ------------------------ | ||||||||||||||||||||||||||||
| 394 | # Do not document | ||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||
| 396 | 0 | ▶ | sub tcp_cork { | ||||||||||||||||||||||||||
|
Subroutine
tcp_cork: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 397 | # XXX is this the same as watch_read(0)? | ||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||
| 400 | 0 | ▶ | sub watch_write { | ||||||||||||||||||||||||||
|
Subroutine
watch_write: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 401 | 0 | my ( $self, $watch ) = @_; | |||||||||||||||||||||||||||
| 402 | |||||||||||||||||||||||||||||
| 403 | 0 | $self->active(); | |||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | 0 | ▶ | if ( my $wheel = $self->wheel ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 406 | 0 | ▶ | if ( $watch ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 407 | 0 | $wheel->resume_output(); | |||||||||||||||||||||||||||
| 408 | } else { | ||||||||||||||||||||||||||||
| 409 | 0 | $wheel->pause_output(); | |||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||
| 411 | } # XXX else | ||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||
| 413 | 0 | return; | |||||||||||||||||||||||||||
| 414 | } | ||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||
| 416 | 0 | ▶ | sub watch_read { | ||||||||||||||||||||||||||
|
Subroutine
watch_read: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 417 | 0 | my ( $self, $watch ) = @_; | |||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||
| 419 | 0 | $self->active(); | |||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | 0 | ▶ | if ( my $wheel = $self->wheel ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 422 | 0 | ▶ | if ( $watch ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 423 | 0 | $wheel->resume_input(); | |||||||||||||||||||||||||||
| 424 | } else { | ||||||||||||||||||||||||||||
| 425 | 0 | $wheel->pause_input(); | |||||||||||||||||||||||||||
| 426 | } | ||||||||||||||||||||||||||||
| 427 | } # XXX else | ||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | 0 | return; | |||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||
| 432 | # ------------------------ | ||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||
| 434 | 8 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=4 SCAR=17.9
| |||||||||||||||||||||||||||||
| 435 | 8 | my $self = shift; | |||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||
| 437 | # XXX this will change | ||||||||||||||||||||||||||||
| 438 | 8 | ▶ | if ( keys %{$self->{destroy_events}} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 439 | 0 | foreach my $type ( keys %{$self->{destroy_events}} ) { | |||||||||||||||||||||||||||
| 440 | 0 | $poe_kernel->post( @{$self->{destroy_events}->{$type}} ); | |||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||
| 442 | } | ||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | # remove alarms for this connection | ||||||||||||||||||||||||||||
| 445 | 8 | foreach ( keys %{$self->{alarms}} ) { | |||||||||||||||||||||||||||
| 446 | 0 | $self->_log( v => 4, "removed alarm $_ for client" ); | |||||||||||||||||||||||||||
| 447 | 0 | $poe_kernel->alarm_remove( $_ ); | |||||||||||||||||||||||||||
| 448 | } | ||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||
| 450 | 8 | return; | |||||||||||||||||||||||||||
| 451 | } | ||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||
| 453 | 5 | 1; | |||||||||||||||||||||||||||
| 454 | |||||||||||||||||||||||||||||
| 455 | __END__ | ||||||||||||||||||||||||||||