Better checks for NULL log handles

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6083 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
brain 2006-12-23 23:58:26 +00:00
parent e473ba1a25
commit f85fdf431e

View File

@ -959,6 +959,7 @@ bool FileLogger::Readable()
void FileLogger::HandleEvent(EventType et, int errornum) void FileLogger::HandleEvent(EventType et, int errornum)
{ {
this->WriteLogLine(""); this->WriteLogLine("");
if (log)
ServerInstance->SE->DelFd(this); ServerInstance->SE->DelFd(this);
} }
@ -1000,19 +1001,25 @@ void FileLogger::Close()
fcntl(fileno(log), F_SETFL, flags ^ O_NONBLOCK); fcntl(fileno(log), F_SETFL, flags ^ O_NONBLOCK);
if (buffer.size()) if (buffer.size())
fprintf(log,"%s",buffer.c_str()); fprintf(log,"%s",buffer.c_str());
ServerInstance->SE->DelFd(this);
fflush(log); fflush(log);
fclose(log); fclose(log);
} }
buffer = ""; buffer = "";
ServerInstance->SE->DelFd(this);
} }
FileLogger::FileLogger(InspIRCd* Instance, FILE* logfile) : ServerInstance(Instance), log(logfile), writeops(0) FileLogger::FileLogger(InspIRCd* Instance, FILE* logfile) : ServerInstance(Instance), log(logfile), writeops(0)
{
if (log)
{ {
irc::sockets::NonBlocking(fileno(log)); irc::sockets::NonBlocking(fileno(log));
this->SetFd(fileno(log)); this->SetFd(fileno(log));
buffer = ""; buffer = "";
} }
}
FileLogger::~FileLogger() FileLogger::~FileLogger()
{ {