From 49b49c351ab0e5d464d158f2d103333371d9c42a Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 15 May 2011 23:35:06 +0900 Subject: Eliminated few seconds delay when downloads stop or pause. The delay is caused because some Commands are only called in certain interval(called refreshInterval, default, 1000ms). In aria2 download stops when all Commands associated to it are stopped. Since some Commands are called in each 1000ms by default, as mentioned before, we have to wait for them. To fix this issue, we call DownloadEngine::setRefreshInterval(0) when pausing/stopping downloads. DownloadEngine::setRefreshInterval(0) makes refreshInterval 0 in one shot. When all segments are ignored, now DownloadFailureException is thrown. And stop the download immediately. As described earlier, we call DownloadEngine::setRefreshInterval(0) in catch block of DownloadFailureException to eliminate delay. --- src/CreateRequestCommand.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/CreateRequestCommand.cc') diff --git a/src/CreateRequestCommand.cc b/src/CreateRequestCommand.cc index f731d91a..9fe997e6 100644 --- a/src/CreateRequestCommand.cc +++ b/src/CreateRequestCommand.cc @@ -94,7 +94,10 @@ bool CreateRequestCommand::executeInternal() if(getSegmentMan()) { getSegmentMan()->ignoreSegmentFor(getFileEntry()); } - throw DL_ABORT_EX("No URI available."); + // In this case, the error might be already set in RequestGroup, + // so use it here. + throw DL_ABORT_EX2("No URI available.", + getRequestGroup()->getLastErrorCode()); } else if(getRequest()->getWakeTime() > global::wallclock) { A2_LOG_DEBUG("This request object is still sleeping."); getFileEntry()->poolRequest(getRequest()); -- cgit