2008-04-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Fixed compilation error without gcrypt/openssl.
	* src/DownloadCommand.cc
	* src/DownloadCommand.h
pull/1/head
Tatsuhiro Tsujikawa 2008-04-27 06:01:34 +00:00
parent b74e27ff92
commit 0f64c20da8
3 changed files with 11 additions and 11 deletions

View File

@ -1,3 +1,9 @@
2008-04-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Fixed compilation error without gcrypt/openssl.
* src/DownloadCommand.cc
* src/DownloadCommand.h
2008-04-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Reorganized version information so that it can be displayed in a

View File

@ -67,16 +67,13 @@ DownloadCommand::DownloadCommand(int cuid,
RequestGroup* requestGroup,
DownloadEngine* e,
const SocketHandle& s):
AbstractCommand(cuid, req, requestGroup, e, s),
#ifdef ENABLE_MESSAGE_DIGEST
_messageDigestContext(0)
#endif // ENABLE_MESSAGE_DIGEST
AbstractCommand(cuid, req, requestGroup, e, s)
{
#ifdef ENABLE_MESSAGE_DIGEST
{
std::string algo = _requestGroup->getDownloadContext()->getPieceHashAlgo();
if(MessageDigestContext::supports(algo)) {
_messageDigestContext = new MessageDigestContext();
_messageDigestContext.reset(new MessageDigestContext());
_messageDigestContext->trySetAlgo(algo);
_messageDigestContext->digestInit();
}
@ -93,9 +90,6 @@ DownloadCommand::DownloadCommand(int cuid,
DownloadCommand::~DownloadCommand() {
assert(peerStat.get());
peerStat->downloadStop();
#ifdef ENABLE_MESSAGE_DIGEST
delete _messageDigestContext;
#endif // ENABLE_MESSAGE_DIGEST
}
bool DownloadCommand::executeInternal() {
@ -202,12 +196,12 @@ void DownloadCommand::validatePieceHash(const SegmentHandle& segment)
#ifdef ENABLE_MESSAGE_DIGEST
std::string expectedPieceHash =
_requestGroup->getDownloadContext()->getPieceHash(segment->getIndex());
if(_messageDigestContext &&
if(!_messageDigestContext.isNull() &&
e->option->get(PREF_REALTIME_CHUNK_CHECKSUM) == V_TRUE &&
!expectedPieceHash.empty()) {
_messageDigestContext->digestReset();
std::string actualPieceHash =
MessageDigestHelper::digest(_messageDigestContext,
MessageDigestHelper::digest(_messageDigestContext.get(),
_requestGroup->getPieceStorage()->getDiskAdaptor(),
segment->getPosition(),
segment->getLength());

View File

@ -52,7 +52,7 @@ private:
unsigned int lowestDownloadSpeedLimit;
SharedHandle<PeerStat> peerStat;
#ifdef ENABLE_MESSAGE_DIGEST
MessageDigestContext* _messageDigestContext;
SharedHandle<MessageDigestContext> _messageDigestContext;
#endif // ENABLE_MESSAGE_DIGEST
void validatePieceHash(const SharedHandle<Segment>& segment);