From 78eff232546a5fa6f48c151dc2343915ed94fa8c Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 3 Jul 2006 14:19:23 +0000 Subject: 2006-07-03 Tatsuhiro Tsujikawa To add Metalink support(http/ftp only): * src/AbstractCommand.h (tryReserved): New function. * src/AbstractCommand.cc (execute): Call tryReserved(). (tryReserved): New function. * src/Request.h (Requests): New type definition. * src/SegmentMan.h (reserved): New variable. * src/Util.h (fileChecksum): New function. (toUpper): New function. (toLower): New function. * src/Util.cc (messageDigest.h): Included. (trim): Trim \r\n\t. (fileChecksum): New function. (toUpper): New function. (toLower): New function. * src/main.cc (normalDownload): New function. (main): Added 2 command-line options: metalink-file, metalink-connection. Their usage has not been written yet. * src/MetalinkProcessor.h: New class. * src/Xml2MetalinkProcessor.h: New class. * src/Xml2MetalinkProcessor.cc: New class. * src/MetalinkEntry.h: New class. * src/MetalinkEntry.cc: New class. * src/MetalinkResource.h: New class. * src/MetalinkResource.cc: New class. To add md5 message digest checking: * src/messageDigest.h: Rewritten. * src/MultiDiskWriter.cc: Updated according to the changes in messageDigest.h. * src/ShaVisitor.cc: Updated according to the changes in messageDigest.h. * src/Util.cc: Updated according to the changes in messageDigest.h. * src/AbstractDiskWriter.cc: Updated according to the changes in messageDigest.h. To fix a bug that causes segfault when the payload length in peer message is less than 0: * src/PeerConnection.cc: (receiveMessage): Fixed the bug. * src/PeerMessageUtil.cc (checkLength): Throw an exception if length is less than or equals to 0. To add new interfaces to Base64 encoding/decoding: * src/Base64.h (part_encode): Changed the method signature. (encode): New function(overload). (decode): New function(overload). * src/Base64.cc (part_encode): Rewritten. (encode): Rewritten. (encode): New function(overload). To prevent a peer to download same piece if there is an error in checksum: * src/PieceMessage.cc (receivedAction): Call peerInteraction->abortPiece(). --- src/AbstractCommand.cc | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'src/AbstractCommand.cc') diff --git a/src/AbstractCommand.cc b/src/AbstractCommand.cc index 0de96354..a622959a 100644 --- a/src/AbstractCommand.cc +++ b/src/AbstractCommand.cc @@ -77,6 +77,7 @@ bool AbstractCommand::execute() { delete(err); req->resetUrl(); e->segmentMan->errors++; + tryReserved(); return true; } catch(DlRetryEx* err) { logger->error(MSG_RESTARTING_DOWNLOAD, err, cuid); @@ -90,6 +91,7 @@ bool AbstractCommand::execute() { if(isAbort) { logger->error(MSG_MAX_TRY, cuid, req->getTryCount()); e->segmentMan->errors++; + tryReserved(); return true; } else { return prepareForRetry(e->option->getAsInt(PREF_RETRY_WAIT)); @@ -97,6 +99,15 @@ bool AbstractCommand::execute() { } } +void AbstractCommand::tryReserved() { + if(!e->segmentMan->reserved.empty()) { + Request* req = e->segmentMan->reserved.front(); + e->segmentMan->reserved.pop_front(); + Command* command = InitiateConnectionCommandFactory::createInitiateConnectionCommand(cuid, req, e); + e->commands.push_back(command); + } +} + bool AbstractCommand::prepareForRetry(int wait) { Command* command = InitiateConnectionCommandFactory::createInitiateConnectionCommand(cuid, req, e); if(wait == 0) { -- cgit