--- googlecode.com/svn/trunk/Meteor/Connection.pm 2006/11/20 17:59:30 3 +++ googlecode.com/svn/trunk/Meteor/Connection.pm 2008/02/27 13:55:35 50 @@ -53,7 +53,8 @@ my $wVecRef=shift; my $eVecRef=shift; - map {$_->addHandleBits($rVecRef,$wVecRef,$eVecRef)} @Connections; + my @cons=@Connections; + map {$_->addHandleBits($rVecRef,$wVecRef,$eVecRef) if(defined($_)) } @cons; } sub checkAllHandleBits { @@ -63,7 +64,8 @@ my $wVec=shift; my $eVec=shift; - map {$_->checkHandleBits($rVec,$wVec,$eVec)} @Connections; + my @cons=@Connections; + map {$_->checkHandleBits($rVec,$wVec,$eVec) if(defined($_)) } @cons; } sub connectionCount { @@ -96,6 +98,8 @@ # my $self=shift->new(); + $::Statistics->{'total_requests'}++; + my $server=shift; my $socket=$server->conSocket(); @@ -107,6 +111,8 @@ $self->{'writeBuffer'}=''; $self->{'readBuffer'}=''; + $self->{'bytesWritten'}=0; + push(@Connections,$self); &::syslog('debug',"New %s for %s",ref($self),$socket->{'connection'}->{'remoteIP'}); @@ -180,6 +186,7 @@ my $bytesRead=sysread($socket->{'handle'},$buffer,$MAX_READ_SIZE); if(defined($bytesRead) && $bytesRead>0) { + $::Statistics->{'total_inbound_bytes'}+=$bytesRead; $self->{'readBuffer'}.=$buffer; while($self->{'readBuffer'}=~s/^([^\r\n]*)\r?\n//) { @@ -190,7 +197,7 @@ { # Connection closed $self->{'remoteClosed'}=1; - $self->close(); + $self->close(1, 'remoteClosed'); return; } @@ -200,7 +207,7 @@ { &::syslog('notice',"Connection closed: $!"); $self->{'remoteClosed'}=1; - $self->close(); + $self->close(1, 'remoteClosed'); return; } @@ -218,6 +225,8 @@ if(defined($bytesWritten) && $bytesWritten>0) { + $::Statistics->{'total_outbound_bytes'}+=$bytesWritten; + $self->{'bytesWritten'}+=$bytesWritten; $self->{'writeBuffer'}=substr($self->{'writeBuffer'},$bytesWritten); if(length($self->{'writeBuffer'})==0) { @@ -235,7 +244,7 @@ { &::syslog('notice',"Connection closed: $!"); $self->{'remoteClosed'}=1; - $self->close(); + $self->close(1, 'remoteClosed'); return; } @@ -276,7 +285,8 @@ # Remove connection from list of connections # my $idx=undef; - for(my $i=0;$i{'socket'}->{'connection'}->{'remoteIP'}); + + $self->didClose(); +} + +sub didClose { } 1;