summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-04-21 16:59:23 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2008-04-21 16:59:23 +0000
commit98659aa0dcac7636627846555ef7d5f807152b7e (patch)
tree4726b3771ad6874862f2ff7b503264eed617f8d4
parentf21617328a8a576c8ada619f2934ac31f0dec717 (diff)
Merge in large patchset from GreenReaper, useful fixes for freeing a ton of different things on shutdown for tidyness, and a few stack corruption fixes in the mode handler
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9565 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/ctables.h5
-rw-r--r--include/usermanager.h10
-rw-r--r--src/commands/cmd_die.cpp8
-rw-r--r--src/configreader.cpp5
-rw-r--r--src/dns.cpp1
-rw-r--r--src/inspircd.cpp125
-rw-r--r--src/mode.cpp3
-rw-r--r--src/modes/cmode_l.cpp2
-rw-r--r--src/modules.cpp4
-rw-r--r--src/server.cpp3
-rw-r--r--src/snomasks.cpp7
-rw-r--r--src/xline.cpp12
-rw-r--r--win/configure.cpp12
-rw-r--r--win/m_spanningtreeVC80.vcproj61
14 files changed, 203 insertions, 55 deletions
diff --git a/include/ctables.h b/include/ctables.h
index fa0d42d74..ba6773a4c 100644
--- a/include/ctables.h
+++ b/include/ctables.h
@@ -167,7 +167,10 @@ class CoreExport Command : public Extensible
/** Standard constructor gubbins
*/
- virtual ~Command() {}
+ virtual ~Command()
+ {
+ syntax.clear();
+ }
};
/** A hash of commands used by the core
diff --git a/include/usermanager.h b/include/usermanager.h
index 4c50c4292..3a9e15150 100644
--- a/include/usermanager.h
+++ b/include/usermanager.h
@@ -32,7 +32,15 @@ class CoreExport UserManager : public classbase
{
ServerInstance = Instance;
}
-
+
+ ~UserManager()
+ {
+ for (user_hash::iterator i = clientlist->begin();i != clientlist->end();i++)
+ {
+ delete i->second;
+ }
+ clientlist->clear();
+ }
/** Client list, a hash_map containing all clients, local and remote
*/
diff --git a/src/commands/cmd_die.cpp b/src/commands/cmd_die.cpp
index 761127dcb..2723ecca3 100644
--- a/src/commands/cmd_die.cpp
+++ b/src/commands/cmd_die.cpp
@@ -26,9 +26,11 @@ CmdResult CommandDie::Handle (const char* const* parameters, int pcnt, User *use
{
if (!ServerInstance->PassCompare(user, ServerInstance->Config->diepass, parameters[0], ServerInstance->Config->powerhash))
{
- std::string diebuf = std::string("*** DIE command from ") + user->nick + "!" + user->ident + "@" + user->dhost + ". Terminating in " + ConvToStr(ServerInstance->Config->DieDelay) + " seconds.";
- ServerInstance->Logs->Log("COMMAND",SPARSE, diebuf);
- ServerInstance->SendError(diebuf);
+ {
+ std::string diebuf = std::string("*** DIE command from ") + user->nick + "!" + user->ident + "@" + user->dhost + ". Terminating in " + ConvToStr(ServerInstance->Config->DieDelay) + " seconds.";
+ ServerInstance->Logs->Log("COMMAND",SPARSE, diebuf);
+ ServerInstance->SendError(diebuf);
+ }
if (ServerInstance->Config->DieDelay)
sleep(ServerInstance->Config->DieDelay);
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 29dff39ca..e45a76b40 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -36,7 +36,7 @@ bool DoneELine(ServerConfig* conf, const char* tag);
ServerConfig::ServerConfig(InspIRCd* Instance) : ServerInstance(Instance)
{
this->ClearStack();
- *ServerName = *Network = *ServerDesc = *AdminName = '\0';
+ *sid = *ServerName = *Network = *ServerDesc = *AdminName = '\0';
*HideWhoisServer = *AdminEmail = *AdminNick = *diepass = *restartpass = *FixedQuit = *HideKillsServer = '\0';
*DefaultModes = *CustomVersion = *motd = *rules = *PrefixQuit = *DieValue = *DNSServer = '\0';
*UserStats = *ModPath = *MyExecutable = *DisabledCommands = *PID = *SuffixQuit = '\0';
@@ -1960,7 +1960,7 @@ bool ServerConfig::DirValid(const char* dirandfile)
{
#ifdef WINDOWS
return true;
-#endif
+#else
char work[1024];
char buffer[1024];
@@ -2011,6 +2011,7 @@ bool ServerConfig::DirValid(const char* dirandfile)
{
return false;
}
+#endif
}
std::string ServerConfig::GetFullProgDir()
diff --git a/src/dns.cpp b/src/dns.cpp
index 2e393de53..ad59a98e4 100644
--- a/src/dns.cpp
+++ b/src/dns.cpp
@@ -934,7 +934,6 @@ DNS::~DNS()
ServerInstance->SE->Shutdown(this, 2);
ServerInstance->SE->Close(this);
ServerInstance->Timers->DelTimer(this->PruneTimer);
- delete this->PruneTimer;
}
CachedQuery* DNS::GetCache(const std::string &source)
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index d533a6e45..d09dff840 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -112,15 +112,109 @@ void InspIRCd::Cleanup()
this->Modules->Unload(k->c_str());
}
}
-
- /* Close logging */
- this->Logs->CloseLogs();
+ /* Remove core commands */
+ Parser->RemoveCommands("<core>");
/* Cleanup Server Names */
for(servernamelist::iterator itr = servernames.begin(); itr != servernames.end(); ++itr)
delete (*itr);
+ /* Delete objects dynamically allocated in constructor
+ * (destructor would be more appropriate, but we're likely exiting)
+ */
+
+ // Must be deleted before modes as it decrements modelines
+ if (this->Users)
+ {
+ delete this->Users;
+ this->Users = 0;
+ }
+
+ if (this->Modes)
+ {
+ delete this->Modes;
+ this->Modes = 0;
+ }
+
+ if (this->XLines)
+ {
+ delete this->XLines;
+ this->XLines = 0;
+ }
+ if (this->Parser)
+ {
+ delete this->Parser;
+ this->Parser = 0;
+
+ if (this->stats)
+ {
+ delete this->stats;
+ this->stats = 0;
+ }
+
+ if (this->Modules)
+ {
+ delete this->Modules;
+ this->Modules = 0;
+ }
+
+ if (this->BanCache)
+ delete this->BanCache;
+ this->BanCache = 0;
+ }
+
+ if (this->SNO)
+ {
+ delete this->SNO;
+ this->SNO = 0;
+ }
+
+ if (this->Config)
+ {
+ delete this->Config;
+ this->Config = 0;
+ }
+
+ if (this->Res)
+ {
+ delete this->Res;
+ this->Res = 0;
+ }
+
+ if (this->chanlist)
+ {
+ delete chanlist;
+ chanlist = 0;
+ }
+
+ if (this->PI)
+ {
+ delete this->PI;
+ this->PI = 0;
+ }
+
+ if (this->Threads)
+ {
+ delete this->Threads;
+ this->Threads = 0;
+ }
+
+ /* Needs to be deleted after Res, DNS has a timer */
+ if (this->Timers)
+ {
+ delete this->Timers;
+ this->Timers = 0;
+ }
+
+ /* Close logging */
+ this->Logs->CloseLogs();
+
+ if (this->Logs)
+ {
+ delete this->Logs;
+ this->Logs = 0;
+ }
}
void InspIRCd::Restart(const std::string &reason)
@@ -312,7 +406,11 @@ InspIRCd::InspIRCd(int argc, char** argv)
{
#ifdef WIN32
+ // Strict, frequent checking of memory on debug builds
_CrtSetDbgFlag ( _CRTDBG_CHECK_ALWAYS_DF | _CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF );
+
+ // Avoid erroneous frees on early exit
+ WindowsIPC = 0;
#endif
int found_ports = 0;
FailedPortList pl;
@@ -320,6 +418,24 @@ InspIRCd::InspIRCd(int argc, char** argv)
do_nolog = 0, do_root = 0, do_testsuite = 0; /* flag variables */
char c = 0;
+ // Initialize so that if we exit before proper initialization they're not deleted
+ this->Logs = 0;
+ this->Threads = 0;
+ this->PI = 0;
+ this->Users = 0;
+ this->chanlist = 0;
+ this->Config = 0;
+ this->SNO = 0;
+ this->BanCache = 0;
+ this->Modules = 0;
+ this->stats = 0;
+ this->Timers = 0;
+ this->Parser = 0;
+ this->XLines = 0;
+ this->Modes = 0;
+ this->Res = 0;
+
+
memset(&server, 0, sizeof(server));
memset(&client, 0, sizeof(client));
@@ -348,8 +464,6 @@ InspIRCd::InspIRCd(int argc, char** argv)
this->Users->uuidlist = new user_hash();
this->chanlist = new chan_hash();
- this->Res = NULL;
-
this->Config = new ServerConfig(this);
this->SNO = new SnomaskManager(this);
this->BanCache = new BanCacheManager(this);
@@ -530,6 +644,7 @@ InspIRCd::InspIRCd(int argc, char** argv)
Config->sid[0] = (char)(sid / 100 + 48);
Config->sid[1] = (char)(((sid / 10) % 10) + 48);
Config->sid[2] = (char)(sid % 10 + 48);
+ Config->sid[3] = '\0';
}
/* set up fake client again this time with the correct uid */
diff --git a/src/mode.cpp b/src/mode.cpp
index e562a8551..e5efaffdf 100644
--- a/src/mode.cpp
+++ b/src/mode.cpp
@@ -1125,9 +1125,8 @@ ModeParser::ModeParser(InspIRCd* Instance) : ServerInstance(Instance)
NULL
};
- /* Clear mode list */
+ /* Clear mode handler list */
memset(modehandlers, 0, sizeof(modehandlers));
- memset(modewatchers, 0, sizeof(modewatchers));
/* Last parse string */
LastParse.clear();
diff --git a/src/modes/cmode_l.cpp b/src/modes/cmode_l.cpp
index 5c9db31df..4ed95bc2c 100644
--- a/src/modes/cmode_l.cpp
+++ b/src/modes/cmode_l.cpp
@@ -92,6 +92,4 @@ ModeAction ModeChannelLimit::OnModeChange(User*, User*, Channel* channel, std::s
return MODEACTION_ALLOW;
}
-
- return MODEACTION_DENY;
}
diff --git a/src/modules.cpp b/src/modules.cpp
index df6876b1a..617d5a0fa 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -602,14 +602,12 @@ bool ModuleManager::PublishInterface(const std::string &InterfaceName, Module* M
modulelist ml;
ml.push_back(Mod);
Interfaces[InterfaceName] = std::make_pair(0, ml);
- return true;
}
else
{
iter->second.second.push_back(Mod);
- return true;
}
- return false;
+ return true;
}
bool ModuleManager::UnpublishInterface(const std::string &InterfaceName, Module* Mod)
diff --git a/src/server.cpp b/src/server.cpp
index c713a028f..ae1d106b8 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -34,7 +34,8 @@ void InspIRCd::SignalHandler(int signal)
void InspIRCd::Exit(int status)
{
#ifdef WINDOWS
- delete WindowsIPC;
+ if (WindowsIPC)
+ delete WindowsIPC;
#endif
if (this)
{
diff --git a/src/snomasks.cpp b/src/snomasks.cpp
index de900623d..e6323b50c 100644
--- a/src/snomasks.cpp
+++ b/src/snomasks.cpp
@@ -24,7 +24,12 @@ SnomaskManager::SnomaskManager(InspIRCd* Instance) : ServerInstance(Instance)
}
SnomaskManager::~SnomaskManager()
-{
+{
+ for (std::map<char, Snomask *>::iterator i = SnoMasks.begin(); i != SnoMasks.end(); i++)
+ {
+ delete i->second;
+ }
+ SnoMasks.clear();
}
void SnomaskManager::FlushSnotices()
diff --git a/src/xline.cpp b/src/xline.cpp
index 47e122420..610af2e6c 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -391,6 +391,18 @@ XLineManager::~XLineManager()
delete KFact;
delete QFact;
delete ZFact;
+
+ // Delete all existing XLines
+ for (XLineContainer::iterator i = lookup_lines.begin(); i != lookup_lines.end(); i++)
+ {
+ for (XLineLookup::iterator j = i->second.begin(); j != i->second.end(); j++)
+ {
+ delete j->second;
+ }
+ i->second.clear();
+ }
+ lookup_lines.clear();
+
}
void XLine::Apply(User* u)
diff --git a/win/configure.cpp b/win/configure.cpp
index a7351739e..a6dab1ffd 100644
--- a/win/configure.cpp
+++ b/win/configure.cpp
@@ -552,7 +552,11 @@ void WriteCompileCommands()
#endif
#endif
- fprintf(f, "makedir:\n if not exist debug mkdir debug\n if not exist release mkdir release\n\n");
+#ifdef _DEBUG
+ fprintf(f, "makedir:\n if not exist debug mkdir debug\n if not exist ..\\..\\bin\\debug\\lib mkdir ..\\..\\bin\\debug\\lib\n\n");
+#else
+ fprintf(f, "makedir:\n if not exist release mkdir release\n if not exist ..\\..\\bin\\release\\lib mkdir ..\\..\\bin\\release\\lib\n\n");
+#endif
// dump modules.. again the second and last time :)
for(int i = 0; i < command_count; ++i)
@@ -623,7 +627,11 @@ void WriteCompileModules()
#endif
#endif
- fprintf(f, "makedir:\n if not exist debug mkdir debug\n if not exist release mkdir release\n\n");
+#ifdef _DEBUG
+ fprintf(f, "makedir:\n if not exist debug mkdir debug\n if not exist ..\\..\\bin\\debug\\modules mkdir ..\\..\\bin\\debug\\modules\n\n");
+#else
+ fprintf(f, "makedir:\n if not exist release mkdir release\n if not exist ..\\..\\bin\\release\\modules mkdir ..\\..\\bin\\release\\modules\n\n");
+#endif
// dump modules.. again the second and last time :)
for(int i = 0; i < module_count; ++i)
diff --git a/win/m_spanningtreeVC80.vcproj b/win/m_spanningtreeVC80.vcproj
index 2367ef4ec..2477756d9 100644
--- a/win/m_spanningtreeVC80.vcproj
+++ b/win/m_spanningtreeVC80.vcproj
@@ -101,9 +101,9 @@
/>
</Configuration>
<Configuration
- Name="Release|Win32"
- OutputDirectory="..\bin\release\modules"
- IntermediateDirectory="Release"
+ Name="Debug|x64"
+ OutputDirectory="..\bin\debug_x64\modules"
+ IntermediateDirectory="x64Debug_spanningtree"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
@@ -122,18 +122,18 @@
/>
<Tool
Name="VCMIDLTool"
+ TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalOptions="/MP"
- Optimization="1"
- WholeProgramOptimization="true"
+ Optimization="0"
AdditionalIncludeDirectories="..\include;..\win;..\src\modules\m_spanningtree;.;..\src\modules"
- PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;M_SPANNINGTREE_EXPORTS;DLL_BUILD"
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;DLL_BUILD;WIN64"
MinimalRebuild="true"
- RuntimeLibrary="2"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="1"
UsePrecompiledHeader="0"
- WarningLevel="2"
+ WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
@@ -148,18 +148,15 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalOptions="/MD"
- AdditionalDependencies="ws2_32.lib inspircd.lib cmd_whois.lib cmd_stats.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib"
+ AdditionalDependencies="ws2_32.lib inspircd.lib cmd_whois.lib cmd_stats.lib"
OutputFile="$(OutDir)/m_spanningtree.so"
LinkIncremental="1"
- AdditionalLibraryDirectories="..\bin\release\bin;..\bin\release\lib"
+ AdditionalLibraryDirectories="..\bin\debug_x64\bin;..\bin\debug_x64\lib"
GenerateDebugInformation="true"
+ ProgramDatabaseFile="$(OutDir)/m_spanningtree.pdb"
SubSystem="2"
- OptimizeReferences="2"
- EnableCOMDATFolding="2"
- LinkTimeCodeGeneration="1"
ImportLibrary="$(OutDir)/m_spanningtree.lib"
- TargetMachine="1"
+ TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
@@ -184,14 +181,12 @@
/>
<Tool
Name="VCPostBuildEventTool"
- Description="Re-basing shared objects..."
- CommandLine="@cd $(InputDir)&#x0D;&#x0A;@$(InputDir)\rebase.bat&#x0D;&#x0A;"
/>
</Configuration>
<Configuration
- Name="Debug|x64"
- OutputDirectory="..\bin\debug_x64\modules"
- IntermediateDirectory="x64Debug_spanningtree"
+ Name="Release|Win32"
+ OutputDirectory="..\bin\release\modules"
+ IntermediateDirectory="Release"
ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2"
@@ -210,18 +205,17 @@
/>
<Tool
Name="VCMIDLTool"
- TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
- Optimization="0"
+ Optimization="1"
+ WholeProgramOptimization="true"
AdditionalIncludeDirectories="..\include;..\win;..\src\modules\m_spanningtree;.;..\src\modules"
- PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;DLL_BUILD;WIN64"
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;M_SPANNINGTREE_EXPORTS;DLL_BUILD"
MinimalRebuild="true"
- BasicRuntimeChecks="3"
- RuntimeLibrary="1"
+ RuntimeLibrary="2"
UsePrecompiledHeader="0"
- WarningLevel="3"
+ WarningLevel="2"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
@@ -236,15 +230,18 @@
/>
<Tool
Name="VCLinkerTool"
- AdditionalDependencies="ws2_32.lib inspircd.lib cmd_whois.lib cmd_stats.lib"
+ AdditionalOptions="/MD"
+ AdditionalDependencies="ws2_32.lib inspircd.lib cmd_whois.lib cmd_stats.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib"
OutputFile="$(OutDir)/m_spanningtree.so"
LinkIncremental="1"
- AdditionalLibraryDirectories="..\bin\debug_x64\bin;..\bin\debug_x64\lib"
+ AdditionalLibraryDirectories="..\bin\release\bin;..\bin\release\lib"
GenerateDebugInformation="true"
- ProgramDatabaseFile="$(OutDir)/m_spanningtree.pdb"
SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ LinkTimeCodeGeneration="1"
ImportLibrary="$(OutDir)/m_spanningtree.lib"
- TargetMachine="17"
+ TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
@@ -269,6 +266,8 @@
/>
<Tool
Name="VCPostBuildEventTool"
+ Description="Re-basing shared objects..."
+ CommandLine="@cd $(InputDir)&#x0D;&#x0A;@&quot;$(InputDir)\rebase.bat&quot;&#x0D;&#x0A;"
/>
</Configuration>
<Configuration