2008-05-16 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Call subtractPieceStats from ~PeerInteractionCommand only when 
the
	peer has at least one completed piece.
	* src/Peer.cc
	* src/Peer.h
	* src/PeerInteractionCommand.cc
	* src/PeerSessionResource.cc
	* src/PeerSessionResource.h
pull/1/head
Tatsuhiro Tsujikawa 2008-05-17 05:12:14 +00:00
parent d4d608eeb0
commit 7bbd9cec3b
6 changed files with 29 additions and 2 deletions

View File

@ -1,3 +1,13 @@
2008-05-16 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Call subtractPieceStats from ~PeerInteractionCommand only when the
peer has at least one completed piece.
* src/Peer.cc
* src/Peer.h
* src/PeerInteractionCommand.cc
* src/PeerSessionResource.cc
* src/PeerSessionResource.h
2008-05-16 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Removed unnecessary sorting

View File

@ -454,4 +454,10 @@ const Time& Peer::getLastAmUnchoking() const
return _res->getLastAmUnchoking();
}
uint64_t Peer::getCompletedLength() const
{
assert(_res);
return _res->getCompletedLength();
}
} // namespace aria2

View File

@ -235,6 +235,8 @@ public:
const Time& getLastDownloadUpdate() const;
const Time& getLastAmUnchoking() const;
uint64_t getCompletedLength() const;
};
typedef SharedHandle<Peer> PeerHandle;

View File

@ -170,8 +170,10 @@ PeerInteractionCommand::PeerInteractionCommand(int32_t cuid,
}
PeerInteractionCommand::~PeerInteractionCommand() {
pieceStorage->subtractPieceStats(peer->getBitfield(),
peer->getBitfieldLength());
if(peer->getCompletedLength() > 0) {
pieceStorage->subtractPieceStats(peer->getBitfield(),
peer->getBitfieldLength());
}
peer->releaseSessionResource();
PEER_OBJECT_CLUSTER(btContext)->unregisterHandle(peer->getID());

View File

@ -337,4 +337,9 @@ const Time& PeerSessionResource::getLastAmUnchoking() const
return _lastAmUnchoking;
}
uint64_t PeerSessionResource::getCompletedLength() const
{
return _bitfieldMan->getCompletedLength();
}
} // namespace aria2

View File

@ -185,6 +185,8 @@ public:
const Time& getLastDownloadUpdate() const;
const Time& getLastAmUnchoking() const;
uint64_t getCompletedLength() const;
};
} // namespace aria2