2006-12-24 06:25:21 +00:00
|
|
|
/* <!-- copyright */
|
|
|
|
/*
|
|
|
|
* aria2 - The high speed download utility
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Tatsuhiro Tsujikawa
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2010-01-05 16:01:46 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
2006-12-24 06:25:21 +00:00
|
|
|
*
|
|
|
|
* In addition, as a special exception, the copyright holders give
|
|
|
|
* permission to link the code of portions of this program with the
|
|
|
|
* OpenSSL library under certain conditions as described in each
|
|
|
|
* individual source file, and distribute linked combinations
|
|
|
|
* including the two.
|
|
|
|
* You must obey the GNU General Public License in all respects
|
|
|
|
* for all of the code used other than OpenSSL. If you modify
|
|
|
|
* file(s) with this exception, you may extend this exception to your
|
|
|
|
* version of the file(s), but you are not obligated to do so. If you
|
|
|
|
* do not wish to do so, delete this exception statement from your
|
|
|
|
* version. If you delete this exception statement from all source
|
|
|
|
* files in the program, then also delete it here.
|
|
|
|
*/
|
|
|
|
/* copyright --> */
|
|
|
|
#include "BtPieceMessage.h"
|
2009-03-12 15:54:43 +00:00
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cassert>
|
|
|
|
|
2009-09-29 14:52:42 +00:00
|
|
|
#include "bittorrent_helper.h"
|
2009-10-22 15:35:33 +00:00
|
|
|
#include "util.h"
|
2006-12-24 06:25:21 +00:00
|
|
|
#include "message.h"
|
|
|
|
#include "DlAbortEx.h"
|
2011-02-05 14:38:51 +00:00
|
|
|
#include "message_digest_helper.h"
|
2007-10-11 16:58:24 +00:00
|
|
|
#include "DiskAdaptor.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
#include "Logger.h"
|
2010-11-20 08:21:36 +00:00
|
|
|
#include "LogFactory.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
#include "Peer.h"
|
|
|
|
#include "Piece.h"
|
|
|
|
#include "PieceStorage.h"
|
|
|
|
#include "BtMessageDispatcher.h"
|
|
|
|
#include "BtMessageFactory.h"
|
|
|
|
#include "BtRequestFactory.h"
|
|
|
|
#include "PeerConnection.h"
|
2010-11-20 08:21:36 +00:00
|
|
|
#include "fmt.h"
|
2009-06-28 10:37:15 +00:00
|
|
|
#include "DownloadContext.h"
|
2011-12-03 09:12:31 +00:00
|
|
|
#include "PeerStorage.h"
|
2012-11-15 13:05:59 +00:00
|
|
|
#include "array_fun.h"
|
2012-11-27 13:04:59 +00:00
|
|
|
#include "WrDiskCache.h"
|
|
|
|
#include "WrDiskCacheEntry.h"
|
|
|
|
#include "DownloadFailureException.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
|
|
|
|
namespace aria2 {
|
2006-12-24 06:25:21 +00:00
|
|
|
|
2012-09-25 14:28:24 +00:00
|
|
|
const char BtPieceMessage::NAME[] = "piece";
|
2009-03-12 15:54:43 +00:00
|
|
|
|
2010-06-11 11:48:22 +00:00
|
|
|
BtPieceMessage::BtPieceMessage
|
2011-12-07 15:51:20 +00:00
|
|
|
(size_t index, int32_t begin, int32_t blockLength)
|
2010-11-20 08:21:36 +00:00
|
|
|
: AbstractBtMessage(ID, NAME),
|
|
|
|
index_(index),
|
|
|
|
begin_(begin),
|
|
|
|
blockLength_(blockLength),
|
2011-12-07 15:51:20 +00:00
|
|
|
data_(0)
|
2010-06-11 11:48:22 +00:00
|
|
|
{
|
|
|
|
setUploading(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
BtPieceMessage::~BtPieceMessage()
|
2012-06-25 12:29:48 +00:00
|
|
|
{}
|
2010-06-11 11:48:22 +00:00
|
|
|
|
2012-06-25 12:29:48 +00:00
|
|
|
void BtPieceMessage::setMsgPayload(const unsigned char* data)
|
2010-03-04 16:24:03 +00:00
|
|
|
{
|
2011-12-07 15:51:20 +00:00
|
|
|
data_ = data;
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
|
2012-09-27 14:40:25 +00:00
|
|
|
BtPieceMessage* BtPieceMessage::create
|
2010-06-11 11:48:22 +00:00
|
|
|
(const unsigned char* data, size_t dataLength)
|
|
|
|
{
|
2009-09-29 14:52:42 +00:00
|
|
|
bittorrent::assertPayloadLengthGreater(9, dataLength, NAME);
|
|
|
|
bittorrent::assertID(ID, data, NAME);
|
2012-09-27 14:40:25 +00:00
|
|
|
BtPieceMessage* message(new BtPieceMessage());
|
2009-09-29 14:52:42 +00:00
|
|
|
message->setIndex(bittorrent::getIntParam(data, 1));
|
|
|
|
message->setBegin(bittorrent::getIntParam(data, 5));
|
2010-03-04 16:24:03 +00:00
|
|
|
message->setBlockLength(dataLength-9);
|
2006-12-24 06:25:21 +00:00
|
|
|
return message;
|
|
|
|
}
|
|
|
|
|
2010-06-11 11:48:22 +00:00
|
|
|
void BtPieceMessage::doReceivedAction()
|
|
|
|
{
|
|
|
|
if(isMetadataGetMode()) {
|
2009-11-22 13:33:35 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-06-11 11:48:22 +00:00
|
|
|
RequestSlot slot = getBtMessageDispatcher()->getOutstandingRequest
|
2010-06-21 13:51:56 +00:00
|
|
|
(index_, begin_, blockLength_);
|
|
|
|
getPeer()->updateDownloadLength(blockLength_);
|
2012-10-25 14:33:45 +00:00
|
|
|
downloadContext_->updateDownloadLength(blockLength_);
|
2006-12-24 06:25:21 +00:00
|
|
|
if(!RequestSlot::isNull(slot)) {
|
2010-06-11 11:48:22 +00:00
|
|
|
getPeer()->snubbing(false);
|
2010-06-21 13:51:56 +00:00
|
|
|
SharedHandle<Piece> piece = getPieceStorage()->getPiece(index_);
|
2012-07-23 12:36:24 +00:00
|
|
|
int64_t offset =
|
|
|
|
static_cast<int64_t>(index_)*downloadContext_->getPieceLength()+begin_;
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_DEBUG(fmt(MSG_PIECE_RECEIVED,
|
2010-11-20 12:12:06 +00:00
|
|
|
getCuid(),
|
2010-11-20 08:21:36 +00:00
|
|
|
static_cast<unsigned long>(index_),
|
|
|
|
begin_,
|
|
|
|
blockLength_,
|
2012-06-25 13:43:33 +00:00
|
|
|
static_cast<int64_t>(offset),
|
2010-11-20 08:21:36 +00:00
|
|
|
static_cast<unsigned long>(slot.getBlockIndex())));
|
2011-07-15 15:23:45 +00:00
|
|
|
if(piece->hasBlock(slot.getBlockIndex())) {
|
|
|
|
A2_LOG_DEBUG("Already have this block.");
|
|
|
|
return;
|
|
|
|
}
|
2012-11-27 13:04:59 +00:00
|
|
|
if(piece->getWrDiskCacheEntry()) {
|
|
|
|
// Write Disk Cache enabled. Unfortunately, it incurs extra data
|
|
|
|
// copy.
|
|
|
|
unsigned char* dataCopy = new unsigned char[blockLength_];
|
|
|
|
memcpy(dataCopy, data_+9, blockLength_);
|
|
|
|
piece->updateWrCache(getPieceStorage()->getWrDiskCache(),
|
2012-12-05 17:23:32 +00:00
|
|
|
dataCopy, 0, blockLength_, blockLength_, offset);
|
2012-11-27 13:04:59 +00:00
|
|
|
} else {
|
|
|
|
getPieceStorage()->getDiskAdaptor()->writeData(data_+9, blockLength_,
|
|
|
|
offset);
|
|
|
|
}
|
2006-12-24 06:25:21 +00:00
|
|
|
piece->completeBlock(slot.getBlockIndex());
|
2010-11-20 12:12:06 +00:00
|
|
|
A2_LOG_DEBUG(fmt(MSG_PIECE_BITFIELD, getCuid(),
|
2010-11-20 08:21:36 +00:00
|
|
|
util::toHex(piece->getBitfield(),
|
|
|
|
piece->getBitfieldLength()).c_str()));
|
2011-12-07 15:51:20 +00:00
|
|
|
piece->updateHash(begin_, data_+9, blockLength_);
|
2010-06-11 11:48:22 +00:00
|
|
|
getBtMessageDispatcher()->removeOutstandingRequest(slot);
|
2006-12-24 06:25:21 +00:00
|
|
|
if(piece->pieceComplete()) {
|
|
|
|
if(checkPieceHash(piece)) {
|
2010-01-05 16:01:46 +00:00
|
|
|
onNewPiece(piece);
|
2006-12-24 06:25:21 +00:00
|
|
|
} else {
|
2010-01-05 16:01:46 +00:00
|
|
|
onWrongPiece(piece);
|
2011-12-03 09:12:31 +00:00
|
|
|
peerStorage_->addBadPeer(getPeer()->getIPAddress());
|
2010-08-04 14:15:29 +00:00
|
|
|
throw DL_ABORT_EX("Bad piece hash.");
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
}
|
2008-05-17 07:06:17 +00:00
|
|
|
} else {
|
2012-06-25 13:43:33 +00:00
|
|
|
A2_LOG_DEBUG(fmt("CUID#%" PRId64 " - RequestSlot not found, index=%lu, begin=%d",
|
2010-11-20 12:12:06 +00:00
|
|
|
getCuid(),
|
2010-11-20 08:21:36 +00:00
|
|
|
static_cast<unsigned long>(index_),
|
|
|
|
begin_));
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-09 12:24:01 +00:00
|
|
|
size_t BtPieceMessage::MESSAGE_HEADER_LENGTH = 13;
|
2006-12-24 06:25:21 +00:00
|
|
|
|
2013-01-14 09:08:52 +00:00
|
|
|
void BtPieceMessage::createMessageHeader(unsigned char* msgHeader) const
|
2010-03-04 16:24:03 +00:00
|
|
|
{
|
|
|
|
/**
|
|
|
|
* len --- 9+blockLength, 4bytes
|
|
|
|
* id --- 7, 1byte
|
|
|
|
* index --- index, 4bytes
|
|
|
|
* begin --- begin, 4bytes
|
|
|
|
* total: 13bytes
|
|
|
|
*/
|
|
|
|
bittorrent::createPeerMessageString(msgHeader, MESSAGE_HEADER_LENGTH,
|
2010-06-21 13:51:56 +00:00
|
|
|
9+blockLength_, ID);
|
|
|
|
bittorrent::setIntParam(&msgHeader[5], index_);
|
|
|
|
bittorrent::setIntParam(&msgHeader[9], begin_);
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
|
2010-06-11 11:48:22 +00:00
|
|
|
size_t BtPieceMessage::getMessageHeaderLength()
|
|
|
|
{
|
2006-12-24 06:25:21 +00:00
|
|
|
return MESSAGE_HEADER_LENGTH;
|
|
|
|
}
|
|
|
|
|
2013-01-11 05:20:34 +00:00
|
|
|
namespace {
|
|
|
|
struct PieceSendUpdate : public ProgressUpdate {
|
2013-06-13 12:34:08 +00:00
|
|
|
PieceSendUpdate(const SharedHandle<Peer>& peer, size_t headerLength)
|
|
|
|
: peer(peer), headerLength(headerLength) {}
|
2013-01-11 05:20:34 +00:00
|
|
|
virtual void update(size_t length, bool complete)
|
|
|
|
{
|
2013-01-14 09:08:52 +00:00
|
|
|
if(headerLength > 0) {
|
|
|
|
size_t m = std::min(headerLength, length);
|
|
|
|
headerLength -= m;
|
|
|
|
length -= m;
|
|
|
|
}
|
2013-01-11 05:20:34 +00:00
|
|
|
peer->updateUploadLength(length);
|
|
|
|
}
|
|
|
|
SharedHandle<Peer> peer;
|
2013-01-14 09:08:52 +00:00
|
|
|
size_t headerLength;
|
2013-01-11 05:20:34 +00:00
|
|
|
};
|
|
|
|
} // namespace
|
|
|
|
|
2010-06-11 11:48:22 +00:00
|
|
|
void BtPieceMessage::send()
|
|
|
|
{
|
|
|
|
if(isInvalidate()) {
|
2006-12-24 06:25:21 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-01-11 05:20:34 +00:00
|
|
|
A2_LOG_INFO(fmt(MSG_SEND_PEER_MESSAGE,
|
|
|
|
getCuid(),
|
|
|
|
getPeer()->getIPAddress().c_str(),
|
|
|
|
getPeer()->getPort(),
|
|
|
|
toString().c_str()));
|
|
|
|
int64_t pieceDataOffset =
|
|
|
|
static_cast<int64_t>(index_)*downloadContext_->getPieceLength()+begin_;
|
|
|
|
pushPieceData(pieceDataOffset, blockLength_);
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
|
2012-07-23 12:36:24 +00:00
|
|
|
void BtPieceMessage::pushPieceData(int64_t offset, int32_t length) const
|
2010-06-11 11:48:22 +00:00
|
|
|
{
|
2008-09-28 10:55:17 +00:00
|
|
|
assert(length <= 16*1024);
|
2013-01-14 09:08:52 +00:00
|
|
|
array_ptr<unsigned char> buf
|
|
|
|
(new unsigned char[length+MESSAGE_HEADER_LENGTH]);
|
|
|
|
createMessageHeader(buf);
|
2010-03-04 16:24:03 +00:00
|
|
|
ssize_t r;
|
2013-01-14 09:08:52 +00:00
|
|
|
r = getPieceStorage()->getDiskAdaptor()->readData(buf+MESSAGE_HEADER_LENGTH,
|
|
|
|
length, offset);
|
2011-12-07 15:51:20 +00:00
|
|
|
if(r == length) {
|
2012-11-15 13:05:59 +00:00
|
|
|
unsigned char* dbuf = buf;
|
|
|
|
buf.reset(0);
|
2013-01-14 09:08:52 +00:00
|
|
|
getPeerConnection()->pushBytes(dbuf, length+MESSAGE_HEADER_LENGTH,
|
|
|
|
new PieceSendUpdate(getPeer(),
|
2013-06-13 12:34:08 +00:00
|
|
|
MESSAGE_HEADER_LENGTH));
|
2013-01-11 05:20:34 +00:00
|
|
|
// To avoid upload rate overflow, we update the length here at
|
|
|
|
// once.
|
|
|
|
downloadContext_->updateUploadLength(length);
|
2008-09-28 10:55:17 +00:00
|
|
|
} else {
|
2009-05-18 15:07:15 +00:00
|
|
|
throw DL_ABORT_EX(EX_DATA_READ);
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-06-11 11:48:22 +00:00
|
|
|
std::string BtPieceMessage::toString() const
|
|
|
|
{
|
2011-12-07 15:51:20 +00:00
|
|
|
return fmt("%s index=%lu, begin=%d, length=%d",
|
2012-09-25 14:28:24 +00:00
|
|
|
NAME,
|
2011-11-12 10:33:38 +00:00
|
|
|
static_cast<unsigned long>(index_),
|
2011-12-07 15:51:20 +00:00
|
|
|
begin_, blockLength_);
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
|
2010-06-11 11:48:22 +00:00
|
|
|
bool BtPieceMessage::checkPieceHash(const SharedHandle<Piece>& piece)
|
|
|
|
{
|
2010-08-04 14:15:29 +00:00
|
|
|
if(!getPieceStorage()->isEndGame() && piece->isHashCalculated()) {
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_DEBUG(fmt("Hash is available!! index=%lu",
|
|
|
|
static_cast<unsigned long>(piece->getIndex())));
|
2009-06-28 10:37:15 +00:00
|
|
|
return
|
2011-10-13 12:40:07 +00:00
|
|
|
piece->getDigest() == downloadContext_->getPieceHash(piece->getIndex());
|
2008-06-04 16:28:16 +00:00
|
|
|
} else {
|
2012-11-27 13:04:59 +00:00
|
|
|
A2_LOG_DEBUG(fmt("Calculating hash index=%lu",
|
|
|
|
static_cast<unsigned long>(piece->getIndex())));
|
|
|
|
try {
|
|
|
|
return piece->getDigestWithWrCache(downloadContext_->getPieceLength(),
|
|
|
|
getPieceStorage()->getDiskAdaptor())
|
|
|
|
== downloadContext_->getPieceHash(piece->getIndex());
|
|
|
|
} catch(RecoverableException& e) {
|
2012-12-05 15:39:14 +00:00
|
|
|
piece->clearAllBlock(getPieceStorage()->getWrDiskCache());
|
2012-11-27 13:04:59 +00:00
|
|
|
throw;
|
|
|
|
}
|
2008-06-04 16:28:16 +00:00
|
|
|
}
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
|
2010-06-11 11:48:22 +00:00
|
|
|
void BtPieceMessage::onNewPiece(const SharedHandle<Piece>& piece)
|
|
|
|
{
|
2012-11-27 13:04:59 +00:00
|
|
|
if(piece->getWrDiskCacheEntry()) {
|
|
|
|
// We flush cached data whenever an whole piece is retrieved.
|
|
|
|
piece->flushWrCache(getPieceStorage()->getWrDiskCache());
|
|
|
|
if(piece->getWrDiskCacheEntry()->getError() !=
|
|
|
|
WrDiskCacheEntry::CACHE_ERR_SUCCESS) {
|
2012-12-05 15:39:14 +00:00
|
|
|
piece->clearAllBlock(getPieceStorage()->getWrDiskCache());
|
2012-11-27 13:04:59 +00:00
|
|
|
throw DOWNLOAD_FAILURE_EXCEPTION2
|
|
|
|
(fmt("Write disk cache flush failure index=%lu",
|
|
|
|
static_cast<unsigned long>(piece->getIndex())),
|
|
|
|
piece->getWrDiskCacheEntry()->getErrorCode());
|
|
|
|
}
|
|
|
|
}
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_INFO(fmt(MSG_GOT_NEW_PIECE,
|
2010-11-20 12:12:06 +00:00
|
|
|
getCuid(),
|
2010-11-20 08:21:36 +00:00
|
|
|
static_cast<unsigned long>(piece->getIndex())));
|
2010-06-11 11:48:22 +00:00
|
|
|
getPieceStorage()->completePiece(piece);
|
|
|
|
getPieceStorage()->advertisePiece(getCuid(), piece->getIndex());
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
|
2010-06-11 11:48:22 +00:00
|
|
|
void BtPieceMessage::onWrongPiece(const SharedHandle<Piece>& piece)
|
|
|
|
{
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_INFO(fmt(MSG_GOT_WRONG_PIECE,
|
2010-11-20 12:12:06 +00:00
|
|
|
getCuid(),
|
2010-11-20 08:21:36 +00:00
|
|
|
static_cast<unsigned long>(piece->getIndex())));
|
2012-12-05 15:39:14 +00:00
|
|
|
piece->clearAllBlock(getPieceStorage()->getWrDiskCache());
|
2008-06-04 16:28:16 +00:00
|
|
|
piece->destroyHashContext();
|
2010-06-11 11:48:22 +00:00
|
|
|
getBtRequestFactory()->removeTargetPiece(piece);
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
|
2009-04-21 14:52:04 +00:00
|
|
|
void BtPieceMessage::onChokingEvent(const BtChokingEvent& event)
|
|
|
|
{
|
2010-06-11 11:48:22 +00:00
|
|
|
if(!isInvalidate() &&
|
2010-06-21 13:51:56 +00:00
|
|
|
!getPeer()->isInAmAllowedIndexSet(index_)) {
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_DEBUG(fmt(MSG_REJECT_PIECE_CHOKED,
|
2010-11-20 12:12:06 +00:00
|
|
|
getCuid(),
|
2010-11-20 08:21:36 +00:00
|
|
|
static_cast<unsigned long>(index_),
|
|
|
|
begin_,
|
|
|
|
blockLength_));
|
2010-06-11 11:48:22 +00:00
|
|
|
if(getPeer()->isFastExtensionEnabled()) {
|
2012-09-28 14:27:46 +00:00
|
|
|
SharedHandle<BtMessage> rej =
|
2010-06-11 11:48:22 +00:00
|
|
|
getBtMessageFactory()->createRejectMessage
|
2010-06-21 13:51:56 +00:00
|
|
|
(index_, begin_, blockLength_);
|
2010-06-11 11:48:22 +00:00
|
|
|
getBtMessageDispatcher()->addMessageToQueue(rej);
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
2010-06-11 11:48:22 +00:00
|
|
|
setInvalidate(true);
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-21 14:52:04 +00:00
|
|
|
void BtPieceMessage::onCancelSendingPieceEvent
|
|
|
|
(const BtCancelSendingPieceEvent& event)
|
|
|
|
{
|
2010-06-11 11:48:22 +00:00
|
|
|
if(!isInvalidate() &&
|
2010-06-21 13:51:56 +00:00
|
|
|
index_ == event.getIndex() &&
|
|
|
|
begin_ == event.getBegin() &&
|
|
|
|
blockLength_ == event.getLength()) {
|
2010-11-20 08:21:36 +00:00
|
|
|
A2_LOG_DEBUG(fmt(MSG_REJECT_PIECE_CANCEL,
|
2010-11-20 12:12:06 +00:00
|
|
|
getCuid(),
|
2010-11-20 08:21:36 +00:00
|
|
|
static_cast<unsigned long>(index_),
|
|
|
|
begin_,
|
|
|
|
blockLength_));
|
2010-06-11 11:48:22 +00:00
|
|
|
if(getPeer()->isFastExtensionEnabled()) {
|
2012-09-28 14:27:46 +00:00
|
|
|
SharedHandle<BtMessage> rej =
|
2010-06-11 11:48:22 +00:00
|
|
|
getBtMessageFactory()->createRejectMessage
|
2010-06-21 13:51:56 +00:00
|
|
|
(index_, begin_, blockLength_);
|
2010-06-11 11:48:22 +00:00
|
|
|
getBtMessageDispatcher()->addMessageToQueue(rej);
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
2010-06-11 11:48:22 +00:00
|
|
|
setInvalidate(true);
|
2012-09-28 14:27:46 +00:00
|
|
|
}
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
2008-02-08 15:53:45 +00:00
|
|
|
|
2009-06-28 10:37:15 +00:00
|
|
|
void BtPieceMessage::setDownloadContext
|
|
|
|
(const SharedHandle<DownloadContext>& downloadContext)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
downloadContext_ = downloadContext;
|
2009-06-28 10:37:15 +00:00
|
|
|
}
|
|
|
|
|
2011-12-03 09:12:31 +00:00
|
|
|
void BtPieceMessage::setPeerStorage
|
|
|
|
(const SharedHandle<PeerStorage>& peerStorage)
|
|
|
|
{
|
|
|
|
peerStorage_ = peerStorage;
|
|
|
|
}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
} // namespace aria2
|