mirror of https://github.com/aria2/aria2
2010-08-04 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Don't use pre-calculate hash value when end-game mode. Throw exception if bad piece is received. * src/BtPieceMessage.cc * src/DownloadCommand.ccpull/1/head
parent
2176b68116
commit
dfdf2d8e56
|
@ -1,3 +1,10 @@
|
||||||
|
2010-08-04 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Don't use pre-calculate hash value when end-game mode. Throw
|
||||||
|
exception if bad piece is received.
|
||||||
|
* src/BtPieceMessage.cc
|
||||||
|
* src/DownloadCommand.cc
|
||||||
|
|
||||||
2010-08-04 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2010-08-04 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Rewritten ut_pex peer selection.
|
Rewritten ut_pex peer selection.
|
||||||
|
|
|
@ -128,6 +128,7 @@ void BtPieceMessage::doReceivedAction()
|
||||||
onNewPiece(piece);
|
onNewPiece(piece);
|
||||||
} else {
|
} else {
|
||||||
onWrongPiece(piece);
|
onWrongPiece(piece);
|
||||||
|
throw DL_ABORT_EX("Bad piece hash.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -221,7 +222,7 @@ std::string BtPieceMessage::toString() const
|
||||||
|
|
||||||
bool BtPieceMessage::checkPieceHash(const SharedHandle<Piece>& piece)
|
bool BtPieceMessage::checkPieceHash(const SharedHandle<Piece>& piece)
|
||||||
{
|
{
|
||||||
if(piece->isHashCalculated()) {
|
if(!getPieceStorage()->isEndGame() && piece->isHashCalculated()) {
|
||||||
if(getLogger()->debug()) {
|
if(getLogger()->debug()) {
|
||||||
getLogger()->debug("Hash is available!! index=%lu",
|
getLogger()->debug("Hash is available!! index=%lu",
|
||||||
static_cast<unsigned long>(piece->getIndex()));
|
static_cast<unsigned long>(piece->getIndex()));
|
||||||
|
|
|
@ -64,6 +64,9 @@
|
||||||
#ifdef ENABLE_MESSAGE_DIGEST
|
#ifdef ENABLE_MESSAGE_DIGEST
|
||||||
# include "MessageDigestHelper.h"
|
# include "MessageDigestHelper.h"
|
||||||
#endif // ENABLE_MESSAGE_DIGEST
|
#endif // ENABLE_MESSAGE_DIGEST
|
||||||
|
#ifdef ENABLE_BITTORRENT
|
||||||
|
# include "bittorrent_helper.h"
|
||||||
|
#endif // ENABLE_BITTORRENT
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -241,7 +244,12 @@ bool DownloadCommand::executeInternal() {
|
||||||
const std::string& expectedPieceHash =
|
const std::string& expectedPieceHash =
|
||||||
getDownloadContext()->getPieceHash(segment->getIndex());
|
getDownloadContext()->getPieceHash(segment->getIndex());
|
||||||
if(pieceHashValidationEnabled_ && !expectedPieceHash.empty()) {
|
if(pieceHashValidationEnabled_ && !expectedPieceHash.empty()) {
|
||||||
if(segment->isHashCalculated()) {
|
if(
|
||||||
|
#ifdef ENABLE_BITTORRENT
|
||||||
|
(!getPieceStorage()->isEndGame() ||
|
||||||
|
!getDownloadContext()->hasAttribute(bittorrent::BITTORRENT)) &&
|
||||||
|
#endif // ENABLE_BITTORRENT
|
||||||
|
segment->isHashCalculated()) {
|
||||||
if(getLogger()->debug()) {
|
if(getLogger()->debug()) {
|
||||||
getLogger()->debug
|
getLogger()->debug
|
||||||
("Hash is available! index=%lu",
|
("Hash is available! index=%lu",
|
||||||
|
|
Loading…
Reference in New Issue