mirror of https://github.com/aria2/aria2
Stuff memory holes
Padding changes on x86_64: - RequestGroup: 29 -> 5 bytes - DownloadContext: 25 -> 1 bytes - Cookie: 20 -> 4 bytes - Command: 8 -> 0 bytes (affects many derived as well) - HttpRequest: 20 -> 4 bytes - DownloadCommand: 18 -> 2 bytes - TimeBasedCommand: 14 -> 6 bytes - AbstractCommand: 13 -> 5 bytes - HttpSkipResponseCommand: 12 -> 4 bytes - FileEntry: 10 -> 2 bytes - DownloadResult: 15 -> 7 bytes - UriStruct: 12 -> 4 bytes - Piece: 11 -> 3 bytes - BitfieldMan -> 11 -> 3 bytespull/159/merge
parent
1323048ab1
commit
2db0c81fc8
|
@ -76,26 +76,29 @@
|
|||
|
||||
namespace aria2 {
|
||||
|
||||
AbstractCommand::AbstractCommand
|
||||
(cuid_t cuid,
|
||||
const std::shared_ptr<Request>& req,
|
||||
const std::shared_ptr<FileEntry>& fileEntry,
|
||||
RequestGroup* requestGroup,
|
||||
DownloadEngine* e,
|
||||
const std::shared_ptr<SocketCore>& s,
|
||||
const std::shared_ptr<SocketRecvBuffer>& socketRecvBuffer,
|
||||
bool incNumConnection)
|
||||
: Command(cuid), checkPoint_(global::wallclock()),
|
||||
timeout_(requestGroup->getTimeout()),
|
||||
requestGroup_(requestGroup),
|
||||
req_(req), fileEntry_(fileEntry), e_(e), socket_(s),
|
||||
AbstractCommand::AbstractCommand(cuid_t cuid,
|
||||
const std::shared_ptr<Request>& req,
|
||||
const std::shared_ptr<FileEntry>& fileEntry,
|
||||
RequestGroup* requestGroup, DownloadEngine* e,
|
||||
const std::shared_ptr<SocketCore>& s,
|
||||
const std::shared_ptr<SocketRecvBuffer>& socketRecvBuffer,
|
||||
bool incNumConnection)
|
||||
: Command(cuid),
|
||||
req_(req),
|
||||
fileEntry_(fileEntry),
|
||||
socket_(s),
|
||||
socketRecvBuffer_(socketRecvBuffer),
|
||||
#ifdef ENABLE_ASYNC_DNS
|
||||
asyncNameResolverMan_(make_unique<AsyncNameResolverMan>()),
|
||||
#endif // ENABLE_ASYNC_DNS
|
||||
checkSocketIsReadable_(false), checkSocketIsWritable_(false),
|
||||
incNumConnection_(incNumConnection),
|
||||
serverStatTimer_(global::wallclock())
|
||||
requestGroup_(requestGroup),
|
||||
e_(e),
|
||||
checkPoint_(global::wallclock()),
|
||||
serverStatTimer_(global::wallclock()),
|
||||
timeout_(requestGroup->getTimeout()),
|
||||
checkSocketIsReadable_(false),
|
||||
checkSocketIsWritable_(false),
|
||||
incNumConnection_(incNumConnection)
|
||||
{
|
||||
if(socket_ && socket_->isOpen()) {
|
||||
setReadCheckSocket(socket_);
|
||||
|
|
|
@ -64,31 +64,34 @@ class AsyncNameResolverMan;
|
|||
|
||||
class AbstractCommand : public Command {
|
||||
private:
|
||||
Timer checkPoint_;
|
||||
time_t timeout_;
|
||||
|
||||
RequestGroup* requestGroup_;
|
||||
std::shared_ptr<Request> req_;
|
||||
std::shared_ptr<FileEntry> fileEntry_;
|
||||
DownloadEngine* e_;
|
||||
std::shared_ptr<SocketCore> socket_;
|
||||
std::shared_ptr<SocketRecvBuffer> socketRecvBuffer_;
|
||||
std::vector<std::shared_ptr<Segment> > segments_;
|
||||
std::shared_ptr<SocketCore> readCheckTarget_;
|
||||
std::shared_ptr<SocketCore> writeCheckTarget_;
|
||||
|
||||
#ifdef ENABLE_ASYNC_DNS
|
||||
std::unique_ptr<AsyncNameResolverMan> asyncNameResolverMan_;
|
||||
#endif // ENABLE_ASYNC_DNS
|
||||
|
||||
RequestGroup* requestGroup_;
|
||||
DownloadEngine* e_;
|
||||
|
||||
std::vector<std::shared_ptr<Segment> > segments_;
|
||||
|
||||
Timer checkPoint_;
|
||||
Timer serverStatTimer_;
|
||||
time_t timeout_;
|
||||
|
||||
bool checkSocketIsReadable_;
|
||||
bool checkSocketIsWritable_;
|
||||
std::shared_ptr<SocketCore> readCheckTarget_;
|
||||
std::shared_ptr<SocketCore> writeCheckTarget_;
|
||||
|
||||
bool incNumConnection_;
|
||||
Timer serverStatTimer_;
|
||||
|
||||
int32_t calculateMinSplitSize() const;
|
||||
void useFasterRequest(const std::shared_ptr<Request>& fasterRequest);
|
||||
|
||||
public:
|
||||
RequestGroup* getRequestGroup() const
|
||||
{
|
||||
|
@ -234,13 +237,12 @@ protected:
|
|||
}
|
||||
|
||||
public:
|
||||
AbstractCommand
|
||||
(cuid_t cuid, const std::shared_ptr<Request>& req,
|
||||
const std::shared_ptr<FileEntry>& fileEntry,
|
||||
RequestGroup* requestGroup, DownloadEngine* e,
|
||||
const std::shared_ptr<SocketCore>& s = nullptr,
|
||||
const std::shared_ptr<SocketRecvBuffer>& socketRecvBuffer = nullptr,
|
||||
bool incNumConnection = true);
|
||||
AbstractCommand(cuid_t cuid, const std::shared_ptr<Request>& req,
|
||||
const std::shared_ptr<FileEntry>& fileEntry,
|
||||
RequestGroup* requestGroup, DownloadEngine* e,
|
||||
const std::shared_ptr<SocketCore>& s = nullptr,
|
||||
const std::shared_ptr<SocketRecvBuffer>& socketRecvBuffer = nullptr,
|
||||
bool incNumConnection = true);
|
||||
|
||||
virtual ~AbstractCommand();
|
||||
virtual bool execute() CXX11_OVERRIDE;
|
||||
|
|
|
@ -45,19 +45,19 @@ using namespace aria2::expr;
|
|||
namespace aria2 {
|
||||
|
||||
BitfieldMan::BitfieldMan(int32_t blockLength, int64_t totalLength)
|
||||
:blockLength_(blockLength),
|
||||
totalLength_(totalLength),
|
||||
bitfieldLength_(0),
|
||||
blocks_(0),
|
||||
filterEnabled_(false),
|
||||
bitfield_(nullptr),
|
||||
useBitfield_(nullptr),
|
||||
filterBitfield_(nullptr),
|
||||
cachedNumMissingBlock_(0),
|
||||
cachedNumFilteredBlock_(0),
|
||||
cachedCompletedLength_(0),
|
||||
cachedFilteredCompletedLength_(0),
|
||||
cachedFilteredTotalLength_(0)
|
||||
: totalLength_(totalLength),
|
||||
cachedCompletedLength_(0),
|
||||
cachedFilteredCompletedLength_(0),
|
||||
cachedFilteredTotalLength_(0),
|
||||
bitfield_(nullptr),
|
||||
useBitfield_(nullptr),
|
||||
filterBitfield_(nullptr),
|
||||
bitfieldLength_(0),
|
||||
cachedNumMissingBlock_(0),
|
||||
cachedNumFilteredBlock_(0),
|
||||
blocks_(0),
|
||||
blockLength_(blockLength),
|
||||
filterEnabled_(false)
|
||||
{
|
||||
if(blockLength_ > 0 && totalLength_ > 0) {
|
||||
blocks_ = (totalLength_+blockLength_-1)/blockLength_;
|
||||
|
@ -71,19 +71,19 @@ BitfieldMan::BitfieldMan(int32_t blockLength, int64_t totalLength)
|
|||
}
|
||||
|
||||
BitfieldMan::BitfieldMan(const BitfieldMan& bitfieldMan)
|
||||
:blockLength_(bitfieldMan.blockLength_),
|
||||
totalLength_(bitfieldMan.totalLength_),
|
||||
bitfieldLength_(bitfieldMan.bitfieldLength_),
|
||||
blocks_(bitfieldMan.blocks_),
|
||||
filterEnabled_(bitfieldMan.filterEnabled_),
|
||||
bitfield_(new unsigned char[bitfieldLength_]),
|
||||
useBitfield_(new unsigned char[bitfieldLength_]),
|
||||
filterBitfield_(nullptr),
|
||||
cachedNumMissingBlock_(0),
|
||||
cachedNumFilteredBlock_(0),
|
||||
cachedCompletedLength_(0),
|
||||
cachedFilteredCompletedLength_(0),
|
||||
cachedFilteredTotalLength_(0)
|
||||
: totalLength_(bitfieldMan.totalLength_),
|
||||
cachedCompletedLength_(0),
|
||||
cachedFilteredCompletedLength_(0),
|
||||
cachedFilteredTotalLength_(0),
|
||||
bitfield_(new unsigned char[bitfieldMan.bitfieldLength_]),
|
||||
useBitfield_(new unsigned char[bitfieldMan.bitfieldLength_]),
|
||||
filterBitfield_(nullptr),
|
||||
bitfieldLength_(bitfieldMan.bitfieldLength_),
|
||||
cachedNumMissingBlock_(0),
|
||||
cachedNumFilteredBlock_(0),
|
||||
blocks_(bitfieldMan.blocks_),
|
||||
blockLength_(bitfieldMan.blockLength_),
|
||||
filterEnabled_(bitfieldMan.filterEnabled_)
|
||||
{
|
||||
memcpy(bitfield_, bitfieldMan.bitfield_, bitfieldLength_);
|
||||
memcpy(useBitfield_, bitfieldMan.useBitfield_, bitfieldLength_);
|
||||
|
@ -97,8 +97,8 @@ BitfieldMan::BitfieldMan(const BitfieldMan& bitfieldMan)
|
|||
BitfieldMan& BitfieldMan::operator=(const BitfieldMan& bitfieldMan)
|
||||
{
|
||||
if(this != &bitfieldMan) {
|
||||
blockLength_ = bitfieldMan.blockLength_;
|
||||
totalLength_ = bitfieldMan.totalLength_;
|
||||
blockLength_ = bitfieldMan.blockLength_;
|
||||
blocks_ = bitfieldMan.blocks_;
|
||||
bitfieldLength_ = bitfieldMan.bitfieldLength_;
|
||||
filterEnabled_ = bitfieldMan.filterEnabled_;
|
||||
|
|
|
@ -43,21 +43,23 @@ namespace aria2 {
|
|||
|
||||
class BitfieldMan {
|
||||
private:
|
||||
int32_t blockLength_;
|
||||
int64_t totalLength_;
|
||||
size_t bitfieldLength_;
|
||||
size_t blocks_;
|
||||
bool filterEnabled_;
|
||||
int64_t cachedCompletedLength_;
|
||||
int64_t cachedFilteredCompletedLength_;
|
||||
int64_t cachedFilteredTotalLength_;
|
||||
|
||||
unsigned char* bitfield_;
|
||||
unsigned char* useBitfield_;
|
||||
unsigned char* filterBitfield_;
|
||||
|
||||
// for caching
|
||||
size_t bitfieldLength_;
|
||||
size_t cachedNumMissingBlock_;
|
||||
size_t cachedNumFilteredBlock_;
|
||||
int64_t cachedCompletedLength_;
|
||||
int64_t cachedFilteredCompletedLength_;
|
||||
int64_t cachedFilteredTotalLength_;
|
||||
size_t blocks_;
|
||||
|
||||
int32_t blockLength_;
|
||||
|
||||
bool filterEnabled_;
|
||||
|
||||
bool setBitInternal(unsigned char* bitfield, size_t index, bool on);
|
||||
bool setFilterBit(size_t index);
|
||||
|
@ -70,6 +72,7 @@ private:
|
|||
// If filterBitfield_ is 0, allocate bitfieldLength_ bytes to it and
|
||||
// set 0 to all bytes.
|
||||
void ensureFilterBitfield();
|
||||
|
||||
public:
|
||||
// [startIndex, endIndex)
|
||||
struct Range {
|
||||
|
@ -81,6 +84,7 @@ public:
|
|||
bool operator<(const Range& range) const;
|
||||
bool operator==(const Range& range) const;
|
||||
};
|
||||
|
||||
public:
|
||||
BitfieldMan(int32_t blockLength, int64_t totalLength);
|
||||
BitfieldMan(const BitfieldMan& bitfieldMan);
|
||||
|
|
|
@ -38,8 +38,8 @@
|
|||
namespace aria2 {
|
||||
|
||||
Command::Command(cuid_t cuid)
|
||||
: status_(STATUS_INACTIVE),
|
||||
cuid_(cuid),
|
||||
: cuid_(cuid),
|
||||
status_(STATUS_INACTIVE),
|
||||
readEvent_(false),
|
||||
writeEvent_(false),
|
||||
errorEvent_(false),
|
||||
|
|
|
@ -50,15 +50,17 @@ public:
|
|||
STATUS_REALTIME,
|
||||
STATUS_ONESHOT_REALTIME
|
||||
};
|
||||
private:
|
||||
STATUS status_;
|
||||
|
||||
private:
|
||||
cuid_t cuid_;
|
||||
|
||||
STATUS status_;
|
||||
|
||||
bool readEvent_;
|
||||
bool writeEvent_;
|
||||
bool errorEvent_;
|
||||
bool hupEvent_;
|
||||
|
||||
protected:
|
||||
bool readEventEnabled() const
|
||||
{
|
||||
|
@ -79,6 +81,7 @@ protected:
|
|||
{
|
||||
return hupEvent_;
|
||||
}
|
||||
|
||||
public:
|
||||
Command(cuid_t cuid);
|
||||
|
||||
|
|
|
@ -42,37 +42,32 @@
|
|||
|
||||
namespace aria2 {
|
||||
|
||||
Cookie::Cookie
|
||||
(std::string name,
|
||||
std::string value,
|
||||
time_t expiryTime,
|
||||
bool persistent,
|
||||
std::string domain,
|
||||
bool hostOnly,
|
||||
std::string path,
|
||||
bool secure,
|
||||
bool httpOnly,
|
||||
time_t creationTime):
|
||||
name_(std::move(name)),
|
||||
value_(std::move(value)),
|
||||
expiryTime_(expiryTime),
|
||||
persistent_(persistent),
|
||||
domain_(std::move(domain)),
|
||||
hostOnly_(hostOnly),
|
||||
path_(std::move(path)),
|
||||
secure_(secure),
|
||||
httpOnly_(httpOnly),
|
||||
creationTime_(creationTime),
|
||||
lastAccessTime_(creationTime) {}
|
||||
Cookie::Cookie(std::string name, std::string value, time_t expiryTime,
|
||||
bool persistent, std::string domain, bool hostOnly,
|
||||
std::string path, bool secure, bool httpOnly,
|
||||
time_t creationTime)
|
||||
: expiryTime_(expiryTime),
|
||||
creationTime_(creationTime),
|
||||
lastAccessTime_(creationTime),
|
||||
name_(std::move(name)),
|
||||
value_(std::move(value)),
|
||||
domain_(std::move(domain)),
|
||||
path_(std::move(path)),
|
||||
persistent_(persistent),
|
||||
hostOnly_(hostOnly),
|
||||
secure_(secure),
|
||||
httpOnly_(httpOnly)
|
||||
{}
|
||||
|
||||
Cookie::Cookie():
|
||||
expiryTime_(0),
|
||||
persistent_(false),
|
||||
hostOnly_(false),
|
||||
secure_(false),
|
||||
httpOnly_(false),
|
||||
creationTime_(0),
|
||||
lastAccessTime_(0) {}
|
||||
Cookie::Cookie()
|
||||
: expiryTime_(0),
|
||||
creationTime_(0),
|
||||
lastAccessTime_(0),
|
||||
persistent_(false),
|
||||
hostOnly_(false),
|
||||
secure_(false),
|
||||
httpOnly_(false)
|
||||
{}
|
||||
|
||||
std::string Cookie::toString() const
|
||||
{
|
||||
|
@ -82,10 +77,9 @@ std::string Cookie::toString() const
|
|||
return s;
|
||||
}
|
||||
|
||||
bool Cookie::match
|
||||
(const std::string& requestHost,
|
||||
const std::string& requestPath,
|
||||
time_t date, bool secure) const
|
||||
bool Cookie::match(const std::string& requestHost,
|
||||
const std::string& requestPath,
|
||||
time_t date, bool secure) const
|
||||
{
|
||||
if((secure_ && !secure) || isExpired(date) ||
|
||||
!cookie::pathMatch(requestPath, path_)) {
|
||||
|
|
31
src/Cookie.h
31
src/Cookie.h
|
@ -45,40 +45,31 @@ namespace aria2 {
|
|||
|
||||
class Cookie {
|
||||
private:
|
||||
time_t expiryTime_;
|
||||
time_t creationTime_;
|
||||
time_t lastAccessTime_;
|
||||
std::string name_;
|
||||
std::string value_;
|
||||
time_t expiryTime_;
|
||||
std::string domain_;
|
||||
std::string path_;
|
||||
// If persistent_ is false, this is a session scope cookie and it is
|
||||
// never expired during session. So isExpired() always returns
|
||||
// false.
|
||||
bool persistent_;
|
||||
std::string domain_;
|
||||
bool hostOnly_;
|
||||
std::string path_;
|
||||
bool secure_;
|
||||
bool httpOnly_;
|
||||
time_t creationTime_;
|
||||
time_t lastAccessTime_;
|
||||
|
||||
public:
|
||||
Cookie();
|
||||
|
||||
Cookie
|
||||
(std::string name,
|
||||
std::string value,
|
||||
time_t expiryTime,
|
||||
bool persistent,
|
||||
std::string domain,
|
||||
bool hostOnly,
|
||||
std::string path,
|
||||
bool secure,
|
||||
bool httpOnly,
|
||||
time_t creationTime);
|
||||
Cookie(std::string name, std::string value, time_t expiryTime,
|
||||
bool persistent, std::string domain, bool hostOnly, std::string path,
|
||||
bool secure, bool httpOnly, time_t creationTime);
|
||||
|
||||
std::string toString() const;
|
||||
|
||||
bool match
|
||||
(const std::string& requestHost, const std::string& requestPath,
|
||||
time_t date, bool secure) const;
|
||||
bool match(const std::string& requestHost, const std::string& requestPath,
|
||||
time_t date, bool secure) const;
|
||||
|
||||
bool operator==(const Cookie& cookie) const;
|
||||
|
||||
|
|
|
@ -79,14 +79,12 @@ namespace {
|
|||
const size_t BUFSIZE = 16*1024;
|
||||
} // namespace
|
||||
|
||||
DownloadCommand::DownloadCommand
|
||||
(cuid_t cuid,
|
||||
const std::shared_ptr<Request>& req,
|
||||
const std::shared_ptr<FileEntry>& fileEntry,
|
||||
RequestGroup* requestGroup,
|
||||
DownloadEngine* e,
|
||||
const std::shared_ptr<SocketCore>& s,
|
||||
const std::shared_ptr<SocketRecvBuffer>& socketRecvBuffer)
|
||||
DownloadCommand::DownloadCommand(cuid_t cuid,
|
||||
const std::shared_ptr<Request>& req,
|
||||
const std::shared_ptr<FileEntry>& fileEntry,
|
||||
RequestGroup* requestGroup, DownloadEngine* e,
|
||||
const std::shared_ptr<SocketCore>& s,
|
||||
const std::shared_ptr<SocketRecvBuffer>& socketRecvBuffer)
|
||||
: AbstractCommand(cuid, req, fileEntry, requestGroup, e, s, socketRecvBuffer),
|
||||
startupIdleTime_(10),
|
||||
lowestDownloadSpeedLimit_(0),
|
||||
|
|
|
@ -49,17 +49,21 @@ class MessageDigest;
|
|||
|
||||
class DownloadCommand : public AbstractCommand {
|
||||
private:
|
||||
time_t startupIdleTime_;
|
||||
int lowestDownloadSpeedLimit_;
|
||||
std::shared_ptr<PeerStat> peerStat_;
|
||||
|
||||
std::unique_ptr<StreamFilter> streamFilter_;
|
||||
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
std::unique_ptr<MessageDigest> messageDigest_;
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
|
||||
time_t startupIdleTime_;
|
||||
|
||||
int lowestDownloadSpeedLimit_;
|
||||
|
||||
bool pieceHashValidationEnabled_;
|
||||
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
|
||||
std::unique_ptr<MessageDigest> messageDigest_;
|
||||
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
bool sinkFilterOnly_;
|
||||
|
||||
void validatePieceHash(const std::shared_ptr<Segment>& segment,
|
||||
const std::string& expectedPieceHash,
|
||||
|
@ -69,9 +73,6 @@ private:
|
|||
|
||||
void completeSegment(cuid_t cuid, const std::shared_ptr<Segment>& segment);
|
||||
|
||||
std::unique_ptr<StreamFilter> streamFilter_;
|
||||
|
||||
bool sinkFilterOnly_;
|
||||
protected:
|
||||
virtual bool executeInternal() CXX11_OVERRIDE;
|
||||
|
||||
|
|
|
@ -47,25 +47,26 @@
|
|||
|
||||
namespace aria2 {
|
||||
|
||||
DownloadContext::DownloadContext():
|
||||
pieceLength_(0),
|
||||
checksumVerified_(false),
|
||||
knowsTotalLength_(true),
|
||||
ownerRequestGroup_(nullptr),
|
||||
attrs_(MAX_CTX_ATTR),
|
||||
downloadStopTime_(0),
|
||||
acceptMetalink_(true) {}
|
||||
DownloadContext::DownloadContext()
|
||||
: ownerRequestGroup_(nullptr),
|
||||
attrs_(MAX_CTX_ATTR),
|
||||
downloadStopTime_(0),
|
||||
pieceLength_(0),
|
||||
checksumVerified_(false),
|
||||
knowsTotalLength_(true),
|
||||
acceptMetalink_(true)
|
||||
{}
|
||||
|
||||
DownloadContext::DownloadContext(int32_t pieceLength,
|
||||
int64_t totalLength,
|
||||
const std::string& path):
|
||||
pieceLength_(pieceLength),
|
||||
checksumVerified_(false),
|
||||
knowsTotalLength_(true),
|
||||
ownerRequestGroup_(nullptr),
|
||||
attrs_(MAX_CTX_ATTR),
|
||||
downloadStopTime_(0),
|
||||
acceptMetalink_(true)
|
||||
const std::string& path)
|
||||
: ownerRequestGroup_(nullptr),
|
||||
attrs_(MAX_CTX_ATTR),
|
||||
downloadStopTime_(0),
|
||||
pieceLength_(pieceLength),
|
||||
checksumVerified_(false),
|
||||
knowsTotalLength_(true),
|
||||
acceptMetalink_(true)
|
||||
{
|
||||
std::shared_ptr<FileEntry> fileEntry(new FileEntry(path, totalLength, 0));
|
||||
fileEntries_.push_back(fileEntry);
|
||||
|
|
|
@ -58,11 +58,19 @@ class FileEntry;
|
|||
class DownloadContext
|
||||
{
|
||||
private:
|
||||
std::unique_ptr<Signature> signature_;
|
||||
|
||||
RequestGroup* ownerRequestGroup_;
|
||||
|
||||
std::vector<std::unique_ptr<ContextAttribute> > attrs_;
|
||||
|
||||
std::vector<std::shared_ptr<FileEntry> > fileEntries_;
|
||||
|
||||
std::vector<std::string> pieceHashes_;
|
||||
|
||||
int32_t pieceLength_;
|
||||
NetStat netStat_;
|
||||
|
||||
Timer downloadStopTime_;
|
||||
|
||||
std::string pieceHashType_;
|
||||
|
||||
|
@ -70,24 +78,18 @@ private:
|
|||
|
||||
std::string hashType_;
|
||||
|
||||
bool checksumVerified_;
|
||||
|
||||
std::string basePath_;
|
||||
|
||||
int32_t pieceLength_;
|
||||
|
||||
bool checksumVerified_;
|
||||
|
||||
bool knowsTotalLength_;
|
||||
|
||||
RequestGroup* ownerRequestGroup_;
|
||||
|
||||
std::vector<std::unique_ptr<ContextAttribute> > attrs_;
|
||||
|
||||
NetStat netStat_;
|
||||
|
||||
Timer downloadStopTime_;
|
||||
|
||||
std::unique_ptr<Signature> signature_;
|
||||
// This member variable is required to avoid to use parse Metalink
|
||||
// (including both Metalink XML and Metalink/HTTP) twice.
|
||||
bool acceptMetalink_;
|
||||
|
||||
public:
|
||||
DownloadContext();
|
||||
|
||||
|
|
|
@ -40,17 +40,16 @@
|
|||
namespace aria2 {
|
||||
|
||||
DownloadResult::DownloadResult()
|
||||
: gid(nullptr),
|
||||
inMemoryDownload(false),
|
||||
: belongsTo(0),
|
||||
sessionDownloadLength(0),
|
||||
sessionTime(0),
|
||||
result(error_code::UNDEFINED),
|
||||
belongsTo(0),
|
||||
totalLength(0),
|
||||
completedLength(0),
|
||||
uploadLength(0),
|
||||
numPieces(0),
|
||||
pieceLength(0),
|
||||
numPieces(0)
|
||||
result(error_code::UNDEFINED),
|
||||
inMemoryDownload(false)
|
||||
{}
|
||||
|
||||
DownloadResult::~DownloadResult() {}
|
||||
|
|
|
@ -54,46 +54,46 @@ class MetadataInfo;
|
|||
|
||||
struct DownloadResult
|
||||
{
|
||||
std::shared_ptr<GroupId> gid;
|
||||
|
||||
std::vector<std::shared_ptr<FileEntry> > fileEntries;
|
||||
|
||||
bool inMemoryDownload;
|
||||
// This field contains GID. See comment in
|
||||
// RequestGroup.cc::belongsToGID_.
|
||||
a2_gid_t belongsTo;
|
||||
|
||||
uint64_t sessionDownloadLength;
|
||||
|
||||
// milliseconds
|
||||
int64_t sessionTime;
|
||||
|
||||
error_code::Value result;
|
||||
|
||||
// This field contains GIDs. See comment in
|
||||
// RequestGroup.cc::followedByGIDs_.
|
||||
std::vector<a2_gid_t> followedBy;
|
||||
|
||||
// This field contains GID. See comment in
|
||||
// RequestGroup.cc::belongsToGID_.
|
||||
a2_gid_t belongsTo;
|
||||
|
||||
std::shared_ptr<Option> option;
|
||||
|
||||
std::shared_ptr<MetadataInfo> metadataInfo;
|
||||
|
||||
int64_t totalLength;
|
||||
|
||||
int64_t completedLength;
|
||||
|
||||
int64_t uploadLength;
|
||||
|
||||
std::shared_ptr<GroupId> gid;
|
||||
|
||||
std::shared_ptr<Option> option;
|
||||
|
||||
std::shared_ptr<MetadataInfo> metadataInfo;
|
||||
|
||||
std::vector<std::shared_ptr<FileEntry> > fileEntries;
|
||||
|
||||
// This field contains GIDs. See comment in
|
||||
// RequestGroup.cc::followedByGIDs_.
|
||||
std::vector<a2_gid_t> followedBy;
|
||||
|
||||
std::string bitfield;
|
||||
|
||||
std::string infoHash;
|
||||
|
||||
int32_t pieceLength;
|
||||
std::string dir;
|
||||
|
||||
size_t numPieces;
|
||||
|
||||
std::string dir;
|
||||
int32_t pieceLength;
|
||||
|
||||
error_code::Value result;
|
||||
|
||||
bool inMemoryDownload;
|
||||
|
||||
DownloadResult();
|
||||
~DownloadResult();
|
||||
|
|
|
@ -66,27 +66,24 @@ bool FileEntry::RequestFaster::operator()
|
|||
return lspd > rspd || (lspd == rspd && lhs.get() < rhs.get());
|
||||
}
|
||||
|
||||
FileEntry::FileEntry
|
||||
(const std::string& path,
|
||||
int64_t length,
|
||||
int64_t offset,
|
||||
const std::vector<std::string>& uris)
|
||||
: path_(path),
|
||||
uris_(uris.begin(), uris.end()),
|
||||
length_(length),
|
||||
FileEntry::FileEntry(const std::string& path, int64_t length, int64_t offset,
|
||||
const std::vector<std::string>& uris)
|
||||
: length_(length),
|
||||
offset_(offset),
|
||||
requested_(true),
|
||||
uniqueProtocol_(false),
|
||||
uris_(uris.begin(), uris.end()),
|
||||
path_(path),
|
||||
lastFasterReplace_(0),
|
||||
maxConnectionPerServer_(1),
|
||||
lastFasterReplace_(0)
|
||||
requested_(true),
|
||||
uniqueProtocol_(false)
|
||||
{}
|
||||
|
||||
FileEntry::FileEntry()
|
||||
: length_(0),
|
||||
offset_(0),
|
||||
maxConnectionPerServer_(1),
|
||||
requested_(false),
|
||||
uniqueProtocol_(false),
|
||||
maxConnectionPerServer_(1)
|
||||
uniqueProtocol_(false)
|
||||
{}
|
||||
|
||||
FileEntry::~FileEntry() {}
|
||||
|
|
|
@ -62,31 +62,35 @@ class FileEntry {
|
|||
public:
|
||||
typedef std::set<std::shared_ptr<Request>, RefLess<Request> >
|
||||
InFlightRequestSet;
|
||||
private:
|
||||
std::string path_;
|
||||
std::deque<std::string> uris_;
|
||||
std::deque<std::string> spentUris_;
|
||||
int64_t length_;
|
||||
int64_t offset_;
|
||||
bool requested_;
|
||||
|
||||
private:
|
||||
class RequestFaster {
|
||||
public:
|
||||
bool operator()(const std::shared_ptr<Request>& lhs,
|
||||
const std::shared_ptr<Request>& rhs) const;
|
||||
};
|
||||
|
||||
typedef std::set<std::shared_ptr<Request>, RequestFaster> RequestPool;
|
||||
RequestPool requestPool_;
|
||||
InFlightRequestSet inFlightRequests_;
|
||||
std::string contentType_;
|
||||
|
||||
int64_t length_;
|
||||
int64_t offset_;
|
||||
|
||||
std::deque<std::string> uris_;
|
||||
std::deque<std::string> spentUris_;
|
||||
// URIResult is stored in the ascending order of the time when its result is
|
||||
// available.
|
||||
std::deque<URIResult> uriResults_;
|
||||
bool uniqueProtocol_;
|
||||
int maxConnectionPerServer_;
|
||||
RequestPool requestPool_;
|
||||
InFlightRequestSet inFlightRequests_;
|
||||
|
||||
std::string path_;
|
||||
std::string contentType_;
|
||||
std::string originalName_;
|
||||
|
||||
Timer lastFasterReplace_;
|
||||
int maxConnectionPerServer_;
|
||||
|
||||
bool requested_;
|
||||
bool uniqueProtocol_;
|
||||
|
||||
void storePool(const std::shared_ptr<Request>& request);
|
||||
public:
|
||||
|
|
|
@ -58,15 +58,15 @@ namespace aria2 {
|
|||
const std::string HttpRequest::USER_AGENT("aria2");
|
||||
|
||||
HttpRequest::HttpRequest()
|
||||
: contentEncodingEnabled_(true),
|
||||
userAgent_(USER_AGENT),
|
||||
acceptMetalink_(false),
|
||||
cookieStorage_(nullptr),
|
||||
: cookieStorage_(nullptr),
|
||||
authConfigFactory_(nullptr),
|
||||
option_(nullptr),
|
||||
endOffsetOverride_(0),
|
||||
userAgent_(USER_AGENT),
|
||||
contentEncodingEnabled_(true),
|
||||
acceptMetalink_(false),
|
||||
noCache_(true),
|
||||
acceptGzip_(false),
|
||||
endOffsetOverride_(0)
|
||||
acceptGzip_(false)
|
||||
{}
|
||||
|
||||
HttpRequest::~HttpRequest() {}
|
||||
|
|
|
@ -65,14 +65,9 @@ private:
|
|||
|
||||
std::shared_ptr<Segment> segment_;
|
||||
|
||||
bool contentEncodingEnabled_;
|
||||
std::shared_ptr<Request> proxyRequest_;
|
||||
|
||||
std::string userAgent_;
|
||||
|
||||
std::vector<std::string> headers_;
|
||||
|
||||
// If true, metalink content types are sent in Accept header field.
|
||||
bool acceptMetalink_;
|
||||
std::unique_ptr<AuthConfig> authConfig_;
|
||||
|
||||
CookieStorage* cookieStorage_;
|
||||
|
||||
|
@ -80,14 +75,6 @@ private:
|
|||
|
||||
const Option* option_;
|
||||
|
||||
std::unique_ptr<AuthConfig> authConfig_;
|
||||
|
||||
std::shared_ptr<Request> proxyRequest_;
|
||||
|
||||
bool noCache_;
|
||||
|
||||
bool acceptGzip_;
|
||||
|
||||
// Historically, aria2 did not specify end byte marker unless http
|
||||
// pipelining is enabled. Sometimes end byte is known because the
|
||||
// segment/piece ahead of this request was already acquired. In this
|
||||
|
@ -97,9 +84,23 @@ private:
|
|||
// bytes and it is also true if it is used via HTTP proxy.
|
||||
int64_t endOffsetOverride_;
|
||||
|
||||
std::vector<std::string> headers_;
|
||||
|
||||
std::string userAgent_;
|
||||
|
||||
std::string ifModSinceHeader_;
|
||||
|
||||
bool contentEncodingEnabled_;
|
||||
|
||||
// If true, metalink content types are sent in Accept header field.
|
||||
bool acceptMetalink_;
|
||||
|
||||
bool noCache_;
|
||||
|
||||
bool acceptGzip_;
|
||||
|
||||
std::pair<std::string, std::string> getProxyAuthString() const;
|
||||
|
||||
public:
|
||||
HttpRequest();
|
||||
~HttpRequest();
|
||||
|
|
|
@ -74,12 +74,12 @@ HttpSkipResponseCommand::HttpSkipResponseCommand
|
|||
const std::shared_ptr<SocketCore>& s)
|
||||
: AbstractCommand(cuid, req, fileEntry, requestGroup, e, s,
|
||||
httpConnection->getSocketRecvBuffer()),
|
||||
httpConnection_(httpConnection),
|
||||
httpResponse_(std::move(httpResponse)),
|
||||
streamFilter_(new NullSinkStreamFilter()),
|
||||
sinkFilterOnly_(true),
|
||||
totalLength_(httpResponse_->getEntityLength()),
|
||||
receivedBytes_(0)
|
||||
receivedBytes_(0),
|
||||
httpConnection_(httpConnection),
|
||||
httpResponse_(std::move(httpResponse)),
|
||||
streamFilter_(new NullSinkStreamFilter())
|
||||
{
|
||||
checkSocketRecvBuffer();
|
||||
}
|
||||
|
|
|
@ -45,11 +45,7 @@ class StreamFilter;
|
|||
|
||||
class HttpSkipResponseCommand : public AbstractCommand {
|
||||
private:
|
||||
std::shared_ptr<HttpConnection> httpConnection_;
|
||||
|
||||
std::unique_ptr<HttpResponse> httpResponse_;
|
||||
|
||||
std::unique_ptr<StreamFilter> streamFilter_;
|
||||
// hole from AbstractCommand (5 bytes on x86_64)
|
||||
|
||||
bool sinkFilterOnly_;
|
||||
|
||||
|
@ -57,21 +53,27 @@ private:
|
|||
|
||||
int64_t receivedBytes_;
|
||||
|
||||
std::shared_ptr<HttpConnection> httpConnection_;
|
||||
|
||||
std::unique_ptr<HttpResponse> httpResponse_;
|
||||
|
||||
std::unique_ptr<StreamFilter> streamFilter_;
|
||||
|
||||
bool processResponse();
|
||||
|
||||
void poolConnection() const;
|
||||
|
||||
protected:
|
||||
virtual bool executeInternal() CXX11_OVERRIDE;
|
||||
|
||||
public:
|
||||
HttpSkipResponseCommand
|
||||
(cuid_t cuid,
|
||||
const std::shared_ptr<Request>& req,
|
||||
const std::shared_ptr<FileEntry>& fileEntry,
|
||||
RequestGroup* requestGroup,
|
||||
const std::shared_ptr<HttpConnection>& httpConnection,
|
||||
std::unique_ptr<HttpResponse> httpResponse,
|
||||
DownloadEngine* e,
|
||||
const std::shared_ptr<SocketCore>& s);
|
||||
HttpSkipResponseCommand(cuid_t cuid, const std::shared_ptr<Request>& req,
|
||||
const std::shared_ptr<FileEntry>& fileEntry,
|
||||
RequestGroup* requestGroup,
|
||||
const std::shared_ptr<HttpConnection>& httpConnection,
|
||||
std::unique_ptr<HttpResponse> httpResponse,
|
||||
DownloadEngine* e,
|
||||
const std::shared_ptr<SocketCore>& s);
|
||||
|
||||
virtual ~HttpSkipResponseCommand();
|
||||
|
||||
|
|
20
src/Piece.cc
20
src/Piece.cc
|
@ -52,22 +52,28 @@
|
|||
|
||||
namespace aria2 {
|
||||
|
||||
Piece::Piece():index_(0), length_(0), blockLength_(BLOCK_LENGTH), bitfield_(nullptr),
|
||||
usedBySegment_(false), wrCache_(nullptr)
|
||||
Piece::Piece()
|
||||
: bitfield_(nullptr),
|
||||
wrCache_(nullptr),
|
||||
index_(0),
|
||||
length_(0),
|
||||
blockLength_(BLOCK_LENGTH),
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
, nextBegin_(0)
|
||||
nextBegin_(0),
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
usedBySegment_(false)
|
||||
{}
|
||||
|
||||
Piece::Piece(size_t index, int32_t length, int32_t blockLength)
|
||||
: index_(index),
|
||||
: bitfield_(new BitfieldMan(blockLength, length)),
|
||||
wrCache_(nullptr),
|
||||
index_(index),
|
||||
length_(length),
|
||||
blockLength_(blockLength),
|
||||
bitfield_(new BitfieldMan(blockLength_, length)),
|
||||
usedBySegment_(false), wrCache_(nullptr)
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
,nextBegin_(0)
|
||||
nextBegin_(0),
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
usedBySegment_(false)
|
||||
{}
|
||||
|
||||
Piece::~Piece()
|
||||
|
|
31
src/Piece.h
31
src/Piece.h
|
@ -59,32 +59,33 @@ class MessageDigest;
|
|||
|
||||
class Piece {
|
||||
private:
|
||||
size_t index_;
|
||||
int32_t length_;
|
||||
int32_t blockLength_;
|
||||
BitfieldMan* bitfield_;
|
||||
std::vector<cuid_t> users_;
|
||||
bool usedBySegment_;
|
||||
WrDiskCacheEntry* wrCache_;
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
|
||||
int32_t nextBegin_;
|
||||
|
||||
std::string hashType_;
|
||||
|
||||
std::unique_ptr<MessageDigest> mdctx_;
|
||||
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
std::vector<cuid_t> users_;
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
std::string hashType_;
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
|
||||
Piece(const Piece& piece);
|
||||
size_t index_;
|
||||
|
||||
int32_t length_;
|
||||
int32_t blockLength_;
|
||||
#ifdef ENABLE_MESSAGE_DIGEST
|
||||
int32_t nextBegin_;
|
||||
#endif // ENABLE_MESSAGE_DIGEST
|
||||
|
||||
bool usedBySegment_;
|
||||
|
||||
Piece(const Piece& piece) = delete;
|
||||
Piece& operator=(const Piece& piece) = delete;
|
||||
|
||||
Piece& operator=(const Piece& piece);
|
||||
public:
|
||||
|
||||
static const int32_t BLOCK_LENGTH = 16*1024;
|
||||
|
||||
Piece();
|
||||
|
||||
Piece(size_t index, int32_t length, int32_t blockLength = BLOCK_LENGTH);
|
||||
|
||||
~Piece();
|
||||
|
|
|
@ -123,35 +123,35 @@ namespace aria2 {
|
|||
|
||||
RequestGroup::RequestGroup(const std::shared_ptr<GroupId>& gid,
|
||||
const std::shared_ptr<Option>& option)
|
||||
: gid_(gid),
|
||||
state_(STATE_WAITING),
|
||||
: belongsToGID_(0),
|
||||
gid_(gid),
|
||||
option_(option),
|
||||
numConcurrentCommand_(option->getAsInt(PREF_SPLIT)),
|
||||
numStreamConnection_(0),
|
||||
numStreamCommand_(0),
|
||||
numCommand_(0),
|
||||
saveControlFile_(true),
|
||||
progressInfoFile_(new NullProgressInfoFile()),
|
||||
preLocalFileCheckEnabled_(true),
|
||||
haltRequested_(false),
|
||||
forceHaltRequested_(false),
|
||||
haltReason_(RequestGroup::NONE),
|
||||
pauseRequested_(false),
|
||||
uriSelector_(make_unique<InorderURISelector>()),
|
||||
lastModifiedTime_(Time::null()),
|
||||
fileNotFoundCount_(0),
|
||||
timeout_(option->getAsInt(PREF_TIMEOUT)),
|
||||
requestGroupMan_(nullptr),
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
btRuntime_(nullptr),
|
||||
peerStorage_(nullptr),
|
||||
#endif // ENABLE_BITTORRENT
|
||||
inMemoryDownload_(false),
|
||||
lastModifiedTime_(Time::null()),
|
||||
timeout_(option->getAsInt(PREF_TIMEOUT)),
|
||||
state_(STATE_WAITING),
|
||||
numConcurrentCommand_(option->getAsInt(PREF_SPLIT)),
|
||||
numStreamConnection_(0),
|
||||
numStreamCommand_(0),
|
||||
numCommand_(0),
|
||||
fileNotFoundCount_(0),
|
||||
maxDownloadSpeedLimit_(option->getAsInt(PREF_MAX_DOWNLOAD_LIMIT)),
|
||||
maxUploadSpeedLimit_(option->getAsInt(PREF_MAX_UPLOAD_LIMIT)),
|
||||
resumeFailureCount_(0),
|
||||
haltReason_(RequestGroup::NONE),
|
||||
lastErrorCode_(error_code::UNDEFINED),
|
||||
belongsToGID_(0),
|
||||
requestGroupMan_(nullptr),
|
||||
resumeFailureCount_(0)
|
||||
saveControlFile_(true),
|
||||
preLocalFileCheckEnabled_(true),
|
||||
haltRequested_(false),
|
||||
forceHaltRequested_(false),
|
||||
pauseRequested_(false),
|
||||
inMemoryDownload_(false)
|
||||
{
|
||||
fileAllocationEnabled_ = option_->get(PREF_FILE_ALLOCATION) != V_NONE;
|
||||
if(!option_->getAsBool(PREF_DRY_RUN)) {
|
||||
|
|
|
@ -87,13 +87,59 @@ public:
|
|||
// Download has begun
|
||||
STATE_ACTIVE
|
||||
};
|
||||
|
||||
private:
|
||||
// If this download is a part of another download(for example,
|
||||
// downloading torrent file described in Metalink file), this field
|
||||
// has the GID of parent RequestGroup. 0 means this is a parent
|
||||
// RequestGroup.
|
||||
a2_gid_t belongsToGID_;
|
||||
|
||||
std::shared_ptr<GroupId> gid_;
|
||||
|
||||
int state_;
|
||||
|
||||
std::shared_ptr<Option> option_;
|
||||
|
||||
std::shared_ptr<SegmentMan> segmentMan_;
|
||||
|
||||
std::shared_ptr<DownloadContext> downloadContext_;
|
||||
|
||||
std::shared_ptr<PieceStorage> pieceStorage_;
|
||||
|
||||
std::shared_ptr<BtProgressInfoFile> progressInfoFile_;
|
||||
|
||||
std::shared_ptr<DiskWriterFactory> diskWriterFactory_;
|
||||
|
||||
std::shared_ptr<Dependency> dependency_;
|
||||
|
||||
std::unique_ptr<URISelector> uriSelector_;
|
||||
|
||||
std::shared_ptr<MetadataInfo> metadataInfo_;
|
||||
|
||||
RequestGroupMan* requestGroupMan_;
|
||||
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
BtRuntime* btRuntime_;
|
||||
|
||||
PeerStorage* peerStorage_;
|
||||
#endif // ENABLE_BITTORRENT
|
||||
|
||||
// If this download generates another downloads when completed(for
|
||||
// example, downloads generated by PostDownloadHandler), this field
|
||||
// has the GID of generated RequestGroups. empty list means there is
|
||||
// no such RequestGroup.
|
||||
std::vector<a2_gid_t> followedByGIDs_;
|
||||
|
||||
std::vector<const PreDownloadHandler*> preDownloadHandlers_;
|
||||
|
||||
std::vector<const PostDownloadHandler*> postDownloadHandlers_;
|
||||
|
||||
Time lastModifiedTime_;
|
||||
|
||||
// Timeout used for HTTP/FTP downloads.
|
||||
time_t timeout_;
|
||||
|
||||
int state_;
|
||||
|
||||
int numConcurrentCommand_;
|
||||
|
||||
/**
|
||||
|
@ -105,20 +151,20 @@ private:
|
|||
|
||||
int numCommand_;
|
||||
|
||||
std::shared_ptr<SegmentMan> segmentMan_;
|
||||
int fileNotFoundCount_;
|
||||
|
||||
std::shared_ptr<DownloadContext> downloadContext_;
|
||||
int maxDownloadSpeedLimit_;
|
||||
|
||||
std::shared_ptr<PieceStorage> pieceStorage_;
|
||||
int maxUploadSpeedLimit_;
|
||||
|
||||
int resumeFailureCount_;
|
||||
|
||||
HaltReason haltReason_;
|
||||
|
||||
error_code::Value lastErrorCode_;
|
||||
|
||||
bool saveControlFile_;
|
||||
|
||||
std::shared_ptr<BtProgressInfoFile> progressInfoFile_;
|
||||
|
||||
std::shared_ptr<DiskWriterFactory> diskWriterFactory_;
|
||||
|
||||
std::shared_ptr<Dependency> dependency_;
|
||||
|
||||
bool fileAllocationEnabled_;
|
||||
|
||||
bool preLocalFileCheckEnabled_;
|
||||
|
@ -127,56 +173,12 @@ private:
|
|||
|
||||
bool forceHaltRequested_;
|
||||
|
||||
HaltReason haltReason_;
|
||||
|
||||
bool pauseRequested_;
|
||||
|
||||
std::vector<const PreDownloadHandler*> preDownloadHandlers_;
|
||||
|
||||
std::vector<const PostDownloadHandler*> postDownloadHandlers_;
|
||||
|
||||
std::unique_ptr<URISelector> uriSelector_;
|
||||
|
||||
Time lastModifiedTime_;
|
||||
|
||||
int fileNotFoundCount_;
|
||||
|
||||
// Timeout used for HTTP/FTP downloads.
|
||||
time_t timeout_;
|
||||
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
BtRuntime* btRuntime_;
|
||||
|
||||
PeerStorage* peerStorage_;
|
||||
#endif // ENABLE_BITTORRENT
|
||||
|
||||
// This flag just indicates that the downloaded file is not saved disk but
|
||||
// just sits in memory.
|
||||
bool inMemoryDownload_;
|
||||
|
||||
int maxDownloadSpeedLimit_;
|
||||
|
||||
int maxUploadSpeedLimit_;
|
||||
|
||||
error_code::Value lastErrorCode_;
|
||||
|
||||
// If this download generates another downloads when completed(for
|
||||
// example, downloads generated by PostDownloadHandler), this field
|
||||
// has the GID of generated RequestGroups. empty list means there is
|
||||
// no such RequestGroup.
|
||||
std::vector<a2_gid_t> followedByGIDs_;
|
||||
|
||||
// If this download is a part of another download(for example,
|
||||
// downloading torrent file described in Metalink file), this field
|
||||
// has the GID of parent RequestGroup. 0 means this is a parent
|
||||
// RequestGroup.
|
||||
a2_gid_t belongsToGID_;
|
||||
|
||||
std::shared_ptr<MetadataInfo> metadataInfo_;
|
||||
|
||||
RequestGroupMan* requestGroupMan_;
|
||||
|
||||
int resumeFailureCount_;
|
||||
|
||||
void validateFilename(const std::string& expectedFilename,
|
||||
const std::string& actualFilename) const;
|
||||
|
|
|
@ -40,9 +40,14 @@ namespace aria2 {
|
|||
|
||||
TimeBasedCommand::TimeBasedCommand(cuid_t cuid, DownloadEngine* e,
|
||||
time_t interval,
|
||||
bool routineCommand):
|
||||
Command(cuid), e_(e),exit_(false), interval_(interval),
|
||||
routineCommand_(routineCommand), checkPoint_(global::wallclock()) {}
|
||||
bool routineCommand)
|
||||
: Command(cuid),
|
||||
e_(e),
|
||||
checkPoint_(global::wallclock()),
|
||||
interval_(interval),
|
||||
exit_(false),
|
||||
routineCommand_(routineCommand)
|
||||
{}
|
||||
|
||||
TimeBasedCommand::~TimeBasedCommand() {}
|
||||
|
||||
|
|
|
@ -47,6 +47,10 @@ class TimeBasedCommand : public Command
|
|||
private:
|
||||
DownloadEngine* e_;
|
||||
|
||||
Timer checkPoint_;
|
||||
|
||||
time_t interval_; // unit: sec
|
||||
|
||||
/**
|
||||
* setting exit_ to true if this command's job has finished and you want to
|
||||
* delete this command.
|
||||
|
@ -56,11 +60,8 @@ private:
|
|||
*/
|
||||
bool exit_;
|
||||
|
||||
time_t interval_; // unit: sec
|
||||
|
||||
bool routineCommand_;
|
||||
|
||||
Timer checkPoint_;
|
||||
protected:
|
||||
DownloadEngine* getDownloadEngine() const
|
||||
{
|
||||
|
|
|
@ -48,12 +48,12 @@ UriStruct::UriStruct()
|
|||
UriStruct::UriStruct(const UriStruct& c)
|
||||
: protocol(c.protocol),
|
||||
host(c.host),
|
||||
port(c.port),
|
||||
dir(c.dir),
|
||||
file(c.file),
|
||||
query(c.query),
|
||||
username(c.username),
|
||||
password(c.password),
|
||||
port(c.port),
|
||||
hasPassword(c.hasPassword),
|
||||
ipv6LiteralAddress(c.ipv6LiteralAddress)
|
||||
{}
|
||||
|
@ -65,12 +65,12 @@ UriStruct& UriStruct::operator=(const UriStruct& c)
|
|||
if(this != &c) {
|
||||
protocol = c.protocol;
|
||||
host = c.host;
|
||||
port = c.port;
|
||||
dir = c.dir;
|
||||
file = c.file;
|
||||
query = c.query;
|
||||
username = c.username;
|
||||
password = c.password;
|
||||
port = c.port;
|
||||
hasPassword = c.hasPassword;
|
||||
ipv6LiteralAddress = c.ipv6LiteralAddress;
|
||||
}
|
||||
|
@ -83,12 +83,12 @@ void UriStruct::swap(UriStruct& other)
|
|||
if(this != &other) {
|
||||
swap(protocol, other.protocol);
|
||||
swap(host, other.host);
|
||||
swap(port, other.port);
|
||||
swap(dir, other.dir);
|
||||
swap(file, other.file);
|
||||
swap(query, other.query);
|
||||
swap(username, other.username);
|
||||
swap(password, other.password);
|
||||
swap(port, other.port);
|
||||
swap(hasPassword, other.hasPassword);
|
||||
swap(ipv6LiteralAddress, other.ipv6LiteralAddress);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue