浏览代码

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
Tatsuhiro Tsujikawa 17 年之前
父节点
当前提交
7bbd9cec3b
共有 6 个文件被更改,包括 29 次插入2 次删除
  1. 10 0
      ChangeLog
  2. 6 0
      src/Peer.cc
  3. 2 0
      src/Peer.h
  4. 4 2
      src/PeerInteractionCommand.cc
  5. 5 0
      src/PeerSessionResource.cc
  6. 2 0
      src/PeerSessionResource.h

+ 10 - 0
ChangeLog

@@ -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

+ 6 - 0
src/Peer.cc

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

+ 2 - 0
src/Peer.h

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

+ 4 - 2
src/PeerInteractionCommand.cc

@@ -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());
 					

+ 5 - 0
src/PeerSessionResource.cc

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

+ 2 - 0
src/PeerSessionResource.h

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