To fix the bug that causes the number of bytes uploaded is not

saved
	to .aria2 file:

	* src/DefaultPeerStorage.h
	(removedPeerSessionDownloadLength): New variable.
	(removedPeerSessionUploadLength): New variable.
	* src/DefaultPeerStorage.cc
	(DefaultPieceStorage): Added 
removedPeerSessionDownloadLength(0),
	removedPeerSessionUploadLength(0).
	(calculateStat): Calculate the number of bytes 
downloaded(uploaded)
	through all peers, and then add 
removedPeerSessionDownloadLength(
	removedPeerSessionUploadLength) to it.
	(deleteUnusedPeer): Add the number of bytes downloaded(uploaded) 
from
	 (to) the peer to removedPeerSessionDownloadLength
	 (removedPeerSessionUploadLength).
pull/1/head
Tatsuhiro Tsujikawa 2006-11-09 14:48:59 +00:00
parent 9b48e350c6
commit b14e4a5ac1
4 changed files with 35 additions and 1 deletions

View File

@ -34,6 +34,27 @@
(setGlobalSignalHandler): New function.
* src/UrlRequestInfo.cc:
setSignalHander -> Util::setGlobalSignalHandler
Reset peer status in order to exit gracefully:
* src/PeerAbstractCommand.cc
(execute): Call peer->resetStatus() when btRuntime->isHalt() is true.
To fix the bug that causes the number of bytes uploaded is not saved
to .aria2 file:
* src/DefaultPeerStorage.h
(removedPeerSessionDownloadLength): New variable.
(removedPeerSessionUploadLength): New variable.
* src/DefaultPeerStorage.cc
(DefaultPieceStorage): Added removedPeerSessionDownloadLength(0),
removedPeerSessionUploadLength(0).
(calculateStat): Calculate the number of bytes downloaded(uploaded)
through all peers, and then add removedPeerSessionDownloadLength(
removedPeerSessionUploadLength) to it.
(deleteUnusedPeer): Add the number of bytes downloaded(uploaded) from
(to) the peer to removedPeerSessionDownloadLength
(removedPeerSessionUploadLength).
2006-11-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

View File

@ -44,7 +44,9 @@ DefaultPeerStorage::DefaultPeerStorage(BtContextHandle btContext,
option(option),
maxPeerListSize(MAX_PEER_LIST_SIZE),
peerEntryIdCounter(0),
btRuntime(BT_RUNTIME(btContext))
btRuntime(BT_RUNTIME(btContext)),
removedPeerSessionDownloadLength(0),
removedPeerSessionUploadLength(0)
{
logger = LogFactory::getInstance();
}
@ -154,9 +156,14 @@ TransferStat DefaultPeerStorage::calculateStat() {
PeerHandle& peer = *itr;
stat.downloadSpeed += peer->calculateDownloadSpeed();
stat.uploadSpeed += peer->calculateUploadSpeed();
}
for(Peers::iterator itr = peers.begin(); itr != peers.end(); itr++) {
PeerHandle& peer = *itr;
stat.sessionDownloadLength += peer->getSessionDownloadLength();
stat.sessionUploadLength += peer->getSessionUploadLength();
}
stat.sessionDownloadLength += removedPeerSessionDownloadLength;
stat.sessionUploadLength += removedPeerSessionUploadLength;
return stat;
}
@ -165,6 +172,9 @@ void DefaultPeerStorage::deleteUnusedPeer(int delSize) {
itr != peers.end() && delSize > 0;) {
const PeerHandle& p = *itr;
if(p->cuid == 0) {
// Update removedPeerSession******Length
removedPeerSessionDownloadLength += p->getSessionDownloadLength();
removedPeerSessionUploadLength += p->getSessionUploadLength();
itr = peers.erase(itr);
delSize--;
} else {

View File

@ -53,6 +53,8 @@ private:
int peerEntryIdCounter;
Logger* logger;
BtRuntimeHandle btRuntime;
long long int removedPeerSessionDownloadLength;
long long int removedPeerSessionUploadLength;
public:
DefaultPeerStorage(BtContextHandle btContext, const Option* option);
virtual ~DefaultPeerStorage();

View File

@ -60,6 +60,7 @@ PeerAbstractCommand::~PeerAbstractCommand() {
bool PeerAbstractCommand::execute() {
if(btRuntime->isHalt()) {
peer->resetStatus();
return true;
}
try {