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> 2010-11-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Updated supported hash functions. Updated supported hash functions.

View File

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

View File

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

View File

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

View File

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

View File

@ -463,15 +463,15 @@ void RequestGroupMan::configureRequestGroup
{ {
const std::string& uriSelectorValue = option_->get(PREF_URI_SELECTOR); const std::string& uriSelectorValue = option_->get(PREF_URI_SELECTOR);
if(uriSelectorValue == V_FEEDBACK) { if(uriSelectorValue == V_FEEDBACK) {
requestGroup->setURISelector SharedHandle<URISelector> sel(new FeedbackURISelector(serverStatMan_));
(SharedHandle<URISelector>(new FeedbackURISelector(serverStatMan_))); requestGroup->setURISelector(sel);
} else if(uriSelectorValue == V_INORDER) { } else if(uriSelectorValue == V_INORDER) {
requestGroup->setURISelector SharedHandle<URISelector> sel(new InOrderURISelector());
(SharedHandle<URISelector>(new InOrderURISelector())); requestGroup->setURISelector(sel);
} else if(uriSelectorValue == V_ADAPTIVE) { } else if(uriSelectorValue == V_ADAPTIVE) {
requestGroup->setURISelector SharedHandle<URISelector> sel(new AdaptiveURISelector(serverStatMan_,
(SharedHandle<URISelector>(new AdaptiveURISelector(serverStatMan_, requestGroup.get()));
requestGroup.get()))); requestGroup->setURISelector(sel);
} }
} }

View File

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

View File

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