From bfff1d9d93dccb9f0080b84d3933d47f2a6a1f6c Mon Sep 17 00:00:00 2001 From: w00t Date: Sat, 9 Feb 2008 20:15:09 +0000 Subject: Implement LogManager::CloseLogs() to give logstreams a chance to clean up on rehash or exit. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8863 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/logger.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/logger.cpp') diff --git a/src/logger.cpp b/src/logger.cpp index c30dae832..53cc7941f 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -42,6 +42,30 @@ * */ +void LogManager::CloseLogs() +{ + /* + * This doesn't remove logstreams from the map/vector etc, because if this is called, shit is hitting the fan + * and we're going down anyway - this just provides a "nice" way for logstreams to clean up. -- w + */ + std::map >::iterator i; + + while (LogStreams.begin() != LogStreams.end()) + { + i = LogStreams.begin(); + + while (i->second.begin() != i->second.end()) + { + std::vector::iterator it = i->second.begin(); + + delete (*it); + i->second.erase(it); + } + + LogStreams.erase(i); + } +} + bool LogManager::AddLogType(const std::string &type, LogStream *l) { std::map >::iterator i = LogStreams.find(type); -- cgit v1.2.3