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
This commit is contained in:
peavey 2006-12-28 20:29:27 +00:00
parent 125f9c37da
commit 486ac00566

View File

@ -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);
}