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>
|
||||
|
||||
Added bencode::decode overload functions. They have extra argument
|
||||
|
|
|
@ -48,6 +48,7 @@ AbstractBtMessage::AbstractBtMessage(uint8_t id, const std::string& name):
|
|||
uploading(false),
|
||||
cuid(0),
|
||||
_name(name),
|
||||
_metadataGetMode(false),
|
||||
logger(LogFactory::getInstance())
|
||||
{}
|
||||
|
||||
|
|
|
@ -73,6 +73,8 @@ protected:
|
|||
|
||||
SharedHandle<BtMessageValidator> validator;
|
||||
|
||||
bool _metadataGetMode;
|
||||
|
||||
Logger* logger;
|
||||
public:
|
||||
AbstractBtMessage(uint8_t id, const std::string& name);
|
||||
|
@ -148,6 +150,11 @@ public:
|
|||
{
|
||||
return _name;
|
||||
}
|
||||
|
||||
void enableMetadataGetMode()
|
||||
{
|
||||
_metadataGetMode = true;
|
||||
}
|
||||
};
|
||||
|
||||
typedef SharedHandle<AbstractBtMessage> AbstractBtMessageHandle;
|
||||
|
|
|
@ -53,6 +53,9 @@ void BtAllowedFastMessage::doReceivedAction() {
|
|||
(StringFormat("%s received while fast extension is disabled",
|
||||
toString().c_str()).str());
|
||||
}
|
||||
if(_metadataGetMode) {
|
||||
return;
|
||||
}
|
||||
peer->addPeerAllowedIndex(getIndex());
|
||||
}
|
||||
|
||||
|
|
|
@ -71,6 +71,9 @@ BtBitfieldMessage::create(const unsigned char* data, size_t dataLength)
|
|||
}
|
||||
|
||||
void BtBitfieldMessage::doReceivedAction() {
|
||||
if(_metadataGetMode) {
|
||||
return;
|
||||
}
|
||||
pieceStorage->updatePieceStats(bitfield, bitfieldLength, peer->getBitfield());
|
||||
peer->setBitfield(bitfield, bitfieldLength);
|
||||
if(peer->isSeeder() && pieceStorage->downloadFinished()) {
|
||||
|
|
|
@ -47,6 +47,9 @@ SharedHandle<BtCancelMessage> BtCancelMessage::create
|
|||
|
||||
void BtCancelMessage::doReceivedAction()
|
||||
{
|
||||
if(_metadataGetMode) {
|
||||
return;
|
||||
}
|
||||
dispatcher->doCancelSendingPieceAction(getIndex(), getBegin(), getLength());
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,9 @@ SharedHandle<BtChokeMessage> BtChokeMessage::create
|
|||
|
||||
void BtChokeMessage::doReceivedAction()
|
||||
{
|
||||
if(_metadataGetMode) {
|
||||
return;
|
||||
}
|
||||
peer->peerChoking(true);
|
||||
dispatcher->doChokedAction();
|
||||
requestFactory->doChokedAction();
|
||||
|
|
|
@ -56,6 +56,9 @@ void BtHaveAllMessage::doReceivedAction()
|
|||
(StringFormat("%s received while fast extension is disabled",
|
||||
toString().c_str()).str());
|
||||
}
|
||||
if(_metadataGetMode) {
|
||||
return;
|
||||
}
|
||||
pieceStorage->subtractPieceStats(peer->getBitfield(),
|
||||
peer->getBitfieldLength());
|
||||
peer->setAllBitfield();
|
||||
|
|
|
@ -50,6 +50,9 @@ SharedHandle<BtHaveMessage> BtHaveMessage::create
|
|||
|
||||
void BtHaveMessage::doReceivedAction()
|
||||
{
|
||||
if(_metadataGetMode) {
|
||||
return;
|
||||
}
|
||||
peer->updateBitfield(getIndex(), 1);
|
||||
pieceStorage->addPieceStats(getIndex());
|
||||
if(peer->isSeeder() && pieceStorage->downloadFinished()) {
|
||||
|
|
|
@ -48,6 +48,9 @@ SharedHandle<BtInterestedMessage> BtInterestedMessage::create
|
|||
|
||||
void BtInterestedMessage::doReceivedAction()
|
||||
{
|
||||
if(_metadataGetMode) {
|
||||
return;
|
||||
}
|
||||
peer->peerInterested(true);
|
||||
if(!peer->amChoking()) {
|
||||
_peerStorage->executeChoke();
|
||||
|
|
|
@ -48,6 +48,9 @@ SharedHandle<BtNotInterestedMessage> BtNotInterestedMessage::create
|
|||
|
||||
void BtNotInterestedMessage::doReceivedAction()
|
||||
{
|
||||
if(_metadataGetMode) {
|
||||
return;
|
||||
}
|
||||
peer->peerInterested(false);
|
||||
if(!peer->amChoking()) {
|
||||
_peerStorage->executeChoke();
|
||||
|
|
|
@ -77,6 +77,9 @@ BtPieceMessageHandle BtPieceMessage::create(const unsigned char* data, size_t da
|
|||
}
|
||||
|
||||
void BtPieceMessage::doReceivedAction() {
|
||||
if(_metadataGetMode) {
|
||||
return;
|
||||
}
|
||||
RequestSlot slot = dispatcher->getOutstandingRequest(index,
|
||||
begin,
|
||||
blockLength);
|
||||
|
|
|
@ -56,6 +56,9 @@ void BtRejectMessage::doReceivedAction()
|
|||
(StringFormat("%s received while fast extension is disabled.",
|
||||
toString().c_str()).str());
|
||||
}
|
||||
if(_metadataGetMode) {
|
||||
return;
|
||||
}
|
||||
// TODO Current implementation does not close a connection even if
|
||||
// a request for this reject message has never sent.
|
||||
RequestSlot slot =
|
||||
|
|
|
@ -51,6 +51,9 @@ SharedHandle<BtRequestMessage> BtRequestMessage::create
|
|||
|
||||
void BtRequestMessage::doReceivedAction()
|
||||
{
|
||||
if(_metadataGetMode) {
|
||||
return;
|
||||
}
|
||||
if(pieceStorage->hasPiece(getIndex()) &&
|
||||
(!peer->amChoking() ||
|
||||
(peer->amChoking() && peer->isInAmAllowedIndexSet(getIndex())))) {
|
||||
|
|
|
@ -47,6 +47,9 @@ SharedHandle<BtUnchokeMessage> BtUnchokeMessage::create
|
|||
|
||||
void BtUnchokeMessage::doReceivedAction()
|
||||
{
|
||||
if(_metadataGetMode) {
|
||||
return;
|
||||
}
|
||||
peer->peerChoking(false);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue