diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-08-23 19:57:02 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-08-23 19:57:02 +0000 |
commit | 443b0f9645d861ca47a6f041a46703e27da7c0c8 (patch) | |
tree | b87e52ce40b681dea0127d4d5375a88d5fad8d8e /src/helperfuncs.cpp | |
parent | ab7a861a91fd204603775b8d06b1d99c1593229f (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/helperfuncs.cpp')
-rw-r--r-- | src/helperfuncs.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index 7fba47699..9363e3376 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -31,7 +31,7 @@ static time_t LAST = 0; void InspIRCd::Log(int level, const char* text, ...) { /* sanity check, just in case */ - if (!this->Config) + if (!this->Config || !this->Logger) return; /* Do this check again here so that we save pointless vsnprintf calls */ @@ -51,7 +51,7 @@ void InspIRCd::Log(int level, const char* text, ...) void InspIRCd::Log(int level, const std::string &text) { /* sanity check, just in case */ - if (!this->Config) + if (!this->Config || !this->Logger) return; /* If we were given -debug we output all messages, regardless of configured loglevel */ @@ -442,7 +442,7 @@ bool IsIdentHandler::Call(const char* n) } /* open the proper logfile */ -void InspIRCd::OpenLog(char** argv, int argc) +bool InspIRCd::OpenLog(char** argv, int argc) { Config->MyDir = Config->GetFullProgDir(); @@ -462,11 +462,12 @@ void InspIRCd::OpenLog(char** argv, int argc) if (!Config->log_file) { - printf("ERROR: Could not write to logfile %s: %s\n\n", Config->logpath.c_str(), strerror(errno)); - exit(EXIT_STATUS_LOG); + this->Logger = NULL; + return false; } this->Logger = new FileLogger(this, Config->log_file); + return true; } void InspIRCd::CheckRoot() |