Release elements in routineCommands_ on destruction

pull/89/head
Tatsuhiro Tsujikawa 2013-05-15 22:50:51 +09:00
parent cef6db17ba
commit fc0982587b
2 changed files with 9 additions and 8 deletions

View File

@ -107,18 +107,21 @@ DownloadEngine::DownloadEngine(const SharedHandle<EventPoll>& eventPoll)
sessionId_.assign(&sessionId[0], & sessionId[sizeof(sessionId)]);
}
namespace {
void cleanQueue(std::deque<Command*>& commands) {
std::for_each(commands.begin(), commands.end(), Deleter());
commands.clear();
}
} // namespace
DownloadEngine::~DownloadEngine() {
cleanQueue();
cleanQueue(commands_);
cleanQueue(routineCommands_);
#ifdef HAVE_ARES_ADDR_NODE
setAsyncDNSServers(0);
#endif // HAVE_ARES_ADDR_NODE
}
void DownloadEngine::cleanQueue() {
std::for_each(commands_.begin(), commands_.end(), Deleter());
commands_.clear();
}
namespace {
void executeCommand(std::deque<Command*>& commands,
Command::STATUS statusFilter)

View File

@ -183,8 +183,6 @@ public:
// processed. Otherwise, returns 0.
int run(bool oneshot=false);
void cleanQueue();
bool addSocketForReadCheck(const SharedHandle<SocketCore>& socket,
Command* command);
bool deleteSocketForReadCheck(const SharedHandle<SocketCore>& socket,