2010-04-13 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Hold reference to PieceStorage when paused in order to provide
	progress information via XML-RPC.
	* src/RequestGroup.cc
	* src/RequestGroup.h
	* src/RequestGroupMan.cc
pull/1/head
Tatsuhiro Tsujikawa 2010-04-13 12:39:09 +00:00
parent a605048900
commit 1f02b65460
4 changed files with 21 additions and 2 deletions

View File

@ -1,3 +1,11 @@
2010-04-13 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Hold reference to PieceStorage when paused in order to provide
progress information via XML-RPC.
* src/RequestGroup.cc
* src/RequestGroup.h
* src/RequestGroupMan.cc
2010-04-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Defined struct timespec if it is not available.

View File

@ -533,6 +533,12 @@ void RequestGroup::initPieceStorage()
_segmentMan = tempSegmentMan;
}
void RequestGroup::dropPieceStorage()
{
_segmentMan.reset();
_pieceStorage.reset();
}
bool RequestGroup::downloadFinishedByFileLength()
{
// assuming that a control file doesn't exist.
@ -891,8 +897,8 @@ void RequestGroup::releaseRuntimeResource(DownloadEngine* e)
if(!_pieceStorage.isNull()) {
_pieceStorage->removeAdvertisedPiece(0);
}
_segmentMan.reset();
_pieceStorage.reset();
// Don't reset _segmentMan and _pieceStorage here to provide
// progress information via XML-RPC
_progressInfoFile.reset();
_downloadContext->releaseRuntimeResource();
}

View File

@ -379,6 +379,8 @@ public:
// they are not.
void initPieceStorage();
void dropPieceStorage();
bool downloadFinishedByFileLength();
void loadAndOpenFile(const SharedHandle<BtProgressInfoFile>& progressInfoFile);

View File

@ -528,6 +528,9 @@ void RequestGroupMan::fillRequestGroupFromReserver(DownloadEngine* e)
temp.push_back(groupToAdd);
continue;
}
// Drop pieceStorage here because paused download holds its
// reference.
groupToAdd->dropPieceStorage();
configureRequestGroup(groupToAdd);
createInitialCommand(groupToAdd, commands, e);
groupToAdd->setRequestGroupMan(this);