summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/commands/cmd_rehash.cpp2
-rw-r--r--src/inspircd.cpp7
-rw-r--r--src/logger.cpp24
-rw-r--r--src/modules/m_swhois.cpp2
-rw-r--r--src/server.cpp2
5 files changed, 28 insertions, 9 deletions
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();