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"
|
2007-08-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
MessageDigestHelper is introduced in order to simplify the use
of message digest. Removed repeated code.
The message digest algorithm is now specified by string, like
"sha1",
"md5".
* src/messageDigest.{h, cc}
* src/MessageDigestHelper.{h, cc}: New class.
* src/DefaultPieceStorage.cc
* src/DefaultBtContext.{h, cc}
(computeFastSet): New function.
(setInfoHash): Added for unit testing.
(setNumPieces): Added for unit testing.
* src/DefaultBtInteractive.cc
* src/BtPieceMessage.cc
* src/Peer.cc
* src/Checksum.h
* src/message.h
* src/IteratableChecksumValidator.h
* src/ChunkChecksumValidator.{h, cc}: Use
IteratableChecksumValidator
inside it.
* src/SegmentMan.{h, cc}
(checkIntegrity): Removed.
* src/IteratableChunkChecksumValidator.{h, cc}
* src/Util.h
(sha1Sum): Removed.
(simpleMessageDigest): Removed.
(fileChecksum): Removed.
(computeFastSet): Removed.
* src/ShaVisitor.cc
* src/ChunkChecksum.h
* src/DownloadCommand.cc
Removed messageDigest virtual functions.
* src/MultiDiskAdaptor.{h, cc}
* src/DiskAdaptor.h
* src/ByteArrayDiskWriter.h
* src/DiskWriter.h
* src/DiskAdaptorWriter.h
* src/AbstractSingleDiskAdaptor.{h, cc}
* src/AbstractDiskWriter.{h, cc}
Fixed comilation error when message digest is disabled.
* src/MetalinkEntry.{h, cc}
* src/MetalinkRequestInfo.cc
Removed srandom and random.
* src/SimpleRandomizer.h
Added size() virtual function to DiskAdaptor
* src/MultiDiskAdaptor.h
Fixed the bug that causes that files are not opened correctly in
multi-file torrent.
* src/TorrentRequestInfo.cc
* src/MultiDiskAdaptor.cc
Added SHA256 support
* src/messageDigest.cc
* src/Xml2MetalinkProcessor.cc
Show supported message digest algorithms
* src/main.cc
Updated contact info.
* src/main.cc
2007-08-08 14:40:11 +00:00
|
|
|
#include "MessageDigestHelper.h"
|
2007-10-11 16:58:24 +00:00
|
|
|
#include "DiskAdaptor.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
#include "Logger.h"
|
|
|
|
#include "Peer.h"
|
|
|
|
#include "Piece.h"
|
|
|
|
#include "PieceStorage.h"
|
|
|
|
#include "BtMessageDispatcher.h"
|
|
|
|
#include "BtMessageFactory.h"
|
|
|
|
#include "BtRequestFactory.h"
|
|
|
|
#include "PeerConnection.h"
|
2008-04-27 02:22:14 +00:00
|
|
|
#include "StringFormat.h"
|
2009-06-28 10:37:15 +00:00
|
|
|
#include "DownloadContext.h"
|
2008-02-08 15:53:45 +00:00
|
|
|
|
|
|
|
namespace aria2 {
|
2006-12-24 06:25:21 +00:00
|
|
|
|
2009-03-12 15:54:43 +00:00
|
|
|
const std::string BtPieceMessage::NAME("piece");
|
|
|
|
|
2010-06-11 11:48:22 +00:00
|
|
|
BtPieceMessage::BtPieceMessage
|
|
|
|
(size_t index, uint32_t begin, size_t blockLength):
|
|
|
|
AbstractBtMessage(ID, NAME),
|
2010-06-21 13:51:56 +00:00
|
|
|
index_(index),
|
|
|
|
begin_(begin),
|
|
|
|
blockLength_(blockLength),
|
|
|
|
block_(0),
|
|
|
|
rawData_(0)
|
2010-06-11 11:48:22 +00:00
|
|
|
{
|
|
|
|
setUploading(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
BtPieceMessage::~BtPieceMessage()
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
delete [] rawData_;
|
2010-06-11 11:48:22 +00:00
|
|
|
}
|
|
|
|
|
2010-03-04 16:24:03 +00:00
|
|
|
void BtPieceMessage::setRawMessage(unsigned char* data)
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
delete [] rawData_;
|
|
|
|
rawData_ = data;
|
|
|
|
block_ = data+9;
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
|
2010-06-11 11:48:22 +00:00
|
|
|
BtPieceMessageHandle BtPieceMessage::create
|
|
|
|
(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);
|
2008-04-20 00:50:22 +00:00
|
|
|
BtPieceMessageHandle 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_);
|
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_);
|
|
|
|
off_t offset = (off_t)index_*downloadContext_->getPieceLength()+begin_;
|
2010-06-11 11:48:22 +00:00
|
|
|
if(getLogger()->debug()) {
|
|
|
|
getLogger()->debug(MSG_PIECE_RECEIVED,
|
|
|
|
util::itos(getCuid()).c_str(),
|
2010-06-21 13:51:56 +00:00
|
|
|
index_, begin_, blockLength_, offset,
|
2010-06-11 11:48:22 +00:00
|
|
|
slot.getBlockIndex());
|
2010-02-09 12:20:20 +00:00
|
|
|
}
|
2010-06-11 11:48:22 +00:00
|
|
|
getPieceStorage()->getDiskAdaptor()->writeData
|
2010-06-21 13:51:56 +00:00
|
|
|
(block_, blockLength_, offset);
|
2006-12-24 06:25:21 +00:00
|
|
|
piece->completeBlock(slot.getBlockIndex());
|
2010-06-11 11:48:22 +00:00
|
|
|
if(getLogger()->debug()) {
|
|
|
|
getLogger()->debug(MSG_PIECE_BITFIELD, util::itos(getCuid()).c_str(),
|
|
|
|
util::toHex(piece->getBitfield(),
|
|
|
|
piece->getBitfieldLength()).c_str());
|
2010-02-09 12:20:20 +00:00
|
|
|
}
|
2010-06-21 13:51:56 +00:00
|
|
|
piece->updateHash(begin_, block_, 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);
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
}
|
2008-05-17 07:06:17 +00:00
|
|
|
} else {
|
2010-06-11 11:48:22 +00:00
|
|
|
if(getLogger()->debug()) {
|
|
|
|
getLogger()->debug("CUID#%s - RequestSlot not found, index=%d, begin=%d",
|
2010-06-21 13:51:56 +00:00
|
|
|
util::itos(getCuid()).c_str(), index_, begin_);
|
2010-02-09 12:20:20 +00:00
|
|
|
}
|
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
|
|
|
|
2010-03-04 16:24:03 +00:00
|
|
|
unsigned char* BtPieceMessage::createMessageHeader()
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* len --- 9+blockLength, 4bytes
|
|
|
|
* id --- 7, 1byte
|
|
|
|
* index --- index, 4bytes
|
|
|
|
* begin --- begin, 4bytes
|
|
|
|
* total: 13bytes
|
|
|
|
*/
|
|
|
|
unsigned char* msgHeader = new unsigned char[MESSAGE_HEADER_LENGTH];
|
|
|
|
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
|
|
|
return msgHeader;
|
|
|
|
}
|
|
|
|
|
2010-06-11 11:48:22 +00:00
|
|
|
size_t BtPieceMessage::getMessageHeaderLength()
|
|
|
|
{
|
2006-12-24 06:25:21 +00:00
|
|
|
return MESSAGE_HEADER_LENGTH;
|
|
|
|
}
|
|
|
|
|
2010-06-11 11:48:22 +00:00
|
|
|
void BtPieceMessage::send()
|
|
|
|
{
|
|
|
|
if(isInvalidate()) {
|
2006-12-24 06:25:21 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-03-04 16:24:03 +00:00
|
|
|
size_t writtenLength;
|
2010-06-11 11:48:22 +00:00
|
|
|
if(!isSendingInProgress()) {
|
|
|
|
if(getLogger()->info()) {
|
|
|
|
getLogger()->info(MSG_SEND_PEER_MESSAGE,
|
|
|
|
util::itos(getCuid()).c_str(),
|
2010-06-13 01:53:49 +00:00
|
|
|
getPeer()->getIPAddress().c_str(),
|
|
|
|
getPeer()->getPort(),
|
2010-06-11 11:48:22 +00:00
|
|
|
toString().c_str());
|
2010-03-04 16:24:03 +00:00
|
|
|
}
|
|
|
|
unsigned char* msgHdr = createMessageHeader();
|
|
|
|
size_t msgHdrLen = getMessageHeaderLength();
|
2010-06-11 11:48:22 +00:00
|
|
|
if(getLogger()->debug()) {
|
|
|
|
getLogger()->debug("msglength = %lu bytes",
|
2010-06-21 13:51:56 +00:00
|
|
|
static_cast<unsigned long>(msgHdrLen+blockLength_));
|
2010-02-09 12:20:20 +00:00
|
|
|
}
|
2010-06-11 11:48:22 +00:00
|
|
|
getPeerConnection()->pushBytes(msgHdr, msgHdrLen);
|
|
|
|
getPeerConnection()->sendPendingData();
|
2010-03-04 16:24:03 +00:00
|
|
|
off_t pieceDataOffset =
|
2010-06-21 13:51:56 +00:00
|
|
|
(off_t)index_*downloadContext_->getPieceLength()+begin_;
|
|
|
|
writtenLength = sendPieceData(pieceDataOffset, blockLength_);
|
2008-09-28 10:55:17 +00:00
|
|
|
} else {
|
2010-06-11 11:48:22 +00:00
|
|
|
writtenLength = getPeerConnection()->sendPendingData();
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
2010-06-11 11:48:22 +00:00
|
|
|
getPeer()->updateUploadLength(writtenLength);
|
|
|
|
setSendingInProgress(!getPeerConnection()->sendBufferIsEmpty());
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
|
2010-06-11 11:48:22 +00:00
|
|
|
size_t BtPieceMessage::sendPieceData(off_t offset, size_t length) const
|
|
|
|
{
|
2008-09-28 10:55:17 +00:00
|
|
|
assert(length <= 16*1024);
|
2010-03-04 16:24:03 +00:00
|
|
|
unsigned char* buf = new unsigned char[length];
|
|
|
|
ssize_t r;
|
|
|
|
try {
|
2010-06-11 11:48:22 +00:00
|
|
|
r = getPieceStorage()->getDiskAdaptor()->readData(buf, length, offset);
|
2010-03-04 16:24:03 +00:00
|
|
|
} catch(RecoverableException& e) {
|
|
|
|
delete [] buf;
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
if(r == static_cast<ssize_t>(length)) {
|
2010-06-11 11:48:22 +00:00
|
|
|
getPeerConnection()->pushBytes(buf, length);
|
|
|
|
return getPeerConnection()->sendPendingData();
|
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
|
|
|
|
{
|
2010-06-21 13:51:56 +00:00
|
|
|
return strconcat(NAME, " index=", util::itos(index_), ", begin=",
|
|
|
|
util::itos(begin_), ", length=", util::itos(blockLength_));
|
2006-12-24 06:25:21 +00:00
|
|
|
}
|
|
|
|
|
2010-06-11 11:48:22 +00:00
|
|
|
bool BtPieceMessage::checkPieceHash(const SharedHandle<Piece>& piece)
|
|
|
|
{
|
2008-06-04 16:28:16 +00:00
|
|
|
if(piece->isHashCalculated()) {
|
2010-06-11 11:48:22 +00:00
|
|
|
if(getLogger()->debug()) {
|
|
|
|
getLogger()->debug("Hash is available!! index=%lu",
|
|
|
|
static_cast<unsigned long>(piece->getIndex()));
|
2010-02-09 12:20:20 +00:00
|
|
|
}
|
2009-06-28 10:37:15 +00:00
|
|
|
return
|
2010-06-21 13:51:56 +00:00
|
|
|
piece->getHashString()==downloadContext_->getPieceHash(piece->getIndex());
|
2008-06-04 16:28:16 +00:00
|
|
|
} else {
|
2010-06-21 13:51:56 +00:00
|
|
|
off_t offset = (off_t)piece->getIndex()*downloadContext_->getPieceLength();
|
2008-06-04 16:28:16 +00:00
|
|
|
|
2010-06-11 11:48:22 +00:00
|
|
|
return MessageDigestHelper::staticSHA1Digest
|
|
|
|
(getPieceStorage()->getDiskAdaptor(), offset, piece->getLength())
|
2010-06-21 13:51:56 +00:00
|
|
|
== downloadContext_->getPieceHash(piece->getIndex());
|
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)
|
|
|
|
{
|
|
|
|
if(getLogger()->info()) {
|
|
|
|
getLogger()->info(MSG_GOT_NEW_PIECE,
|
|
|
|
util::itos(getCuid()).c_str(), piece->getIndex());
|
2010-03-21 07:05:49 +00:00
|
|
|
}
|
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)
|
|
|
|
{
|
|
|
|
if(getLogger()->info()) {
|
|
|
|
getLogger()->info(MSG_GOT_WRONG_PIECE,
|
|
|
|
util::itos(getCuid()).c_str(), piece->getIndex());
|
2010-03-21 07:05:49 +00:00
|
|
|
}
|
2006-12-24 06:25:21 +00:00
|
|
|
erasePieceOnDisk(piece);
|
|
|
|
piece->clearAllBlock();
|
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
|
|
|
}
|
|
|
|
|
2010-06-11 11:48:22 +00:00
|
|
|
void BtPieceMessage::erasePieceOnDisk(const SharedHandle<Piece>& piece)
|
|
|
|
{
|
2008-03-08 11:10:37 +00:00
|
|
|
size_t BUFSIZE = 4096;
|
2006-12-24 15:55:59 +00:00
|
|
|
unsigned char buf[BUFSIZE];
|
2006-12-24 06:25:21 +00:00
|
|
|
memset(buf, 0, BUFSIZE);
|
2010-06-21 13:51:56 +00:00
|
|
|
off_t offset = (off_t)piece->getIndex()*downloadContext_->getPieceLength();
|
2008-03-08 11:10:37 +00:00
|
|
|
div_t res = div(piece->getLength(), BUFSIZE);
|
2009-06-06 12:33:07 +00:00
|
|
|
for(int i = 0; i < res.quot; ++i) {
|
2010-06-11 11:48:22 +00:00
|
|
|
getPieceStorage()->getDiskAdaptor()->writeData(buf, BUFSIZE, offset);
|
2006-12-24 06:25:21 +00:00
|
|
|
offset += BUFSIZE;
|
|
|
|
}
|
2008-03-08 11:10:37 +00:00
|
|
|
if(res.rem > 0) {
|
2010-06-11 11:48:22 +00:00
|
|
|
getPieceStorage()->getDiskAdaptor()->writeData(buf, res.rem, offset);
|
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() &&
|
|
|
|
!isSendingInProgress() &&
|
2010-06-21 13:51:56 +00:00
|
|
|
!getPeer()->isInAmAllowedIndexSet(index_)) {
|
2010-06-11 11:48:22 +00:00
|
|
|
if(getLogger()->debug()) {
|
|
|
|
getLogger()->debug(MSG_REJECT_PIECE_CHOKED,
|
|
|
|
util::itos(getCuid()).c_str(),
|
2010-06-21 13:51:56 +00:00
|
|
|
index_, begin_, blockLength_);
|
2010-02-09 12:20:20 +00:00
|
|
|
}
|
2010-06-11 11:48:22 +00:00
|
|
|
if(getPeer()->isFastExtensionEnabled()) {
|
|
|
|
BtMessageHandle rej =
|
|
|
|
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() &&
|
|
|
|
!isSendingInProgress() &&
|
2010-06-21 13:51:56 +00:00
|
|
|
index_ == event.getIndex() &&
|
|
|
|
begin_ == event.getBegin() &&
|
|
|
|
blockLength_ == event.getLength()) {
|
2010-06-11 11:48:22 +00:00
|
|
|
if(getLogger()->debug()) {
|
|
|
|
getLogger()->debug(MSG_REJECT_PIECE_CANCEL,
|
|
|
|
util::itos(getCuid()).c_str(),
|
2010-06-21 13:51:56 +00:00
|
|
|
index_, begin_, blockLength_);
|
2010-02-09 12:20:20 +00:00
|
|
|
}
|
2010-06-11 11:48:22 +00:00
|
|
|
if(getPeer()->isFastExtensionEnabled()) {
|
|
|
|
BtMessageHandle rej =
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2008-02-08 15:53:45 +00:00
|
|
|
} // namespace aria2
|