From f85fdf431e6ba24019315ab35d6fe0c76f24934f Mon Sep 17 00:00:00 2001 From: brain Date: Sat, 23 Dec 2006 23:58:26 +0000 Subject: Better checks for NULL log handles git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6083 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/inspircd.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/inspircd.cpp b/src/inspircd.cpp index c8be0d019..694627d83 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -959,7 +959,8 @@ bool FileLogger::Readable() void FileLogger::HandleEvent(EventType et, int errornum) { this->WriteLogLine(""); - ServerInstance->SE->DelFd(this); + if (log) + ServerInstance->SE->DelFd(this); } void FileLogger::WriteLogLine(const std::string &line) @@ -1000,18 +1001,24 @@ void FileLogger::Close() fcntl(fileno(log), F_SETFL, flags ^ O_NONBLOCK); if (buffer.size()) fprintf(log,"%s",buffer.c_str()); + + ServerInstance->SE->DelFd(this); + fflush(log); fclose(log); } + buffer = ""; - ServerInstance->SE->DelFd(this); } FileLogger::FileLogger(InspIRCd* Instance, FILE* logfile) : ServerInstance(Instance), log(logfile), writeops(0) { - irc::sockets::NonBlocking(fileno(log)); - this->SetFd(fileno(log)); - buffer = ""; + if (log) + { + irc::sockets::NonBlocking(fileno(log)); + this->SetFd(fileno(log)); + buffer = ""; + } } FileLogger::~FileLogger() -- cgit v1.2.3