浏览代码

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
Tatsuhiro Tsujikawa 16 年之前
父节点
当前提交
e40d6b7c0f
共有 6 个文件被更改,包括 30 次插入2 次删除
  1. 10 0
      ChangeLog
  2. 8 0
      src/DownloadContext.cc
  3. 2 0
      src/DownloadContext.h
  4. 7 0
      src/FileEntry.cc
  5. 2 0
      src/FileEntry.h
  6. 1 2
      src/RequestGroup.cc

+ 10 - 0
ChangeLog

@@ -1,3 +1,13 @@
+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
+
 2009-07-05  Tatsuhiro Tsujikawa  <t-tujikawa@users.sourceforge.net>
 
 	Set manual and source attribute in aria2c.1.txt

+ 8 - 0
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

+ 2 - 0
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

+ 7 - 0
src/FileEntry.cc

@@ -313,4 +313,11 @@ void FileEntry::reuseUri(size_t num)
   }
 }
 
+void FileEntry::releaseRuntimeResource()
+{
+  _requestPool.clear();
+  _inFlightRequests.clear();
+  _uriResults.clear();
+}
+
 } // namespace aria2

+ 2 - 0
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;

+ 1 - 2
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,