diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-07-05 09:10:08 +0000 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2009-07-05 09:10:08 +0000 |
| commit | e40d6b7c0fdfc2518fcf0d79a4c45f8cb769db94 (patch) | |
| tree | 503311fc08ad1b2afeba8bf83178d41fc6e578b6 /src | |
| parent | f0edf98651f7f437bbd9b901907c9a3259687d10 (diff) | |
2009-07-05 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
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
Diffstat (limited to 'src')
| -rw-r--r-- | src/DownloadContext.cc | 8 | ||||
| -rw-r--r-- | src/DownloadContext.h | 2 | ||||
| -rw-r--r-- | src/FileEntry.cc | 7 | ||||
| -rw-r--r-- | src/FileEntry.h | 2 | ||||
| -rw-r--r-- | src/RequestGroup.cc | 3 |
5 files changed, 20 insertions, 2 deletions
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<SharedHandle<FileEntry> >::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<FileEntry>() is // returned if no such FileEntry is found. SharedHandle<FileEntry> 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<FileEntry> 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<DownloadResult> (new DownloadResult(_gid, |
