/* */ #include "BtRejectMessage.h" #include "DlAbortEx.h" #include "Peer.h" #include "RequestSlot.h" #include "BtMessageDispatcher.h" #include "fmt.h" namespace aria2 { const char BtRejectMessage::NAME[] = "reject"; BtRejectMessage::BtRejectMessage(size_t index, int32_t begin, int32_t length) : RangeBtMessage(ID, NAME, index, begin, length) { } std::unique_ptr BtRejectMessage::create(const unsigned char* data, size_t dataLength) { return RangeBtMessage::create(data, dataLength); } void BtRejectMessage::doReceivedAction() { if (!getPeer()->isFastExtensionEnabled()) { throw DL_ABORT_EX(fmt("%s received while fast extension is disabled.", toString().c_str())); } if (isMetadataGetMode()) { return; } // TODO Current implementation does not close a connection even if // a request for this reject message has never sent. auto slot = getBtMessageDispatcher()->getOutstandingRequest( getIndex(), getBegin(), getLength()); if (slot) { getBtMessageDispatcher()->removeOutstandingRequest(slot); } else { // throw DL_ABORT_EX("reject received, but it is not in the request // slots."); } } } // namespace aria2