mirror of https://github.com/aria2/aria2
2009-11-22 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added _metadataGetMode member variable. It toggles the action when messages are received: usually they almost do nothing if _metadataGetMode is true. * src/AbstractBtMessage.cc * src/AbstractBtMessage.h * src/BtAllowedFastMessage.cc * src/BtBitfieldMessage.cc * src/BtCancelMessage.cc * src/BtChokeMessage.cc * src/BtHaveAllMessage.cc * src/BtHaveMessage.cc * src/BtInterestedMessage.cc * src/BtNotInterestedMessage.cc * src/BtPieceMessage.cc * src/BtRejectMessage.cc * src/BtRequestMessage.cc * src/BtUnchokeMessage.ccpull/1/head
parent
5130b5c1e0
commit
d9e29e5c7d
20
ChangeLog
20
ChangeLog
|
@ -1,3 +1,23 @@
|
||||||
|
2009-11-22 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Added _metadataGetMode member variable. It toggles the action when
|
||||||
|
messages are received: usually they almost do nothing if
|
||||||
|
_metadataGetMode is true.
|
||||||
|
* src/AbstractBtMessage.cc
|
||||||
|
* src/AbstractBtMessage.h
|
||||||
|
* src/BtAllowedFastMessage.cc
|
||||||
|
* src/BtBitfieldMessage.cc
|
||||||
|
* src/BtCancelMessage.cc
|
||||||
|
* src/BtChokeMessage.cc
|
||||||
|
* src/BtHaveAllMessage.cc
|
||||||
|
* src/BtHaveMessage.cc
|
||||||
|
* src/BtInterestedMessage.cc
|
||||||
|
* src/BtNotInterestedMessage.cc
|
||||||
|
* src/BtPieceMessage.cc
|
||||||
|
* src/BtRejectMessage.cc
|
||||||
|
* src/BtRequestMessage.cc
|
||||||
|
* src/BtUnchokeMessage.cc
|
||||||
|
|
||||||
2009-11-22 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2009-11-22 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Added bencode::decode overload functions. They have extra argument
|
Added bencode::decode overload functions. They have extra argument
|
||||||
|
|
|
@ -48,6 +48,7 @@ AbstractBtMessage::AbstractBtMessage(uint8_t id, const std::string& name):
|
||||||
uploading(false),
|
uploading(false),
|
||||||
cuid(0),
|
cuid(0),
|
||||||
_name(name),
|
_name(name),
|
||||||
|
_metadataGetMode(false),
|
||||||
logger(LogFactory::getInstance())
|
logger(LogFactory::getInstance())
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
|
|
@ -73,6 +73,8 @@ protected:
|
||||||
|
|
||||||
SharedHandle<BtMessageValidator> validator;
|
SharedHandle<BtMessageValidator> validator;
|
||||||
|
|
||||||
|
bool _metadataGetMode;
|
||||||
|
|
||||||
Logger* logger;
|
Logger* logger;
|
||||||
public:
|
public:
|
||||||
AbstractBtMessage(uint8_t id, const std::string& name);
|
AbstractBtMessage(uint8_t id, const std::string& name);
|
||||||
|
@ -148,6 +150,11 @@ public:
|
||||||
{
|
{
|
||||||
return _name;
|
return _name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void enableMetadataGetMode()
|
||||||
|
{
|
||||||
|
_metadataGetMode = true;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SharedHandle<AbstractBtMessage> AbstractBtMessageHandle;
|
typedef SharedHandle<AbstractBtMessage> AbstractBtMessageHandle;
|
||||||
|
|
|
@ -53,6 +53,9 @@ void BtAllowedFastMessage::doReceivedAction() {
|
||||||
(StringFormat("%s received while fast extension is disabled",
|
(StringFormat("%s received while fast extension is disabled",
|
||||||
toString().c_str()).str());
|
toString().c_str()).str());
|
||||||
}
|
}
|
||||||
|
if(_metadataGetMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
peer->addPeerAllowedIndex(getIndex());
|
peer->addPeerAllowedIndex(getIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,9 @@ BtBitfieldMessage::create(const unsigned char* data, size_t dataLength)
|
||||||
}
|
}
|
||||||
|
|
||||||
void BtBitfieldMessage::doReceivedAction() {
|
void BtBitfieldMessage::doReceivedAction() {
|
||||||
|
if(_metadataGetMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
pieceStorage->updatePieceStats(bitfield, bitfieldLength, peer->getBitfield());
|
pieceStorage->updatePieceStats(bitfield, bitfieldLength, peer->getBitfield());
|
||||||
peer->setBitfield(bitfield, bitfieldLength);
|
peer->setBitfield(bitfield, bitfieldLength);
|
||||||
if(peer->isSeeder() && pieceStorage->downloadFinished()) {
|
if(peer->isSeeder() && pieceStorage->downloadFinished()) {
|
||||||
|
|
|
@ -47,6 +47,9 @@ SharedHandle<BtCancelMessage> BtCancelMessage::create
|
||||||
|
|
||||||
void BtCancelMessage::doReceivedAction()
|
void BtCancelMessage::doReceivedAction()
|
||||||
{
|
{
|
||||||
|
if(_metadataGetMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
dispatcher->doCancelSendingPieceAction(getIndex(), getBegin(), getLength());
|
dispatcher->doCancelSendingPieceAction(getIndex(), getBegin(), getLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,9 @@ SharedHandle<BtChokeMessage> BtChokeMessage::create
|
||||||
|
|
||||||
void BtChokeMessage::doReceivedAction()
|
void BtChokeMessage::doReceivedAction()
|
||||||
{
|
{
|
||||||
|
if(_metadataGetMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
peer->peerChoking(true);
|
peer->peerChoking(true);
|
||||||
dispatcher->doChokedAction();
|
dispatcher->doChokedAction();
|
||||||
requestFactory->doChokedAction();
|
requestFactory->doChokedAction();
|
||||||
|
|
|
@ -56,6 +56,9 @@ void BtHaveAllMessage::doReceivedAction()
|
||||||
(StringFormat("%s received while fast extension is disabled",
|
(StringFormat("%s received while fast extension is disabled",
|
||||||
toString().c_str()).str());
|
toString().c_str()).str());
|
||||||
}
|
}
|
||||||
|
if(_metadataGetMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
pieceStorage->subtractPieceStats(peer->getBitfield(),
|
pieceStorage->subtractPieceStats(peer->getBitfield(),
|
||||||
peer->getBitfieldLength());
|
peer->getBitfieldLength());
|
||||||
peer->setAllBitfield();
|
peer->setAllBitfield();
|
||||||
|
|
|
@ -50,6 +50,9 @@ SharedHandle<BtHaveMessage> BtHaveMessage::create
|
||||||
|
|
||||||
void BtHaveMessage::doReceivedAction()
|
void BtHaveMessage::doReceivedAction()
|
||||||
{
|
{
|
||||||
|
if(_metadataGetMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
peer->updateBitfield(getIndex(), 1);
|
peer->updateBitfield(getIndex(), 1);
|
||||||
pieceStorage->addPieceStats(getIndex());
|
pieceStorage->addPieceStats(getIndex());
|
||||||
if(peer->isSeeder() && pieceStorage->downloadFinished()) {
|
if(peer->isSeeder() && pieceStorage->downloadFinished()) {
|
||||||
|
|
|
@ -48,6 +48,9 @@ SharedHandle<BtInterestedMessage> BtInterestedMessage::create
|
||||||
|
|
||||||
void BtInterestedMessage::doReceivedAction()
|
void BtInterestedMessage::doReceivedAction()
|
||||||
{
|
{
|
||||||
|
if(_metadataGetMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
peer->peerInterested(true);
|
peer->peerInterested(true);
|
||||||
if(!peer->amChoking()) {
|
if(!peer->amChoking()) {
|
||||||
_peerStorage->executeChoke();
|
_peerStorage->executeChoke();
|
||||||
|
|
|
@ -48,6 +48,9 @@ SharedHandle<BtNotInterestedMessage> BtNotInterestedMessage::create
|
||||||
|
|
||||||
void BtNotInterestedMessage::doReceivedAction()
|
void BtNotInterestedMessage::doReceivedAction()
|
||||||
{
|
{
|
||||||
|
if(_metadataGetMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
peer->peerInterested(false);
|
peer->peerInterested(false);
|
||||||
if(!peer->amChoking()) {
|
if(!peer->amChoking()) {
|
||||||
_peerStorage->executeChoke();
|
_peerStorage->executeChoke();
|
||||||
|
|
|
@ -77,6 +77,9 @@ BtPieceMessageHandle BtPieceMessage::create(const unsigned char* data, size_t da
|
||||||
}
|
}
|
||||||
|
|
||||||
void BtPieceMessage::doReceivedAction() {
|
void BtPieceMessage::doReceivedAction() {
|
||||||
|
if(_metadataGetMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
RequestSlot slot = dispatcher->getOutstandingRequest(index,
|
RequestSlot slot = dispatcher->getOutstandingRequest(index,
|
||||||
begin,
|
begin,
|
||||||
blockLength);
|
blockLength);
|
||||||
|
|
|
@ -56,6 +56,9 @@ void BtRejectMessage::doReceivedAction()
|
||||||
(StringFormat("%s received while fast extension is disabled.",
|
(StringFormat("%s received while fast extension is disabled.",
|
||||||
toString().c_str()).str());
|
toString().c_str()).str());
|
||||||
}
|
}
|
||||||
|
if(_metadataGetMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
// TODO Current implementation does not close a connection even if
|
// TODO Current implementation does not close a connection even if
|
||||||
// a request for this reject message has never sent.
|
// a request for this reject message has never sent.
|
||||||
RequestSlot slot =
|
RequestSlot slot =
|
||||||
|
|
|
@ -51,6 +51,9 @@ SharedHandle<BtRequestMessage> BtRequestMessage::create
|
||||||
|
|
||||||
void BtRequestMessage::doReceivedAction()
|
void BtRequestMessage::doReceivedAction()
|
||||||
{
|
{
|
||||||
|
if(_metadataGetMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(pieceStorage->hasPiece(getIndex()) &&
|
if(pieceStorage->hasPiece(getIndex()) &&
|
||||||
(!peer->amChoking() ||
|
(!peer->amChoking() ||
|
||||||
(peer->amChoking() && peer->isInAmAllowedIndexSet(getIndex())))) {
|
(peer->amChoking() && peer->isInAmAllowedIndexSet(getIndex())))) {
|
||||||
|
|
|
@ -47,6 +47,9 @@ SharedHandle<BtUnchokeMessage> BtUnchokeMessage::create
|
||||||
|
|
||||||
void BtUnchokeMessage::doReceivedAction()
|
void BtUnchokeMessage::doReceivedAction()
|
||||||
{
|
{
|
||||||
|
if(_metadataGetMode) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
peer->peerChoking(false);
|
peer->peerChoking(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue