From 010131161ebdea22e5b6eb4fd0740e8e6da3df67 Mon Sep 17 00:00:00 2001 From: Nils Maier Date: Thu, 17 Apr 2014 01:36:19 +0200 Subject: [PATCH] Remove ENABLE_MESSAGE_DIGEST, since we got the internal md, always --- configure.ac | 28 +++++----------- src/AbstractCommand.cc | 4 +-- src/ConsoleStatCalc.cc | 2 -- src/Context.cc | 4 +-- src/DefaultBtProgressInfoFile.cc | 5 --- src/DefaultPieceStorage.cc | 8 ----- src/DownloadCommand.cc | 19 ++--------- src/DownloadCommand.h | 4 --- src/DownloadEngineFactory.cc | 8 +---- src/FeatureConfig.cc | 4 --- src/FtpNegotiationCommand.cc | 12 ++----- src/GrowSegment.cc | 4 --- src/GrowSegment.h | 4 --- src/HttpResponse.cc | 4 --- src/HttpResponse.h | 2 -- src/HttpResponseCommand.cc | 20 +++-------- src/HttpResponseCommand.h | 4 --- src/HttpServerCommand.cc | 6 ++-- src/Makefile.am | 27 +++++++-------- src/Metalink2RequestGroup.cc | 12 ++----- src/MetalinkEntry.cc | 6 ++-- src/MetalinkEntry.h | 5 +-- src/MetalinkParserController.cc | 50 ++-------------------------- src/MetalinkParserController.h | 6 +--- src/MetalinkParserStateV3Impl.cc | 2 -- src/MetalinkParserStateV4Impl.cc | 2 -- src/OptionHandlerFactory.cc | 8 ----- src/OptionHandlerImpl.cc | 6 +--- src/OptionHandlerImpl.h | 2 -- src/Piece.cc | 14 ++------ src/Piece.h | 15 --------- src/PieceHashCheckIntegrityEntry.cc | 2 -- src/PiecedSegment.cc | 8 ----- src/PiecedSegment.h | 4 --- src/RequestGroup.cc | 18 ++-------- src/RpcMethodImpl.cc | 12 ++----- src/Segment.h | 4 --- src/SinkStreamFilter.cc | 2 -- src/download_helper.cc | 2 -- src/util.cc | 10 ++---- src/version_usage.cc | 6 +--- test/FeatureConfigTest.cc | 2 -- test/GZipDecoderTest.cc | 6 +--- test/GZipDecodingStreamFilterTest.cc | 6 +--- test/HttpResponseTest.cc | 10 ++---- test/Makefile.am | 2 -- test/Metalink2RequestGroupTest.cc | 4 --- test/MetalinkEntryTest.cc | 4 +-- test/MetalinkParserControllerTest.cc | 12 ++----- test/MetalinkProcessorTest.cc | 26 ++------------- test/MockSegment.h | 4 --- test/PieceTest.cc | 11 ------ test/RpcMethodTest.cc | 4 --- test/TestUtil.cc | 6 +--- test/TestUtil.h | 2 -- 55 files changed, 65 insertions(+), 399 deletions(-) diff --git a/configure.ac b/configure.ac index e3d1e78c..14c58640 100644 --- a/configure.ac +++ b/configure.ac @@ -531,15 +531,6 @@ AM_CONDITIONAL([HAVE_OPENSSL], [ test "x$have_openssl" = "xyes" ]) AM_CONDITIONAL([USE_OPENSSL_MD], [ test "x$use_md" = "xopenssl"]) AM_CONDITIONAL([USE_INTERNAL_MD], [ test "x$use_md" = "xinternal"]) -if test "x$use_md" != "x"; then - AC_DEFINE([ENABLE_MESSAGE_DIGEST], [1], - [Define to 1 if message digest support is enabled.]) - AM_CONDITIONAL([ENABLE_MESSAGE_DIGEST], true) - enable_message_digest=yes -else - AM_CONDITIONAL([ENABLE_MESSAGE_DIGEST], false) -fi - if test "x$have_libgmp" = "xyes" || test "x$have_libgcrypt" = "xyes" || test "x$have_openssl" = "xyes"; then @@ -558,8 +549,7 @@ else AM_CONDITIONAL([USE_INTERNAL_ARC4], true) fi -if test "x$enable_bittorrent" = "xyes" && - test "x$enable_message_digest" = "xyes"; then +if test "x$enable_bittorrent" = "xyes"; then AC_DEFINE([ENABLE_BITTORRENT], [1], [Define to 1 if BitTorrent support is enabled.]) AM_CONDITIONAL([ENABLE_BITTORRENT], true) @@ -940,15 +930,13 @@ if test "x$have_option_const_name" = "xyes"; then fi AC_CONFIG_SUBDIRS([deps/wslay]) -if test "x$enable_message_digest" = "xyes"; then - enable_websocket=yes - AC_DEFINE([ENABLE_WEBSOCKET], [1], - [Define 1 if WebSocket support is enabled.]) - WSLAY_LIBS="\$(top_builddir)/deps/wslay/lib/libwslay.la" - AC_SUBST([WSLAY_LIBS]) - # $(top_srcdir) for `make distcheck` - CPPFLAGS="-I\$(top_builddir)/deps/wslay/lib/includes -I\$(top_srcdir)/deps/wslay/lib/includes $CPPFLAGS" -fi +enable_websocket=yes +AC_DEFINE([ENABLE_WEBSOCKET], [1], + [Define 1 if WebSocket support is enabled.]) +WSLAY_LIBS="\$(top_builddir)/deps/wslay/lib/libwslay.la" +AC_SUBST([WSLAY_LIBS]) +# $(top_srcdir) for `make distcheck` +CPPFLAGS="-I\$(top_builddir)/deps/wslay/lib/includes -I\$(top_srcdir)/deps/wslay/lib/includes $CPPFLAGS" AM_CONDITIONAL([ENABLE_WEBSOCKET], [test "x$enable_websocket" = "xyes"]) AM_CONDITIONAL([ENABLE_LIBARIA2], [test "x$enable_libaria2" = "xyes"]) diff --git a/src/AbstractCommand.cc b/src/AbstractCommand.cc index 5dad881a..313155ba 100644 --- a/src/AbstractCommand.cc +++ b/src/AbstractCommand.cc @@ -66,13 +66,11 @@ #include "FileEntry.h" #include "error_code.h" #include "SocketRecvBuffer.h" +#include "ChecksumCheckIntegrityEntry.h" #ifdef ENABLE_ASYNC_DNS #include "AsyncNameResolver.h" #include "AsyncNameResolverMan.h" #endif // ENABLE_ASYNC_DNS -#ifdef ENABLE_MESSAGE_DIGEST -# include "ChecksumCheckIntegrityEntry.h" -#endif // ENABLE_MESSAGE_DIGEST namespace aria2 { diff --git a/src/ConsoleStatCalc.cc b/src/ConsoleStatCalc.cc index f57b1dbb..64ae3e30 100644 --- a/src/ConsoleStatCalc.cc +++ b/src/ConsoleStatCalc.cc @@ -359,7 +359,6 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e) } } } -#ifdef ENABLE_MESSAGE_DIGEST { auto& entry = e->getCheckIntegrityMan()->getPickedEntry(); if(entry) { @@ -378,7 +377,6 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e) } } } -#endif // ENABLE_MESSAGE_DIGEST if(isTTY_) { if (truncate_) { auto str = o.str(color, cols); diff --git a/src/Context.cc b/src/Context.cc index 080c0c88..25182c47 100644 --- a/src/Context.cc +++ b/src/Context.cc @@ -66,6 +66,7 @@ #include "fmt.h" #include "console.h" #include "UriListParser.h" +#include "message_digest_helper.h" #ifdef ENABLE_BITTORRENT # include "bittorrent_helper.h" #endif // ENABLE_BITTORRENT @@ -73,9 +74,6 @@ # include "metalink_helper.h" # include "MetalinkEntry.h" #endif // ENABLE_METALINK -#ifdef ENABLE_MESSAGE_DIGEST -# include "message_digest_helper.h" -#endif // ENABLE_MESSAGE_DIGEST extern char* optarg; extern int optind, opterr, optopt; diff --git a/src/DefaultBtProgressInfoFile.cc b/src/DefaultBtProgressInfoFile.cc index ed5fd8f8..b1e4fd14 100644 --- a/src/DefaultBtProgressInfoFile.cc +++ b/src/DefaultBtProgressInfoFile.cc @@ -347,13 +347,8 @@ void DefaultBtProgressInfoFile::load() ((size_t)bitfieldLength); READ_CHECK(fp, pieceBitfield.get(), bitfieldLength); piece->setBitfield(pieceBitfield.get(), bitfieldLength); - -#ifdef ENABLE_MESSAGE_DIGEST - piece->setHashType(dctx_->getPieceHashType()); -#endif // ENABLE_MESSAGE_DIGEST - inFlightPieces.push_back(piece); } pieceStorage_->addInFlightPiece(inFlightPieces); diff --git a/src/DefaultPieceStorage.cc b/src/DefaultPieceStorage.cc index 68dc63b7..c7fd7aa9 100644 --- a/src/DefaultPieceStorage.cc +++ b/src/DefaultPieceStorage.cc @@ -113,12 +113,8 @@ std::shared_ptr DefaultPieceStorage::checkOutPiece std::shared_ptr piece = findUsedPiece(index); if(!piece) { piece.reset(new Piece(index, bitfieldMan_->getBlockLength(index))); -#ifdef ENABLE_MESSAGE_DIGEST - piece->setHashType(downloadContext_->getPieceHashType()); -#endif // ENABLE_MESSAGE_DIGEST - addUsedPiece(piece); } piece->addUser(cuid); @@ -780,12 +776,8 @@ void DefaultPieceStorage::markPiecesDone(int64_t length) p->completeBlock(i); } -#ifdef ENABLE_MESSAGE_DIGEST - p->setHashType(downloadContext_->getPieceHashType()); -#endif // ENABLE_MESSAGE_DIGEST - addUsedPiece(p); } } diff --git a/src/DownloadCommand.cc b/src/DownloadCommand.cc index 0e5104d1..e42339bc 100644 --- a/src/DownloadCommand.cc +++ b/src/DownloadCommand.cc @@ -65,10 +65,8 @@ #include "Piece.h" #include "WrDiskCacheEntry.h" #include "DownloadFailureException.h" -#ifdef ENABLE_MESSAGE_DIGEST -# include "MessageDigest.h" -# include "message_digest_helper.h" -#endif // ENABLE_MESSAGE_DIGEST +#include "MessageDigest.h" +#include "message_digest_helper.h" #ifdef ENABLE_BITTORRENT # include "bittorrent_helper.h" #endif // ENABLE_BITTORRENT @@ -86,7 +84,6 @@ DownloadCommand::DownloadCommand(cuid_t cuid, lowestDownloadSpeedLimit_(0), pieceHashValidationEnabled_(false) { -#ifdef ENABLE_MESSAGE_DIGEST { if(getOption()->getAsBool(PREF_REALTIME_CHUNK_CHECKSUM)) { const std::string& algo = getDownloadContext()->getPieceHashType(); @@ -96,7 +93,6 @@ DownloadCommand::DownloadCommand(cuid_t cuid, } } } -#endif // ENABLE_MESSAGE_DIGEST peerStat_ = req->initPeerStat(); peerStat_->downloadStart(); @@ -236,8 +232,6 @@ bool DownloadCommand::executeInternal() { A2_LOG_INFO(fmt(MSG_SEGMENT_DOWNLOAD_COMPLETED, getCuid())); -#ifdef ENABLE_MESSAGE_DIGEST - { const std::string& expectedPieceHash = getDownloadContext()->getPieceHash(segment->getIndex()); @@ -270,9 +264,6 @@ bool DownloadCommand::executeInternal() { } } -#else // !ENABLE_MESSAGE_DIGEST - completeSegment(getCuid(), segment); -#endif // !ENABLE_MESSAGE_DIGEST } else { // If segment is not canceled here, in the next pipelining // request, aria2 requests bad range @@ -319,7 +310,6 @@ bool DownloadCommand::prepareForNextSegment() { getFileEntry()->setLength(getPieceStorage()->getCompletedLength()); } } -#ifdef ENABLE_MESSAGE_DIGEST if(getDownloadContext()->getPieceHashType().empty()) { auto entry = make_unique(getRequestGroup()); if(entry->isValidationReady()) { @@ -329,7 +319,6 @@ bool DownloadCommand::prepareForNextSegment() { (std::move(entry)); } } -#endif // ENABLE_MESSAGE_DIGEST // Following 2lines are needed for DownloadEngine to detect // completed RequestGroups without 1sec delay. getDownloadEngine()->setNoWait(true); @@ -370,8 +359,6 @@ bool DownloadCommand::prepareForNextSegment() { } } -#ifdef ENABLE_MESSAGE_DIGEST - void DownloadCommand::validatePieceHash(const std::shared_ptr& segment, const std::string& expectedHash, const std::string& actualHash) @@ -393,8 +380,6 @@ void DownloadCommand::validatePieceHash(const std::shared_ptr& segment, } } -#endif // ENABLE_MESSAGE_DIGEST - void DownloadCommand::completeSegment(cuid_t cuid, const std::shared_ptr& segment) { diff --git a/src/DownloadCommand.h b/src/DownloadCommand.h index ddb87da1..3efaf5a0 100644 --- a/src/DownloadCommand.h +++ b/src/DownloadCommand.h @@ -43,9 +43,7 @@ namespace aria2 { class PeerStat; class StreamFilter; -#ifdef ENABLE_MESSAGE_DIGEST class MessageDigest; -#endif // ENABLE_MESSAGE_DIGEST class DownloadCommand : public AbstractCommand { private: @@ -53,9 +51,7 @@ private: std::unique_ptr streamFilter_; -#ifdef ENABLE_MESSAGE_DIGEST std::unique_ptr messageDigest_; -#endif // ENABLE_MESSAGE_DIGEST time_t startupIdleTime_; diff --git a/src/DownloadEngineFactory.cc b/src/DownloadEngineFactory.cc index 39b04f98..fa350589 100644 --- a/src/DownloadEngineFactory.cc +++ b/src/DownloadEngineFactory.cc @@ -43,9 +43,7 @@ #include "FileAllocationMan.h" #include "CheckIntegrityMan.h" #include "CheckIntegrityEntry.h" -#ifdef ENABLE_MESSAGE_DIGEST -# include "CheckIntegrityDispatcherCommand.h" -#endif // ENABLE_MESSAGE_DIGEST +#include "CheckIntegrityDispatcherCommand.h" #include "prefs.h" #include "FillRequestGroupCommand.h" #include "FileAllocationDispatcherCommand.h" @@ -157,19 +155,15 @@ DownloadEngineFactory::newDownloadEngine e->setRequestGroupMan(std::move(requestGroupMan)); } e->setFileAllocationMan(make_unique()); -#ifdef ENABLE_MESSAGE_DIGEST e->setCheckIntegrityMan(make_unique()); -#endif // ENABLE_MESSAGE_DIGEST e->addRoutineCommand(make_unique (e->newCUID(), e.get())); e->addRoutineCommand(make_unique (e->newCUID(), e->getFileAllocationMan().get(), e.get())); -#ifdef ENABLE_MESSAGE_DIGEST e->addRoutineCommand(make_unique (e->newCUID(), e->getCheckIntegrityMan().get(), e.get())); -#endif // ENABLE_MESSAGE_DIGEST if(op->getAsInt(PREF_AUTO_SAVE_INTERVAL) > 0) { e->addRoutineCommand diff --git a/src/FeatureConfig.cc b/src/FeatureConfig.cc index d1063a2a..74dafd2b 100644 --- a/src/FeatureConfig.cc +++ b/src/FeatureConfig.cc @@ -141,11 +141,7 @@ const char* strSupportedFeature(int feature) break; case(FEATURE_MESSAGE_DIGEST): -#ifdef ENABLE_MESSAGE_DIGEST return "Message Digest"; -#else // !ENABLE_MESSAGE_DIGEST - return 0; -#endif // !ENABLE_MESSAGE_DIGEST break; case(FEATURE_METALINK): diff --git a/src/FtpNegotiationCommand.cc b/src/FtpNegotiationCommand.cc index fd369370..16237fe0 100644 --- a/src/FtpNegotiationCommand.cc +++ b/src/FtpNegotiationCommand.cc @@ -75,9 +75,7 @@ #include "error_code.h" #include "SocketRecvBuffer.h" #include "NullProgressInfoFile.h" -#ifdef ENABLE_MESSAGE_DIGEST -# include "ChecksumCheckIntegrityEntry.h" -#endif // ENABLE_MESSAGE_DIGEST +#include "ChecksumCheckIntegrityEntry.h" namespace aria2 { @@ -386,7 +384,6 @@ bool FtpNegotiationCommand::onFileSizeDetermined(int64_t totalLength) if(getDownloadContext()->knowsTotalLength() && getRequestGroup()->downloadFinishedByFileLength()) { -#ifdef ENABLE_MESSAGE_DIGEST // TODO Known issue: if .aria2 file exists, it will not be // deleted on successful verification, because .aria2 file is // not loaded. See also @@ -401,9 +398,8 @@ bool FtpNegotiationCommand::onFileSizeDetermined(int64_t totalLength) getDownloadEngine()->getCheckIntegrityMan()->pushEntry (std::move(entry)); sequence_ = SEQ_EXIT; - } else -#endif // ENABLE_MESSAGE_DIGEST - { + } + else { getPieceStorage()->markAllPiecesDone(); getDownloadContext()->setChecksumVerified(true); sequence_ = SEQ_DOWNLOAD_ALREADY_COMPLETED; @@ -423,7 +419,6 @@ bool FtpNegotiationCommand::onFileSizeDetermined(int64_t totalLength) if(getDownloadContext()->knowsTotalLength()) { A2_LOG_DEBUG("File length becomes zero and it means download completed."); -#ifdef ENABLE_MESSAGE_DIGEST // TODO Known issue: if .aria2 file exists, it will not be // deleted on successful verification, because .aria2 file is // not loaded. See also @@ -437,7 +432,6 @@ bool FtpNegotiationCommand::onFileSizeDetermined(int64_t totalLength) (std::move(entry)); sequence_ = SEQ_EXIT; } else -#endif // ENABLE_MESSAGE_DIGEST { sequence_ = SEQ_DOWNLOAD_ALREADY_COMPLETED; getPieceStorage()->markAllPiecesDone(); diff --git a/src/GrowSegment.cc b/src/GrowSegment.cc index bb5d1e54..433813df 100644 --- a/src/GrowSegment.cc +++ b/src/GrowSegment.cc @@ -50,15 +50,11 @@ void GrowSegment::updateWrittenLength(int32_t bytes) piece_->setAllBlock(); } -#ifdef ENABLE_MESSAGE_DIGEST - std::string GrowSegment::getDigest() { return A2STR::NIL; } -#endif // ENABLE_MESSAGE_DIGEST - void GrowSegment::clear(WrDiskCache* diskCache) { writtenLength_ = 0; diff --git a/src/GrowSegment.h b/src/GrowSegment.h index 8ca96af7..70aed4c0 100644 --- a/src/GrowSegment.h +++ b/src/GrowSegment.h @@ -85,8 +85,6 @@ public: virtual void updateWrittenLength(int32_t bytes) CXX11_OVERRIDE; -#ifdef ENABLE_MESSAGE_DIGEST - virtual bool updateHash (int32_t begin, const unsigned char* data, @@ -102,8 +100,6 @@ public: virtual std::string getDigest() CXX11_OVERRIDE; -#endif // ENABLE_MESSAGE_DIGEST - virtual void clear(WrDiskCache* diskCache) CXX11_OVERRIDE; virtual std::shared_ptr getPiece() const CXX11_OVERRIDE; diff --git a/src/HttpResponse.cc b/src/HttpResponse.cc index dae61dc3..c4168b3e 100644 --- a/src/HttpResponse.cc +++ b/src/HttpResponse.cc @@ -59,9 +59,7 @@ #include "MetalinkHttpEntry.h" #include "base64.h" #include "array_fun.h" -#ifdef ENABLE_MESSAGE_DIGEST #include "MessageDigest.h" -#endif // ENABLE_MESSAGE_DIGEST #ifdef HAVE_ZLIB # include "GZipDecodingStreamFilter.h" #endif // HAVE_ZLIB @@ -395,7 +393,6 @@ void HttpResponse::getMetalinKHttpEntries( std::sort(result.begin(), result.end()); } -#ifdef ENABLE_MESSAGE_DIGEST // Digest header field is defined by // http://tools.ietf.org/html/rfc3230. void HttpResponse::getDigest(std::vector& result) const @@ -445,6 +442,5 @@ void HttpResponse::getDigest(std::vector& result) const } std::swap(temp, result); } -#endif // ENABLE_MESSAGE_DIGEST } // namespace aria2 diff --git a/src/HttpResponse.h b/src/HttpResponse.h index fabb6f7d..2e7b964a 100644 --- a/src/HttpResponse.h +++ b/src/HttpResponse.h @@ -125,13 +125,11 @@ public: void getMetalinKHttpEntries(std::vector& result, const std::shared_ptr