From 486ac00566bf842784f3edf5355ef71e0591ff2d Mon Sep 17 00:00:00 2001 From: peavey Date: Thu, 28 Dec 2006 20:29:27 +0000 Subject: Fix mem leakage in reading in and connecting to databases and have destructor call mem cleanup too and end the endless loop too so /RESTART and /DIE works with no segfault. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6144 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/extra/m_mysql.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/modules') diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index fe23eee8c..63ed7d540 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -594,9 +594,19 @@ void ConnectDatabases(InspIRCd* ServerInstance) } } +void ClearDatabases() +{ + ConnMap::iterator i; + while ((i = Connections.begin()) != Connections.end()) + { + Connections.erase(i); + delete i->second; + } +} + void LoadDatabases(ConfigReader* ThisConf, InspIRCd* ServerInstance) { - Connections.clear(); + ClearDatabases(); for (int j =0; j < ThisConf->Enumerate("database"); j++) { std::string db = ThisConf->ReadValue("database","name",j); @@ -793,6 +803,8 @@ class ModuleSQL : public Module virtual ~ModuleSQL() { + giveup = true; + ClearDatabases(); DELETE(Conf); } -- cgit v1.2.3