From 443b0f9645d861ca47a6f041a46703e27da7c0c8 Mon Sep 17 00:00:00 2001 From: brain Date: Thu, 23 Aug 2007 19:57:02 +0000 Subject: 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 --- src/helperfuncs.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/helperfuncs.cpp') 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() -- cgit v1.3.1-10-gc9f91