summaryrefslogtreecommitdiff
path: root/src/inspircd.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-08-23 19:57:02 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-08-23 19:57:02 +0000
commit443b0f9645d861ca47a6f041a46703e27da7c0c8 (patch)
treeb87e52ce40b681dea0127d4d5375a88d5fad8d8e /src/inspircd.cpp
parentab7a861a91fd204603775b8d06b1d99c1593229f (diff)
Raft of fixes so that inspircd can call Cleanup() and Exit() in less 'stable' circumstances, e.g. when half initialized, and it wont segfault.
Also fix OpenLog to not always exit on error, but to return a bool instead, which is much more friendly on rehash (you don't want /REHASH dieing your server if you cant write the log!) git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7804 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/inspircd.cpp')
-rw-r--r--src/inspircd.cpp38
1 files changed, 25 insertions, 13 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 6d7a26579..4c19878d7 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -77,13 +77,16 @@ void InspIRCd::Cleanup()
std::vector<std::string> mymodnames;
int MyModCount = this->GetModuleCount();
- for (unsigned int i = 0; i < Config->ports.size(); i++)
+ if (Config)
{
- /* This calls the constructor and closes the listening socket */
- delete Config->ports[i];
- }
+ for (unsigned int i = 0; i < Config->ports.size(); i++)
+ {
+ /* This calls the constructor and closes the listening socket */
+ delete Config->ports[i];
+ }
- Config->ports.clear();
+ Config->ports.clear();
+ }
/* Close all client sockets, or the new process inherits them */
for (std::vector<userrec*>::const_iterator i = this->local_users.begin(); i != this->local_users.end(); i++)
@@ -101,16 +104,20 @@ void InspIRCd::Cleanup()
MyModCount = this->GetModuleCount();
mymodnames.clear();
- /* Unload all modules, so they get a chance to clean up their listeners */
- for (int j = 0; j <= MyModCount; j++)
- mymodnames.push_back(Config->module_names[j]);
+ if (MyModCount)
+ {
+ /* Unload all modules, so they get a chance to clean up their listeners */
+ for (int j = 0; j <= MyModCount; j++)
+ mymodnames.push_back(Config->module_names[j]);
- for (int k = 0; k <= MyModCount; k++)
- this->UnloadModule(mymodnames[k].c_str());
+ for (int k = 0; k <= MyModCount; k++)
+ this->UnloadModule(mymodnames[k].c_str());
+ }
}
/* Close logging */
- this->Logger->Close();
+ if (this->Logger)
+ this->Logger->Close();
/* Cleanup Server Names */
for(servernamelist::iterator itr = servernames.begin(); itr != servernames.end(); ++itr)
@@ -183,7 +190,8 @@ void InspIRCd::RehashUsersAndChans()
void InspIRCd::CloseLog()
{
- this->Logger->Close();
+ if (this->Logger)
+ this->Logger->Close();
}
void InspIRCd::SetSignals()
@@ -411,7 +419,11 @@ InspIRCd::InspIRCd(int argc, char** argv)
strlcpy(Config->MyExecutable,argv[0],MAXBUF);
- this->OpenLog(argv, argc);
+ if (!this->OpenLog(argv, argc))
+ {
+ printf("ERROR: Could not open logfile %s: %s\n\n", Config->logpath.c_str(), strerror(errno));
+ Exit(EXIT_STATUS_LOG);
+ }
this->stats = new serverstats();
this->Timers = new TimerManager(this);