mirror of https://github.com/aria2/aria2
2010-07-17 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Count the number of command used in HTTP(S)/FTP and the number of connections in HTTP(S)/FTP independently. The former is used to determin whether additional command is needed. The latter is used to report user to how many connections are used in a download. * src/AbstractCommand.cc * src/AbstractCommand.h * src/CreateRequestCommand.cc * src/RequestGroup.cc * src/RequestGroup.hpull/1/head
parent
036abeee11
commit
d0b727f6dc
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
2010-07-17 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Count the number of command used in HTTP(S)/FTP and the number of
|
||||||
|
connections in HTTP(S)/FTP independently. The former is used to
|
||||||
|
determin whether additional command is needed. The latter is used
|
||||||
|
to report user to how many connections are used in a download.
|
||||||
|
* src/AbstractCommand.cc
|
||||||
|
* src/AbstractCommand.h
|
||||||
|
* src/CreateRequestCommand.cc
|
||||||
|
* src/RequestGroup.cc
|
||||||
|
* src/RequestGroup.h
|
||||||
|
|
||||||
2010-07-17 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2010-07-17 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Check status values: 200 and 206.
|
Check status values: 200 and 206.
|
||||||
|
|
|
@ -79,18 +79,23 @@ AbstractCommand::AbstractCommand(cuid_t cuid,
|
||||||
const SharedHandle<FileEntry>& fileEntry,
|
const SharedHandle<FileEntry>& fileEntry,
|
||||||
RequestGroup* requestGroup,
|
RequestGroup* requestGroup,
|
||||||
DownloadEngine* e,
|
DownloadEngine* e,
|
||||||
const SocketHandle& s):
|
const SocketHandle& s,
|
||||||
|
bool incNumConnection):
|
||||||
Command(cuid), checkPoint_(global::wallclock),
|
Command(cuid), checkPoint_(global::wallclock),
|
||||||
timeout_(requestGroup->getTimeout()),
|
timeout_(requestGroup->getTimeout()),
|
||||||
requestGroup_(requestGroup),
|
requestGroup_(requestGroup),
|
||||||
req_(req), fileEntry_(fileEntry), e_(e), socket_(s),
|
req_(req), fileEntry_(fileEntry), e_(e), socket_(s),
|
||||||
checkSocketIsReadable_(false), checkSocketIsWritable_(false),
|
checkSocketIsReadable_(false), checkSocketIsWritable_(false),
|
||||||
nameResolverCheck_(false)
|
nameResolverCheck_(false),
|
||||||
|
incNumConnection_(incNumConnection)
|
||||||
{
|
{
|
||||||
if(!socket_.isNull() && socket_->isOpen()) {
|
if(!socket_.isNull() && socket_->isOpen()) {
|
||||||
setReadCheckSocket(socket_);
|
setReadCheckSocket(socket_);
|
||||||
}
|
}
|
||||||
requestGroup_->increaseStreamConnection();
|
if(incNumConnection_) {
|
||||||
|
requestGroup->increaseStreamConnection();
|
||||||
|
}
|
||||||
|
requestGroup_->increaseStreamCommand();
|
||||||
requestGroup_->increaseNumCommand();
|
requestGroup_->increaseNumCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,7 +106,10 @@ AbstractCommand::~AbstractCommand() {
|
||||||
disableNameResolverCheck(asyncNameResolver_);
|
disableNameResolverCheck(asyncNameResolver_);
|
||||||
#endif // ENABLE_ASYNC_DNS
|
#endif // ENABLE_ASYNC_DNS
|
||||||
requestGroup_->decreaseNumCommand();
|
requestGroup_->decreaseNumCommand();
|
||||||
|
requestGroup_->decreaseStreamCommand();
|
||||||
|
if(incNumConnection_) {
|
||||||
requestGroup_->decreaseStreamConnection();
|
requestGroup_->decreaseStreamConnection();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AbstractCommand::execute() {
|
bool AbstractCommand::execute() {
|
||||||
|
|
|
@ -75,6 +75,8 @@ private:
|
||||||
SharedHandle<SocketCore> writeCheckTarget_;
|
SharedHandle<SocketCore> writeCheckTarget_;
|
||||||
bool nameResolverCheck_;
|
bool nameResolverCheck_;
|
||||||
|
|
||||||
|
bool incNumConnection_;
|
||||||
|
|
||||||
#ifdef ENABLE_ASYNC_DNS
|
#ifdef ENABLE_ASYNC_DNS
|
||||||
void setNameResolverCheck(const SharedHandle<AsyncNameResolver>& resolver);
|
void setNameResolverCheck(const SharedHandle<AsyncNameResolver>& resolver);
|
||||||
|
|
||||||
|
@ -218,10 +220,12 @@ protected:
|
||||||
return requestGroup_->getPieceStorage();
|
return requestGroup_->getPieceStorage();
|
||||||
}
|
}
|
||||||
public:
|
public:
|
||||||
AbstractCommand(cuid_t cuid, const SharedHandle<Request>& req,
|
AbstractCommand
|
||||||
|
(cuid_t cuid, const SharedHandle<Request>& req,
|
||||||
const SharedHandle<FileEntry>& fileEntry,
|
const SharedHandle<FileEntry>& fileEntry,
|
||||||
RequestGroup* requestGroup, DownloadEngine* e,
|
RequestGroup* requestGroup, DownloadEngine* e,
|
||||||
const SharedHandle<SocketCore>& s = SharedHandle<SocketCore>());
|
const SharedHandle<SocketCore>& s = SharedHandle<SocketCore>(),
|
||||||
|
bool incNumConnection = true);
|
||||||
|
|
||||||
virtual ~AbstractCommand();
|
virtual ~AbstractCommand();
|
||||||
bool execute();
|
bool execute();
|
||||||
|
|
|
@ -57,7 +57,8 @@ CreateRequestCommand::CreateRequestCommand(cuid_t cuid,
|
||||||
RequestGroup* requestGroup,
|
RequestGroup* requestGroup,
|
||||||
DownloadEngine* e):
|
DownloadEngine* e):
|
||||||
AbstractCommand
|
AbstractCommand
|
||||||
(cuid, SharedHandle<Request>(), SharedHandle<FileEntry>(), requestGroup, e)
|
(cuid, SharedHandle<Request>(), SharedHandle<FileEntry>(), requestGroup, e,
|
||||||
|
SharedHandle<SocketCore>(), false)
|
||||||
{
|
{
|
||||||
setStatus(Command::STATUS_ONESHOT_REALTIME);
|
setStatus(Command::STATUS_ONESHOT_REALTIME);
|
||||||
disableReadCheckSocket();
|
disableReadCheckSocket();
|
||||||
|
|
|
@ -119,6 +119,7 @@ RequestGroup::RequestGroup(const SharedHandle<Option>& option):
|
||||||
option_(new Option(*option.get())),
|
option_(new Option(*option.get())),
|
||||||
numConcurrentCommand_(option->getAsInt(PREF_SPLIT)),
|
numConcurrentCommand_(option->getAsInt(PREF_SPLIT)),
|
||||||
numStreamConnection_(0),
|
numStreamConnection_(0),
|
||||||
|
numStreamCommand_(0),
|
||||||
numCommand_(0),
|
numCommand_(0),
|
||||||
saveControlFile_(true),
|
saveControlFile_(true),
|
||||||
progressInfoFile_(new NullProgressInfoFile()),
|
progressInfoFile_(new NullProgressInfoFile()),
|
||||||
|
@ -726,17 +727,17 @@ void RequestGroup::createNextCommand(std::vector<Command*>& commands,
|
||||||
{
|
{
|
||||||
int numCommand;
|
int numCommand;
|
||||||
if(getTotalLength() == 0) {
|
if(getTotalLength() == 0) {
|
||||||
if(numStreamConnection_ > 0) {
|
if(numStreamCommand_ > 0) {
|
||||||
numCommand = 0;
|
numCommand = 0;
|
||||||
} else {
|
} else {
|
||||||
numCommand = 1;
|
numCommand = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(numStreamConnection_ >= numConcurrentCommand_) {
|
if(numStreamCommand_ >= numConcurrentCommand_) {
|
||||||
numCommand = 0;
|
numCommand = 0;
|
||||||
} else {
|
} else {
|
||||||
numCommand = std::min(downloadContext_->getNumPieces(),
|
numCommand = std::min(downloadContext_->getNumPieces(),
|
||||||
numConcurrentCommand_-numStreamConnection_);
|
numConcurrentCommand_-numStreamCommand_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(numCommand > 0) {
|
if(numCommand > 0) {
|
||||||
|
@ -831,6 +832,16 @@ void RequestGroup::validateTotalLength(uint64_t actualTotalLength) const
|
||||||
validateTotalLength(getTotalLength(), actualTotalLength);
|
validateTotalLength(getTotalLength(), actualTotalLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RequestGroup::increaseStreamCommand()
|
||||||
|
{
|
||||||
|
++numStreamCommand_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RequestGroup::decreaseStreamCommand()
|
||||||
|
{
|
||||||
|
--numStreamCommand_;
|
||||||
|
}
|
||||||
|
|
||||||
void RequestGroup::increaseStreamConnection()
|
void RequestGroup::increaseStreamConnection()
|
||||||
{
|
{
|
||||||
++numStreamConnection_;
|
++numStreamConnection_;
|
||||||
|
|
|
@ -97,6 +97,8 @@ private:
|
||||||
*/
|
*/
|
||||||
unsigned int numStreamConnection_;
|
unsigned int numStreamConnection_;
|
||||||
|
|
||||||
|
unsigned int numStreamCommand_;
|
||||||
|
|
||||||
unsigned int numCommand_;
|
unsigned int numCommand_;
|
||||||
|
|
||||||
SharedHandle<SegmentMan> segmentMan_;
|
SharedHandle<SegmentMan> segmentMan_;
|
||||||
|
@ -278,13 +280,14 @@ public:
|
||||||
|
|
||||||
void setProgressInfoFile(const SharedHandle<BtProgressInfoFile>& progressInfoFile);
|
void setProgressInfoFile(const SharedHandle<BtProgressInfoFile>& progressInfoFile);
|
||||||
|
|
||||||
|
void increaseStreamCommand();
|
||||||
|
|
||||||
|
void decreaseStreamCommand();
|
||||||
|
|
||||||
void increaseStreamConnection();
|
void increaseStreamConnection();
|
||||||
|
|
||||||
void decreaseStreamConnection();
|
void decreaseStreamConnection();
|
||||||
|
|
||||||
// Returns the number of connections used in HTTP(S)/FTP.
|
|
||||||
unsigned int getNumStreamConnection() { return numStreamConnection_; }
|
|
||||||
|
|
||||||
unsigned int getNumConnection() const;
|
unsigned int getNumConnection() const;
|
||||||
|
|
||||||
void increaseNumCommand();
|
void increaseNumCommand();
|
||||||
|
|
Loading…
Reference in New Issue