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>
|
||||
|
||||
Check status values: 200 and 206.
|
||||
|
|
|
@ -79,18 +79,23 @@ AbstractCommand::AbstractCommand(cuid_t cuid,
|
|||
const SharedHandle<FileEntry>& fileEntry,
|
||||
RequestGroup* requestGroup,
|
||||
DownloadEngine* e,
|
||||
const SocketHandle& s):
|
||||
const SocketHandle& s,
|
||||
bool incNumConnection):
|
||||
Command(cuid), checkPoint_(global::wallclock),
|
||||
timeout_(requestGroup->getTimeout()),
|
||||
requestGroup_(requestGroup),
|
||||
req_(req), fileEntry_(fileEntry), e_(e), socket_(s),
|
||||
checkSocketIsReadable_(false), checkSocketIsWritable_(false),
|
||||
nameResolverCheck_(false)
|
||||
nameResolverCheck_(false),
|
||||
incNumConnection_(incNumConnection)
|
||||
{
|
||||
if(!socket_.isNull() && socket_->isOpen()) {
|
||||
setReadCheckSocket(socket_);
|
||||
}
|
||||
requestGroup_->increaseStreamConnection();
|
||||
if(incNumConnection_) {
|
||||
requestGroup->increaseStreamConnection();
|
||||
}
|
||||
requestGroup_->increaseStreamCommand();
|
||||
requestGroup_->increaseNumCommand();
|
||||
}
|
||||
|
||||
|
@ -101,7 +106,10 @@ AbstractCommand::~AbstractCommand() {
|
|||
disableNameResolverCheck(asyncNameResolver_);
|
||||
#endif // ENABLE_ASYNC_DNS
|
||||
requestGroup_->decreaseNumCommand();
|
||||
requestGroup_->decreaseStreamCommand();
|
||||
if(incNumConnection_) {
|
||||
requestGroup_->decreaseStreamConnection();
|
||||
}
|
||||
}
|
||||
|
||||
bool AbstractCommand::execute() {
|
||||
|
|
|
@ -75,6 +75,8 @@ private:
|
|||
SharedHandle<SocketCore> writeCheckTarget_;
|
||||
bool nameResolverCheck_;
|
||||
|
||||
bool incNumConnection_;
|
||||
|
||||
#ifdef ENABLE_ASYNC_DNS
|
||||
void setNameResolverCheck(const SharedHandle<AsyncNameResolver>& resolver);
|
||||
|
||||
|
@ -218,10 +220,12 @@ protected:
|
|||
return requestGroup_->getPieceStorage();
|
||||
}
|
||||
public:
|
||||
AbstractCommand(cuid_t cuid, const SharedHandle<Request>& req,
|
||||
AbstractCommand
|
||||
(cuid_t cuid, const SharedHandle<Request>& req,
|
||||
const SharedHandle<FileEntry>& fileEntry,
|
||||
RequestGroup* requestGroup, DownloadEngine* e,
|
||||
const SharedHandle<SocketCore>& s = SharedHandle<SocketCore>());
|
||||
const SharedHandle<SocketCore>& s = SharedHandle<SocketCore>(),
|
||||
bool incNumConnection = true);
|
||||
|
||||
virtual ~AbstractCommand();
|
||||
bool execute();
|
||||
|
|
|
@ -57,7 +57,8 @@ CreateRequestCommand::CreateRequestCommand(cuid_t cuid,
|
|||
RequestGroup* requestGroup,
|
||||
DownloadEngine* e):
|
||||
AbstractCommand
|
||||
(cuid, SharedHandle<Request>(), SharedHandle<FileEntry>(), requestGroup, e)
|
||||
(cuid, SharedHandle<Request>(), SharedHandle<FileEntry>(), requestGroup, e,
|
||||
SharedHandle<SocketCore>(), false)
|
||||
{
|
||||
setStatus(Command::STATUS_ONESHOT_REALTIME);
|
||||
disableReadCheckSocket();
|
||||
|
|
|
@ -119,6 +119,7 @@ RequestGroup::RequestGroup(const SharedHandle<Option>& option):
|
|||
option_(new Option(*option.get())),
|
||||
numConcurrentCommand_(option->getAsInt(PREF_SPLIT)),
|
||||
numStreamConnection_(0),
|
||||
numStreamCommand_(0),
|
||||
numCommand_(0),
|
||||
saveControlFile_(true),
|
||||
progressInfoFile_(new NullProgressInfoFile()),
|
||||
|
@ -726,17 +727,17 @@ void RequestGroup::createNextCommand(std::vector<Command*>& commands,
|
|||
{
|
||||
int numCommand;
|
||||
if(getTotalLength() == 0) {
|
||||
if(numStreamConnection_ > 0) {
|
||||
if(numStreamCommand_ > 0) {
|
||||
numCommand = 0;
|
||||
} else {
|
||||
numCommand = 1;
|
||||
}
|
||||
} else {
|
||||
if(numStreamConnection_ >= numConcurrentCommand_) {
|
||||
if(numStreamCommand_ >= numConcurrentCommand_) {
|
||||
numCommand = 0;
|
||||
} else {
|
||||
numCommand = std::min(downloadContext_->getNumPieces(),
|
||||
numConcurrentCommand_-numStreamConnection_);
|
||||
numConcurrentCommand_-numStreamCommand_);
|
||||
}
|
||||
}
|
||||
if(numCommand > 0) {
|
||||
|
@ -831,6 +832,16 @@ void RequestGroup::validateTotalLength(uint64_t actualTotalLength) const
|
|||
validateTotalLength(getTotalLength(), actualTotalLength);
|
||||
}
|
||||
|
||||
void RequestGroup::increaseStreamCommand()
|
||||
{
|
||||
++numStreamCommand_;
|
||||
}
|
||||
|
||||
void RequestGroup::decreaseStreamCommand()
|
||||
{
|
||||
--numStreamCommand_;
|
||||
}
|
||||
|
||||
void RequestGroup::increaseStreamConnection()
|
||||
{
|
||||
++numStreamConnection_;
|
||||
|
|
|
@ -97,6 +97,8 @@ private:
|
|||
*/
|
||||
unsigned int numStreamConnection_;
|
||||
|
||||
unsigned int numStreamCommand_;
|
||||
|
||||
unsigned int numCommand_;
|
||||
|
||||
SharedHandle<SegmentMan> segmentMan_;
|
||||
|
@ -278,13 +280,14 @@ public:
|
|||
|
||||
void setProgressInfoFile(const SharedHandle<BtProgressInfoFile>& progressInfoFile);
|
||||
|
||||
void increaseStreamCommand();
|
||||
|
||||
void decreaseStreamCommand();
|
||||
|
||||
void increaseStreamConnection();
|
||||
|
||||
void decreaseStreamConnection();
|
||||
|
||||
// Returns the number of connections used in HTTP(S)/FTP.
|
||||
unsigned int getNumStreamConnection() { return numStreamConnection_; }
|
||||
|
||||
unsigned int getNumConnection() const;
|
||||
|
||||
void increaseNumCommand();
|
||||
|
|
Loading…
Reference in New Issue