summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorpeavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7>2006-12-28 20:29:27 +0000
committerpeavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7>2006-12-28 20:29:27 +0000
commit486ac00566bf842784f3edf5355ef71e0591ff2d (patch)
tree65962656326f4d2754ce44dd918a87b4ba79f35d /src
parent125f9c37da8feeb91cec683310f3f67bac39e39e (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/modules/extra/m_mysql.cpp14
1 files changed, 13 insertions, 1 deletions
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);
}