summaryrefslogtreecommitdiff
path: root/src/TrackerWatcherCommand.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-01-11 15:35:12 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2010-01-11 15:35:12 +0000
commitf3b1defc97a1ce72a08631809feb869a9a3448c1 (patch)
tree1c58a880e3648d41a0e334d41218430cd46b1600 /src/TrackerWatcherCommand.cc
parent768f78f7713716816a21f03edcd8020ab708b4b1 (diff)
2010-01-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed memory leak. Commands stored in std::deque<Command*> are not deleted when exception is thrown. Make sure that when passing std::deque<Command*> to function to store Commands, handle exception and delete these Commands. * src/AbstractCommand.cc * src/CheckIntegrityCommand.cc * src/FileAllocationCommand.cc * src/RequestGroup.cc * src/TrackerWatcherCommand.cc
Diffstat (limited to 'src/TrackerWatcherCommand.cc')
-rw-r--r--src/TrackerWatcherCommand.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/TrackerWatcherCommand.cc b/src/TrackerWatcherCommand.cc
index af9a9f13..73052b1e 100644
--- a/src/TrackerWatcherCommand.cc
+++ b/src/TrackerWatcherCommand.cc
@@ -59,6 +59,7 @@
#include "AnnounceTier.h"
#include "DownloadContext.h"
#include "bittorrent_helper.h"
+#include "a2functional.h"
namespace aria2 {
@@ -97,7 +98,13 @@ bool TrackerWatcherCommand::execute() {
_trackerRequestGroup = createAnnounce();
if(!_trackerRequestGroup.isNull()) {
std::deque<Command*> commands;
- _trackerRequestGroup->createInitialCommand(commands, e);
+ try {
+ _trackerRequestGroup->createInitialCommand(commands, e);
+ } catch(RecoverableException& ex) {
+ logger->error(EX_EXCEPTION_CAUGHT, ex);
+ std::for_each(commands.begin(), commands.end(), Deleter());
+ commands.clear();
+ }
e->addCommand(commands);
logger->debug("added tracker request command");
}