From f2a63fa06a931333ac2e4a3a5d36a56418b4b6cd Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 17 Jan 2011 21:19:45 +0900 Subject: Added --retry-wait option. This option was once existed in aria2 but erased on 2009-09-20. Now it is resurrected once again. We choose 2 as default value, but there is no good theory behind it. Now we retry HTTP download when remote server returns 503 Service Unavailable if --retry-wait > 0. We also added error code 29: HTTP_SERVICE_UNAVAILABLE. --- src/FileEntry.cc | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/FileEntry.cc') diff --git a/src/FileEntry.cc b/src/FileEntry.cc index 9fe560e9..262ae890 100644 --- a/src/FileEntry.cc +++ b/src/FileEntry.cc @@ -170,9 +170,23 @@ FileEntry::getRequest break; } } - } else { - req = requestPool_.front(); - requestPool_.pop_front(); + } else { + // Skip Request object if it is still + // sleeping(Request::getWakeTime() < global::wallclock). If all + // pooled objects are sleeping, return first one. Caller should + // inspect returned object's getWakeTime(). + std::deque >::iterator i = requestPool_.begin(); + std::deque >::iterator eoi = requestPool_.end(); + for(; i != eoi; ++i) { + if((*i)->getWakeTime() <= global::wallclock) { + break; + } + } + if(i == eoi) { + i = requestPool_.begin(); + } + req = *i; + requestPool_.erase(i); inFlightRequests_.push_back(req); A2_LOG_DEBUG(fmt("Picked up from pool: %s", req->getUri().c_str())); } -- cgit