diff options
-rw-r--r-- | include/inspircd.h | 4 | ||||
-rw-r--r-- | include/logger.h | 1 | ||||
-rw-r--r-- | src/commands/cmd_rehash.cpp | 2 | ||||
-rw-r--r-- | src/inspircd.cpp | 7 | ||||
-rw-r--r-- | src/logger.cpp | 24 | ||||
-rw-r--r-- | src/modules/m_swhois.cpp | 2 | ||||
-rw-r--r-- | src/server.cpp | 2 |
7 files changed, 29 insertions, 13 deletions
diff --git a/include/inspircd.h b/include/inspircd.h index 5f57619d5..d1e6f4005 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -558,10 +558,6 @@ class CoreExport InspIRCd : public classbase */ bool OpenLog(char** argv, int argc); - /** Close the currently open log file - */ - void CloseLog(); - /** Return true if a channel name is valid * @param chname A channel name to verify * @return True if the name is valid diff --git a/include/logger.h b/include/logger.h index d22b4203b..70407422f 100644 --- a/include/logger.h +++ b/include/logger.h @@ -41,6 +41,7 @@ class CoreExport LogManager : public classbase ServerInstance = Instance; } + void CloseLogs(); bool AddLogType(const std::string &type, LogStream *l); bool DelLogType(const std::string &type, LogStream *l); void Log(const std::string &type, int loglevel, const std::string &msg); diff --git a/src/commands/cmd_rehash.cpp b/src/commands/cmd_rehash.cpp index 22e935fdc..d0e1882a7 100644 --- a/src/commands/cmd_rehash.cpp +++ b/src/commands/cmd_rehash.cpp @@ -34,7 +34,7 @@ CmdResult CommandRehash::Handle (const char** parameters, int pcnt, User *user) else { ServerInstance->SNO->WriteToSnoMask('A', "%s is rehashing config file %s",user->nick,ServerConfig::CleanFilename(ServerInstance->ConfigFileName)); - ServerInstance->CloseLog(); + ServerInstance->Logs->CloseLogs(); if (!ServerInstance->OpenLog(ServerInstance->Config->argv, ServerInstance->Config->argc)) user->WriteServ("*** NOTICE %s :ERROR: Could not open logfile %s: %s", user->nick, ServerInstance->Config->logpath.c_str(), strerror(errno)); ServerInstance->RehashUsersAndChans(); diff --git a/src/inspircd.cpp b/src/inspircd.cpp index ef656cca9..aab09d799 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -103,7 +103,7 @@ void InspIRCd::Cleanup() } /* Close logging */ - // XXX we need to add a method to terminate all logstreams. + this->Logs->CloseLogs(); /* Cleanup Server Names */ for(servernamelist::iterator itr = servernames.begin(); itr != servernames.end(); ++itr) @@ -178,11 +178,6 @@ void InspIRCd::RehashUsersAndChans() delete old_chans; } -void InspIRCd::CloseLog() -{ - // XXX add a method to terminate all logstreams. -} - void InspIRCd::SetSignals() { #ifndef WIN32 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<std::string, std::vector<LogStream *> >::iterator i; + + while (LogStreams.begin() != LogStreams.end()) + { + i = LogStreams.begin(); + + while (i->second.begin() != i->second.end()) + { + std::vector<LogStream *>::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<std::string, std::vector<LogStream *> >::iterator i = LogStreams.find(type); diff --git a/src/modules/m_swhois.cpp b/src/modules/m_swhois.cpp index 9ebbb2a08..3a0b2b0a7 100644 --- a/src/modules/m_swhois.cpp +++ b/src/modules/m_swhois.cpp @@ -90,7 +90,7 @@ class CommandSwhois : public Command delete metadata; // If it's an empty swhois, unset it (not ideal, but ok) - if (text.empty()) + if (text->empty()) { dest->Shrink("swhois"); delete text; diff --git a/src/server.cpp b/src/server.cpp index 2a30f3a37..191c84ce0 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -47,7 +47,7 @@ void InspIRCd::Exit(int status) void InspIRCd::Rehash() { this->SNO->WriteToSnoMask('A', "Rehashing config file %s due to SIGHUP",ServerConfig::CleanFilename(this->ConfigFileName)); - this->CloseLog(); + this->Logs->CloseLogs(); if (!this->OpenLog(this->Config->argv, this->Config->argc)) this->SNO->WriteToSnoMask('A', "ERROR: Could not open logfile %s: %s", Config->logpath.c_str(), strerror(errno)); this->RehashUsersAndChans(); |