2009-07-04 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Add formerly fastest PeerStat's sessionDownloadLength to new
	fastest PeerStat and use _fastestPeerStats to calcuate downloaded
	bytes in a session.	
	* src/PeerStat.cc
	* src/SegmentMan.cc
pull/1/head
Tatsuhiro Tsujikawa 2009-07-04 13:10:40 +00:00
parent 2a2c8c5da0
commit 3a655a5d1a
3 changed files with 16 additions and 3 deletions

View File

@ -1,3 +1,11 @@
2009-07-04 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Add formerly fastest PeerStat's sessionDownloadLength to new
fastest PeerStat and use _fastestPeerStats to calcuate downloaded
bytes in a session.
* src/PeerStat.cc
* src/SegmentMan.cc
2009-07-04 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
If pipelining is enabled, we can always pool socket.

View File

@ -188,6 +188,11 @@ public:
{
return _sessionUploadLength;
}
void addSessionDownloadLength(uint64_t length)
{
_sessionDownloadLength += length;
}
};
typedef SharedHandle<PeerStat> PeerStatHandle;

View File

@ -314,6 +314,7 @@ void SegmentMan::updateFastestPeerStat(const SharedHandle<PeerStat>& peerStat)
if(i == _fastestPeerStats.end()) {
_fastestPeerStats.push_back(peerStat);
} else if((*i)->getAvgDownloadSpeed() < peerStat->getAvgDownloadSpeed()) {
peerStat->addSessionDownloadLength((*i)->getSessionDownloadLength());
*i = peerStat;
}
}
@ -362,9 +363,8 @@ public:
uint64_t SegmentMan::calculateSessionDownloadLength() const
{
return std::accumulate(peerStats.begin(), peerStats.end(), 0LL,
PeerStatDownloadLengthOperator());
return std::accumulate(_fastestPeerStats.begin(), _fastestPeerStats.end(),
0LL, PeerStatDownloadLengthOperator());
}
size_t SegmentMan::countFreePieceFrom(size_t index) const