mirror of https://github.com/aria2/aria2
2010-03-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Only execute RequestGroupMan::fillRequestGroupFromReserver() when queue maintenance is requested by RequestGroup to avoid to call the function unnecessarily. * src/FillRequestGroupCommand.cc * src/RequestGroup.cc * src/RequestGroup.h * src/RequestGroupMan.cc * src/RequestGroupMan.hpull/1/head
parent
db4ed87f7a
commit
fe8fea56ca
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
||||||
|
2010-03-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
|
Only execute RequestGroupMan::fillRequestGroupFromReserver() when
|
||||||
|
queue maintenance is requested by RequestGroup to avoid to call
|
||||||
|
the function unnecessarily.
|
||||||
|
* src/FillRequestGroupCommand.cc
|
||||||
|
* src/RequestGroup.cc
|
||||||
|
* src/RequestGroup.h
|
||||||
|
* src/RequestGroupMan.cc
|
||||||
|
* src/RequestGroupMan.h
|
||||||
|
|
||||||
2010-03-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
2010-03-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
|
||||||
|
|
||||||
Don't use hash for Peer::id. Simple concatenation of ip address
|
Don't use hash for Peer::id. Simple concatenation of ip address
|
||||||
|
|
|
@ -40,6 +40,7 @@
|
||||||
#include "message.h"
|
#include "message.h"
|
||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "DownloadContext.h"
|
#include "DownloadContext.h"
|
||||||
|
#include "ServerStatMan.h"
|
||||||
|
|
||||||
namespace aria2 {
|
namespace aria2 {
|
||||||
|
|
||||||
|
@ -60,13 +61,17 @@ bool FillRequestGroupCommand::execute()
|
||||||
if(_e->isHaltRequested()) {
|
if(_e->isHaltRequested()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
try {
|
SharedHandle<RequestGroupMan> rgman = _e->_requestGroupMan;
|
||||||
_e->_requestGroupMan->fillRequestGroupFromReserver(_e);
|
if(rgman->queueCheckRequested()) {
|
||||||
} catch(RecoverableException& ex) {
|
try {
|
||||||
logger->error(EX_EXCEPTION_CAUGHT, ex);
|
rgman->fillRequestGroupFromReserver(_e);
|
||||||
}
|
rgman->clearQueueCheck();
|
||||||
if(_e->_requestGroupMan->downloadFinished()) {
|
} catch(RecoverableException& ex) {
|
||||||
return true;
|
logger->error(EX_EXCEPTION_CAUGHT, ex);
|
||||||
|
}
|
||||||
|
if(rgman->downloadFinished()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_e->addRoutineCommand(this);
|
_e->addRoutineCommand(this);
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -130,6 +130,7 @@ RequestGroup::RequestGroup(const SharedHandle<Option>& option):
|
||||||
_maxDownloadSpeedLimit(option->getAsInt(PREF_MAX_DOWNLOAD_LIMIT)),
|
_maxDownloadSpeedLimit(option->getAsInt(PREF_MAX_DOWNLOAD_LIMIT)),
|
||||||
_maxUploadSpeedLimit(option->getAsInt(PREF_MAX_UPLOAD_LIMIT)),
|
_maxUploadSpeedLimit(option->getAsInt(PREF_MAX_UPLOAD_LIMIT)),
|
||||||
_belongsToGID(0),
|
_belongsToGID(0),
|
||||||
|
_requestGroupMan(0),
|
||||||
_logger(LogFactory::getInstance())
|
_logger(LogFactory::getInstance())
|
||||||
{
|
{
|
||||||
_fileAllocationEnabled = _option->get(PREF_FILE_ALLOCATION) != V_NONE;
|
_fileAllocationEnabled = _option->get(PREF_FILE_ALLOCATION) != V_NONE;
|
||||||
|
@ -799,6 +800,12 @@ void RequestGroup::increaseNumCommand()
|
||||||
void RequestGroup::decreaseNumCommand()
|
void RequestGroup::decreaseNumCommand()
|
||||||
{
|
{
|
||||||
--_numCommand;
|
--_numCommand;
|
||||||
|
if(!_numCommand && _requestGroupMan) {
|
||||||
|
if(_logger->debug()) {
|
||||||
|
_logger->debug("GID#%d - Request queue check", _gid);
|
||||||
|
}
|
||||||
|
_requestGroupMan->requestQueueCheck();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,7 @@ class CheckIntegrityEntry;
|
||||||
class DownloadResult;
|
class DownloadResult;
|
||||||
class URISelector;
|
class URISelector;
|
||||||
class URIResult;
|
class URIResult;
|
||||||
|
class RequestGroupMan;
|
||||||
#ifdef ENABLE_BITTORRENT
|
#ifdef ENABLE_BITTORRENT
|
||||||
class BtRuntime;
|
class BtRuntime;
|
||||||
class PeerStorage;
|
class PeerStorage;
|
||||||
|
@ -162,6 +163,8 @@ private:
|
||||||
// RequestGroup.
|
// RequestGroup.
|
||||||
int32_t _belongsToGID;
|
int32_t _belongsToGID;
|
||||||
|
|
||||||
|
RequestGroupMan* _requestGroupMan;
|
||||||
|
|
||||||
Logger* _logger;
|
Logger* _logger;
|
||||||
|
|
||||||
void validateFilename(const std::string& expectedFilename,
|
void validateFilename(const std::string& expectedFilename,
|
||||||
|
@ -488,6 +491,11 @@ public:
|
||||||
return _belongsToGID;
|
return _belongsToGID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setRequestGroupMan(RequestGroupMan* requestGroupMan)
|
||||||
|
{
|
||||||
|
_requestGroupMan = requestGroupMan;
|
||||||
|
}
|
||||||
|
|
||||||
static void resetGIDCounter() { _gidCounter = 0; }
|
static void resetGIDCounter() { _gidCounter = 0; }
|
||||||
|
|
||||||
static int32_t newGID();
|
static int32_t newGID();
|
||||||
|
|
|
@ -83,7 +83,8 @@ RequestGroupMan::RequestGroupMan
|
||||||
_maxOverallDownloadSpeedLimit
|
_maxOverallDownloadSpeedLimit
|
||||||
(option->getAsInt(PREF_MAX_OVERALL_DOWNLOAD_LIMIT)),
|
(option->getAsInt(PREF_MAX_OVERALL_DOWNLOAD_LIMIT)),
|
||||||
_maxOverallUploadSpeedLimit(option->getAsInt(PREF_MAX_OVERALL_UPLOAD_LIMIT)),
|
_maxOverallUploadSpeedLimit(option->getAsInt(PREF_MAX_OVERALL_UPLOAD_LIMIT)),
|
||||||
_xmlRpc(option->getAsBool(PREF_ENABLE_XML_RPC))
|
_xmlRpc(option->getAsBool(PREF_ENABLE_XML_RPC)),
|
||||||
|
_queueCheck(true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
bool RequestGroupMan::downloadFinished()
|
bool RequestGroupMan::downloadFinished()
|
||||||
|
@ -497,6 +498,7 @@ void RequestGroupMan::fillRequestGroupFromReserver(DownloadEngine* e)
|
||||||
}
|
}
|
||||||
configureRequestGroup(groupToAdd);
|
configureRequestGroup(groupToAdd);
|
||||||
createInitialCommand(groupToAdd, commands, e);
|
createInitialCommand(groupToAdd, commands, e);
|
||||||
|
groupToAdd->setRequestGroupMan(this);
|
||||||
_requestGroups.push_back(groupToAdd);
|
_requestGroups.push_back(groupToAdd);
|
||||||
++count;
|
++count;
|
||||||
e->addCommand(commands);
|
e->addCommand(commands);
|
||||||
|
|
|
@ -77,6 +77,8 @@ private:
|
||||||
// truf if XML-RPC is enabled.
|
// truf if XML-RPC is enabled.
|
||||||
bool _xmlRpc;
|
bool _xmlRpc;
|
||||||
|
|
||||||
|
bool _queueCheck;
|
||||||
|
|
||||||
std::string
|
std::string
|
||||||
formatDownloadResult(const std::string& status,
|
formatDownloadResult(const std::string& status,
|
||||||
const SharedHandle<DownloadResult>& downloadResult) const;
|
const SharedHandle<DownloadResult>& downloadResult) const;
|
||||||
|
@ -254,6 +256,24 @@ public:
|
||||||
{
|
{
|
||||||
_maxSimultaneousDownloads = max;
|
_maxSimultaneousDownloads = max;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Call this function if _requestGroups queue should be maintained.
|
||||||
|
// This function is added to reduce the call of maintenance, but at
|
||||||
|
// the same time, it provides fast maintenance reaction.
|
||||||
|
void requestQueueCheck()
|
||||||
|
{
|
||||||
|
_queueCheck = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void clearQueueCheck()
|
||||||
|
{
|
||||||
|
_queueCheck = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool queueCheckRequested() const
|
||||||
|
{
|
||||||
|
return _queueCheck;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef SharedHandle<RequestGroupMan> RequestGroupManHandle;
|
typedef SharedHandle<RequestGroupMan> RequestGroupManHandle;
|
||||||
|
|
Loading…
Reference in New Issue