Kaynağa Gözat

Revert 9eea959 only the parts which affect src/BtPieceMessage.cc

This is because we are not sure that peer has a piece just sending off
its block. It should be notified by the peer.
Tatsuhiro Tsujikawa 12 yıl önce
ebeveyn
işleme
e3506b04fb
1 değiştirilmiş dosya ile 3 ekleme ve 15 silme
  1. 3 15
      src/BtPieceMessage.cc

+ 3 - 15
src/BtPieceMessage.cc

@@ -179,10 +179,8 @@ size_t BtPieceMessage::getMessageHeaderLength()
 
 namespace {
 struct PieceSendUpdate : public ProgressUpdate {
-  PieceSendUpdate(const SharedHandle<Peer>& peer, size_t headerLength,
-                  size_t index, const SharedHandle<PieceStorage>& pieceStorage)
-    : peer(peer), headerLength(headerLength), index(index),
-      pieceStorage(pieceStorage) {}
+  PieceSendUpdate(const SharedHandle<Peer>& peer, size_t headerLength)
+    : peer(peer), headerLength(headerLength) {}
   virtual void update(size_t length, bool complete)
   {
     if(headerLength > 0) {
@@ -191,17 +189,9 @@ struct PieceSendUpdate : public ProgressUpdate {
       length -= m;
     }
     peer->updateUploadLength(length);
-    if(complete && !peer->hasPiece(index)) {
-      // Update peer's bitfield because peer may not send HAVE message
-      // to us.
-      peer->updateBitfield(index, 1);
-      pieceStorage->addPieceStats(index);
-    }
   }
   SharedHandle<Peer> peer;
   size_t headerLength;
-  size_t index;
-  SharedHandle<PieceStorage> pieceStorage;
 };
 } // namespace
 
@@ -234,9 +224,7 @@ void BtPieceMessage::pushPieceData(int64_t offset, int32_t length) const
     buf.reset(0);
     getPeerConnection()->pushBytes(dbuf, length+MESSAGE_HEADER_LENGTH,
                                    new PieceSendUpdate(getPeer(),
-                                                       MESSAGE_HEADER_LENGTH,
-                                                       index_,
-                                                       getPieceStorage()));
+                                                       MESSAGE_HEADER_LENGTH));
     // To avoid upload rate overflow, we update the length here at
     // once.
     downloadContext_->updateUploadLength(length);