mirror of https://github.com/aria2/aria2
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.pull/103/head
parent
9eea959455
commit
e3506b04fb
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue