summaryrefslogtreecommitdiff
path: root/include/inspircd.h
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-18 22:01:26 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-18 22:01:26 +0000
commit5adcab2223c1f64550f24c2b1d49d1299ceb69d5 (patch)
tree8614a97923ebf4f1ff2fbc3df4109928a3fe1e81 /include/inspircd.h
parent365fd7e1e903e99d7e3399487d1cf9204ebe64fa (diff)
NONBLOCKING LOGGER!
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4971 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'include/inspircd.h')
-rw-r--r--include/inspircd.h53
1 files changed, 51 insertions, 2 deletions
diff --git a/include/inspircd.h b/include/inspircd.h
index 44f5b519c..d72b5f5b7 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -125,6 +125,55 @@ class serverstats : public classbase
}
};
+class InspIRCd;
+
+/** This class implements a nonblocking log-writer.
+ * Most people writing an ircd give little thought to their disk
+ * i/o. On a congested system, disk writes can block for long
+ * periods of time (e.g. if the system is busy and/or swapping
+ * a lot). If we just use a blocking fprintf() call, this could
+ * block for undesirable amounts of time (half of a second through
+ * to whole seconds). We DO NOT want this, so we make our logfile
+ * nonblocking and hook it into the SocketEngine.
+ */
+class FileLogger : public EventHandler
+{
+ protected:
+ /** The creator/owner of this object
+ */
+ InspIRCd* ServerInstance;
+ /** The log file (fd is inside this somewhere,
+ * we get it out with fileno())
+ */
+ FILE* log;
+ /** Buffer of pending log lines to be written
+ */
+ std::string buffer;
+ /** Number of write operations that have occured
+ */
+ int writeops;
+ public:
+ /** The constructor takes an already opened logfile
+ */
+ FileLogger(InspIRCd* Instance, FILE* logfile);
+ /** This returns false, logfiles are writeable
+ */
+ bool Readable();
+ /** Handle pending write events
+ */
+ void HandleEvent(EventType et);
+ /** Write one or more preformatted log lines
+ */
+ void WriteLogLine(const std::string &line);
+ /** Close the log file and cancel any events.
+ */
+ void Close();
+ /** Close the log file and cancel any events.
+ * (indirectly call Close()
+ */
+ ~FileLogger();
+};
+
class XLineManager;
/** The main singleton class of the irc server.
@@ -279,9 +328,9 @@ class InspIRCd : public classbase
*/
socklen_t length;
- /** Used to count iterations around the mainloop
+ /** Nonblocking file writer
*/
- int iterations;
+ FileLogger* Logger;
public:
/** Time this ircd was booted