From e40d6b7c0fdfc2518fcf0d79a4c45f8cb769db94 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 5 Jul 2009 09:10:08 +0000 Subject: [PATCH] 2009-07-05 Tatsuhiro Tsujikawa Release pooled and in-flight Request objectsand URIResult objects in FileEntry after download completed. * src/DownloadContext.cc * src/DownloadContext.h * src/FileEntry.cc * src/FileEntry.h * src/RequestGroup.cc --- ChangeLog | 10 ++++++++++ src/DownloadContext.cc | 8 ++++++++ src/DownloadContext.h | 2 ++ src/FileEntry.cc | 7 +++++++ src/FileEntry.h | 2 ++ src/RequestGroup.cc | 3 +-- 6 files changed, 30 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 901e05f9..1363ed71 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009-07-05 Tatsuhiro Tsujikawa + + Release pooled and in-flight Request objectsand URIResult objects + in FileEntry after download completed. + * src/DownloadContext.cc + * src/DownloadContext.h + * src/FileEntry.cc + * src/FileEntry.h + * src/RequestGroup.cc + 2009-07-05 Tatsuhiro Tsujikawa Set manual and source attribute in aria2c.1.txt diff --git a/src/DownloadContext.cc b/src/DownloadContext.cc index f002eb3d..b450d8fd 100644 --- a/src/DownloadContext.cc +++ b/src/DownloadContext.cc @@ -165,4 +165,12 @@ bool DownloadContext::hasAttribute(const std::string& key) const } } +void DownloadContext::releaseRuntimeResource() +{ + for(std::vector >::const_iterator i = + _fileEntries.begin(); i != _fileEntries.end(); ++i) { + (*i)->releaseRuntimeResource(); + } +} + } // namespace aria2 diff --git a/src/DownloadContext.h b/src/DownloadContext.h index 479efab5..44af2c4b 100644 --- a/src/DownloadContext.h +++ b/src/DownloadContext.h @@ -235,6 +235,8 @@ public: // Returns FileEntry at given offset. SharedHandle() is // returned if no such FileEntry is found. SharedHandle findFileEntryByOffset(off_t offset) const; + + void releaseRuntimeResource(); }; } // namespace aria2 diff --git a/src/FileEntry.cc b/src/FileEntry.cc index 25d195e2..5e1ffb4b 100644 --- a/src/FileEntry.cc +++ b/src/FileEntry.cc @@ -313,4 +313,11 @@ void FileEntry::reuseUri(size_t num) } } +void FileEntry::releaseRuntimeResource() +{ + _requestPool.clear(); + _inFlightRequests.clear(); + _uriResults.clear(); +} + } // namespace aria2 diff --git a/src/FileEntry.h b/src/FileEntry.h index 74716141..6e894f6d 100644 --- a/src/FileEntry.h +++ b/src/FileEntry.h @@ -231,6 +231,8 @@ public: // reuse, those URIs are used more than once so that num URIs total // are available to reuse. void reuseUri(size_t num); + + void releaseRuntimeResource(); }; typedef SharedHandle FileEntryHandle; diff --git a/src/RequestGroup.cc b/src/RequestGroup.cc index cbf24b68..2bbf91aa 100644 --- a/src/RequestGroup.cc +++ b/src/RequestGroup.cc @@ -800,6 +800,7 @@ void RequestGroup::releaseRuntimeResource(DownloadEngine* e) if(!_pieceStorage.isNull()) { _pieceStorage->removeAdvertisedPiece(0); } + _downloadContext->releaseRuntimeResource(); } void RequestGroup::preDownloadProcessing() @@ -945,8 +946,6 @@ DownloadResultHandle RequestGroup::createDownloadResult() const sessionDownloadLength += _segmentMan->calculateSessionDownloadLength(); } - - // TODO1.5 Purge unnecessary data in FileEntry here. return SharedHandle (new DownloadResult(_gid,