53 |
my $wVecRef=shift; |
my $wVecRef=shift; |
54 |
my $eVecRef=shift; |
my $eVecRef=shift; |
55 |
|
|
56 |
map {$_->addHandleBits($rVecRef,$wVecRef,$eVecRef)} @Connections; |
my @cons=@Connections; |
57 |
|
map {$_->addHandleBits($rVecRef,$wVecRef,$eVecRef) if(defined($_)) } @cons; |
58 |
} |
} |
59 |
|
|
60 |
sub checkAllHandleBits { |
sub checkAllHandleBits { |
64 |
my $wVec=shift; |
my $wVec=shift; |
65 |
my $eVec=shift; |
my $eVec=shift; |
66 |
|
|
67 |
map {$_->checkHandleBits($rVec,$wVec,$eVec)} @Connections; |
my @cons=@Connections; |
68 |
|
map {$_->checkHandleBits($rVec,$wVec,$eVec) if(defined($_)) } @cons; |
69 |
} |
} |
70 |
|
|
71 |
sub connectionCount { |
sub connectionCount { |
110 |
|
|
111 |
$self->{'writeBuffer'}=''; |
$self->{'writeBuffer'}=''; |
112 |
$self->{'readBuffer'}=''; |
$self->{'readBuffer'}=''; |
113 |
|
$self->{'bytesWritten'}=0; |
114 |
|
$self->{'ip'}=$socket->{'connection'}->{'remoteIP'}; |
115 |
|
|
116 |
push(@Connections,$self); |
push(@Connections,$self); |
117 |
|
|
197 |
{ |
{ |
198 |
# Connection closed |
# Connection closed |
199 |
$self->{'remoteClosed'}=1; |
$self->{'remoteClosed'}=1; |
200 |
$self->close(); |
$self->close(1, 'remoteClosed'); |
201 |
|
|
202 |
return; |
return; |
203 |
} |
} |
207 |
{ |
{ |
208 |
&::syslog('notice',"Connection closed: $!"); |
&::syslog('notice',"Connection closed: $!"); |
209 |
$self->{'remoteClosed'}=1; |
$self->{'remoteClosed'}=1; |
210 |
$self->close(); |
$self->close(1, 'remoteClosed'); |
211 |
|
|
212 |
return; |
return; |
213 |
} |
} |
226 |
if(defined($bytesWritten) && $bytesWritten>0) |
if(defined($bytesWritten) && $bytesWritten>0) |
227 |
{ |
{ |
228 |
$::Statistics->{'total_outbound_bytes'}+=$bytesWritten; |
$::Statistics->{'total_outbound_bytes'}+=$bytesWritten; |
229 |
|
$self->{'bytesWritten'}+=$bytesWritten; |
230 |
$self->{'writeBuffer'}=substr($self->{'writeBuffer'},$bytesWritten); |
$self->{'writeBuffer'}=substr($self->{'writeBuffer'},$bytesWritten); |
231 |
if(length($self->{'writeBuffer'})==0) |
if(length($self->{'writeBuffer'})==0) |
232 |
{ |
{ |
233 |
delete($self->{'writeBufferTimestamp'}); |
delete($self->{'writeBufferTimestamp'}); |
234 |
$self->close() if(exists($self->{'autoClose'})); |
$self->close(1) if(exists($self->{'autoClose'})); |
235 |
} |
} |
236 |
else |
else |
237 |
{ |
{ |
244 |
{ |
{ |
245 |
&::syslog('notice',"Connection closed: $!"); |
&::syslog('notice',"Connection closed: $!"); |
246 |
$self->{'remoteClosed'}=1; |
$self->{'remoteClosed'}=1; |
247 |
$self->close(); |
$self->close(1, 'remoteClosed'); |
248 |
|
|
249 |
return; |
return; |
250 |
} |
} |
285 |
# Remove connection from list of connections |
# Remove connection from list of connections |
286 |
# |
# |
287 |
my $idx=undef; |
my $idx=undef; |
288 |
for(my $i=0;$i<scalar(@Connections);$i++) |
my $numcon = scalar(@Connections); |
289 |
|
for(my $i=0;$i<$numcon;$i++) |
290 |
{ |
{ |
291 |
if($Connections[$i]==$self) |
if($Connections[$i]==$self) |
292 |
{ |
{ |
301 |
} |
} |
302 |
|
|
303 |
&::syslog('debug',"Closed %s for %s",ref($self),$self->{'socket'}->{'connection'}->{'remoteIP'}); |
&::syslog('debug',"Closed %s for %s",ref($self),$self->{'socket'}->{'connection'}->{'remoteIP'}); |
304 |
|
|
305 |
|
$self->didClose(); |
306 |
|
} |
307 |
|
|
308 |
|
sub didClose { |
309 |
} |
} |
310 |
|
|
311 |
1; |
1; |