From 228665b0ab71ed83d2a987433117e8510bc76f78 Mon Sep 17 00:00:00 2001 From: w00t Date: Tue, 8 Jan 2008 23:27:29 +0000 Subject: Fix problem #1 by setting a lock on writes when we're reading. This means no more stupid/pointless writes. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8670 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_xline_db.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/modules/m_xline_db.cpp b/src/modules/m_xline_db.cpp index 93b13029d..d77f8e919 100644 --- a/src/modules/m_xline_db.cpp +++ b/src/modules/m_xline_db.cpp @@ -19,12 +19,17 @@ class ModuleXLineDB : public Module { std::vector xlines; + bool reading_db; // If this is true, addlines are as a result of db reading, so don't bother flushing the db to disk. + // DO REMEMBER TO SET IT, otherwise it's annoying :P public: ModuleXLineDB(InspIRCd* Me) : Module(Me) { Implementation eventlist[] = { I_OnAddLine, I_OnDelLine }; ServerInstance->Modules->Attach(eventlist, this, 2); + + reading_db = true; ReadDatabase(); + reading_db = false; } virtual ~ModuleXLineDB() @@ -47,7 +52,10 @@ class ModuleXLineDB : public Module ServerInstance->Config->ServerName, line->set_time, line->duration, line->reason); } - WriteDatabase(); + if (!reading_db) + { + WriteDatabase(); + } } /** Called whenever an xline is deleted. -- cgit v1.2.3