/* */ #include "FillRequestGroupCommand.h" #include "DownloadEngine.h" #include "RequestGroupMan.h" #include "RequestGroup.h" #include "RecoverableException.h" #include "message.h" #include "Logger.h" #include "DownloadContext.h" #include "ServerStatMan.h" #include "FileAllocationEntry.h" #include "CheckIntegrityEntry.h" namespace aria2 { FillRequestGroupCommand::FillRequestGroupCommand(cuid_t cuid, DownloadEngine* e): Command(cuid), _e(e) { setStatusRealtime(); } FillRequestGroupCommand::~FillRequestGroupCommand() {} bool FillRequestGroupCommand::execute() { if(_e->isHaltRequested()) { return true; } SharedHandle rgman = _e->getRequestGroupMan(); if(rgman->queueCheckRequested()) { try { // During adding RequestGroup, // RequestGroupMan::requestQueueCheck() might be called, so // first clear it here. rgman->clearQueueCheck(); rgman->fillRequestGroupFromReserver(_e); } catch(RecoverableException& ex) { getLogger()->error(EX_EXCEPTION_CAUGHT, ex); // Re-request queue check to fulfill the requests of all // downloads, some might come after this exception. rgman->requestQueueCheck(); } if(rgman->downloadFinished()) { return true; } } _e->addRoutineCommand(this); return false; } } // namespace aria2