From 0f0fc5f1987e879ddfffdb0de9214987157eedc2 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Sun, 20 Jun 2010 11:37:47 +0000 Subject: 2010-06-20 Tatsuhiro Tsujikawa Use auto_delete_container to delete created Command when exception is thrown rather than deleting them in catch block. * src/AbstractCommand.cc * src/CheckIntegrityCommand.cc * src/DHTSetup.cc * src/FileAllocationCommand.cc * src/TrackerWatcherCommand.cc * src/a2functional.h --- src/CheckIntegrityCommand.cc | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'src/CheckIntegrityCommand.cc') diff --git a/src/CheckIntegrityCommand.cc b/src/CheckIntegrityCommand.cc index 262f2626..72087520 100644 --- a/src/CheckIntegrityCommand.cc +++ b/src/CheckIntegrityCommand.cc @@ -75,26 +75,20 @@ bool CheckIntegrityCommand::executeInternal() getLogger()->notice (MSG_VERIFICATION_SUCCESSFUL, getRequestGroup()->getDownloadContext()->getBasePath().c_str()); - std::vector commands; - try { - _entry->onDownloadFinished(commands, getDownloadEngine()); - } catch(RecoverableException& e) { - std::for_each(commands.begin(), commands.end(), Deleter()); - throw; - } - getDownloadEngine()->addCommand(commands); + std::vector* commands = new std::vector(); + auto_delete_container > commandsDel(commands); + _entry->onDownloadFinished(*commands, getDownloadEngine()); + getDownloadEngine()->addCommand(*commands); + commands->clear(); } else { getLogger()->error (MSG_VERIFICATION_FAILED, getRequestGroup()->getDownloadContext()->getBasePath().c_str()); - std::vector commands; - try { - _entry->onDownloadIncomplete(commands, getDownloadEngine()); - } catch(RecoverableException& e) { - std::for_each(commands.begin(), commands.end(), Deleter()); - throw; - } - getDownloadEngine()->addCommand(commands); + std::vector* commands = new std::vector(); + auto_delete_container > commandsDel(commands); + _entry->onDownloadIncomplete(*commands, getDownloadEngine()); + getDownloadEngine()->addCommand(*commands); + commands->clear(); } getDownloadEngine()->setNoWait(true); return true; -- cgit