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

Create SharedHandle outside of function call to avoid unexpected
	memory leak.
	* src/AnnounceList.cc
	* src/FtpNegotiationCommand.cc
	* src/HttpResponseCommand.cc
	* src/RequestGroup.cc
	* src/RequestGroupMan.cc
	* src/UTMetadataPostDownloadHandler.cc
	* src/download_helper.cc
pull/1/head
Tatsuhiro Tsujikawa 2010-11-11 05:12:37 +00:00
parent e728385bc9
commit bcf4593bda
8 changed files with 42 additions and 31 deletions

View File

@ -1,3 +1,15 @@
2010-11-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Create SharedHandle outside of function call to avoid unexpected
memory leak.
* src/AnnounceList.cc
* src/FtpNegotiationCommand.cc
* src/HttpResponseCommand.cc
* src/RequestGroup.cc
* src/RequestGroupMan.cc
* src/UTMetadataPostDownloadHandler.cc
* src/download_helper.cc
2010-11-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Updated supported hash functions.

View File

@ -79,7 +79,8 @@ void AnnounceList::reconfigure
void AnnounceList::reconfigure(const std::string& url) {
std::deque<std::string> urls;
urls.push_back(url);
tiers_.push_back(SharedHandle<AnnounceTier>(new AnnounceTier(urls)));
SharedHandle<AnnounceTier> tier(new AnnounceTier(urls));
tiers_.push_back(tier);
resetIterator();
}

View File

@ -431,12 +431,10 @@ bool FtpNegotiationCommand::onFileSizeDetermined(uint64_t totalLength)
getSegmentMan()->getSegmentWithIndex(getCuid(), 0);
return true;
} else {
getRequestGroup()->adjustFilename
(SharedHandle<BtProgressInfoFile>
(new DefaultBtProgressInfoFile
(getDownloadContext(),
SharedHandle<PieceStorage>(),
getOption().get())));
SharedHandle<BtProgressInfoFile> progressInfoFile
(new DefaultBtProgressInfoFile
(getDownloadContext(), SharedHandle<PieceStorage>(), getOption().get()));
getRequestGroup()->adjustFilename(progressInfoFile);
getRequestGroup()->initPieceStorage();
if(getOption()->getAsBool(PREF_DRY_RUN)) {

View File

@ -293,11 +293,10 @@ bool HttpResponseCommand::handleDefaultEncoding
(const SharedHandle<HttpResponse>& httpResponse)
{
SharedHandle<HttpRequest> httpRequest = httpResponse->getHttpRequest();
getRequestGroup()->adjustFilename
(SharedHandle<BtProgressInfoFile>(new DefaultBtProgressInfoFile
(getDownloadContext(),
SharedHandle<PieceStorage>(),
getOption().get())));
SharedHandle<BtProgressInfoFile> progressInfoFile
(new DefaultBtProgressInfoFile
(getDownloadContext(), SharedHandle<PieceStorage>(), getOption().get()));
getRequestGroup()->adjustFilename(progressInfoFile);
getRequestGroup()->initPieceStorage();
if(getOption()->getAsBool(PREF_DRY_RUN)) {

View File

@ -484,11 +484,10 @@ void RequestGroup::createInitialCommand
(StringFormat(EX_DUPLICATE_FILE_DOWNLOAD,
downloadContext_->getBasePath().c_str()).str());
}
adjustFilename
(SharedHandle<BtProgressInfoFile>(new DefaultBtProgressInfoFile
(downloadContext_,
SharedHandle<PieceStorage>(),
option_.get())));
SharedHandle<BtProgressInfoFile> progressInfoFile
(new DefaultBtProgressInfoFile
(downloadContext_, SharedHandle<PieceStorage>(), option_.get()));
adjustFilename(progressInfoFile);
initPieceStorage();
SharedHandle<CheckIntegrityEntry> checkEntry =
createCheckIntegrityEntry();
@ -601,8 +600,9 @@ void RequestGroup::initPieceStorage()
if(logger_->debug()) {
logger_->debug("Using LongestSequencePieceSelector");
}
ps->setPieceSelector
(SharedHandle<PieceSelector>(new LongestSequencePieceSelector()));
SharedHandle<PieceSelector> longestPieceSelector
(new LongestSequencePieceSelector());
ps->setPieceSelector(longestPieceSelector);
}
if(option_->defined(PREF_BT_PRIORITIZE_PIECE)) {
std::vector<size_t> result;

View File

@ -463,22 +463,22 @@ void RequestGroupMan::configureRequestGroup
{
const std::string& uriSelectorValue = option_->get(PREF_URI_SELECTOR);
if(uriSelectorValue == V_FEEDBACK) {
requestGroup->setURISelector
(SharedHandle<URISelector>(new FeedbackURISelector(serverStatMan_)));
SharedHandle<URISelector> sel(new FeedbackURISelector(serverStatMan_));
requestGroup->setURISelector(sel);
} else if(uriSelectorValue == V_INORDER) {
requestGroup->setURISelector
(SharedHandle<URISelector>(new InOrderURISelector()));
SharedHandle<URISelector> sel(new InOrderURISelector());
requestGroup->setURISelector(sel);
} else if(uriSelectorValue == V_ADAPTIVE) {
requestGroup->setURISelector
(SharedHandle<URISelector>(new AdaptiveURISelector(serverStatMan_,
requestGroup.get())));
SharedHandle<URISelector> sel(new AdaptiveURISelector(serverStatMan_,
requestGroup.get()));
requestGroup->setURISelector(sel);
}
}
namespace {
void createInitialCommand(const SharedHandle<RequestGroup>& requestGroup,
std::vector<Command*>& commands,
DownloadEngine* e)
DownloadEngine* e)
{
requestGroup->createInitialCommand(commands, e);
}

View File

@ -69,7 +69,8 @@ bool UTMetadataPostDownloadHandler::Criteria::match
UTMetadataPostDownloadHandler::UTMetadataPostDownloadHandler():
logger_(LogFactory::getInstance())
{
setCriteria(SharedHandle<Criteria>(new Criteria()));
SharedHandle<Criteria> cri(new Criteria());
setCriteria(cri);
}
void UTMetadataPostDownloadHandler::getNextRequestGroups

View File

@ -311,9 +311,9 @@ createBtMagnetRequestGroup(const std::string& magnetLink,
dctx->getFirstFileEntry()->setPath(torrentAttrs->name);
rg->setDownloadContext(dctx);
rg->clearPostDownloadHandler();
rg->addPostDownloadHandler
(SharedHandle<UTMetadataPostDownloadHandler>
(new UTMetadataPostDownloadHandler()));
SharedHandle<UTMetadataPostDownloadHandler> utMetadataPostHandler
(new UTMetadataPostDownloadHandler());
rg->addPostDownloadHandler(utMetadataPostHandler);
rg->setDiskWriterFactory
(SharedHandle<DiskWriterFactory>(new ByteArrayDiskWriterFactory()));
rg->setMetadataInfo(createMetadataInfo(magnetLink));