From 1e3c3d20088c148f20f2237cea54310ca4a8b98c Mon Sep 17 00:00:00 2001
From: brain
Date: Wed, 10 Jan 2007 17:46:38 +0000
Subject: Clever stuff for applying lines (this needs testing); When bursting,
we clear a bitmask to 0. When we receive glines etc, we OR bits in the
bitmask to values of APPLY_GLINES, APPLY_KLINES etc depending on what we've
received, e.g. is it ADDLINE G, or ADDLINE K. When we ENDBURST at the end of
the burst, pass the bitmask to apply_lines, rather than APPLY_ALL :) NOTE:
While not bursting, the bitmask is flushed after each gline, but this is
still faster as only the line type we just added will be ORed in.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6289 e03df62e-2008-0410-955e-edbf42e46eb7
---
src/modules/m_spanningtree.cpp | 31 ++++++++++++++++++++++++++-----
1 file changed, 26 insertions(+), 5 deletions(-)
(limited to 'src/modules/m_spanningtree.cpp')
diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp
index df302a7bf..0687db515 100644
--- a/src/modules/m_spanningtree.cpp
+++ b/src/modules/m_spanningtree.cpp
@@ -167,6 +167,11 @@ class SpanningTreeUtilities
/** Holds the data from the tags in the conf
*/
std::vector LinkBlocks;
+ /** Holds a bitmask of queued xline types waiting to be applied.
+ * Will be a mask containing values APPLY_GLINES, APPLY_KLINES,
+ * APPLY_QLINES and APPLY_ZLINES.
+ */
+ int lines_to_apply;
hookmodules hooks;
std::vector hooknames;
@@ -2635,15 +2640,20 @@ class TreeSocket : public InspSocket
bool propogate = false;
+ if (!this->bursting)
+ Utils->lines_to_apply = 0;
+
switch (*(params[0].c_str()))
{
case 'Z':
propogate = Instance->XLines->add_zline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str());
Instance->XLines->zline_set_creation_time(params[1].c_str(), atoi(params[3].c_str()));
+ Utils->lines_to_apply |= APPLY_ZLINES;
break;
case 'Q':
propogate = Instance->XLines->add_qline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str());
Instance->XLines->qline_set_creation_time(params[1].c_str(), atoi(params[3].c_str()));
+ Utils->lines_to_apply |= APPLY_QLINES;
break;
case 'E':
propogate = Instance->XLines->add_eline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str());
@@ -2652,9 +2662,11 @@ class TreeSocket : public InspSocket
case 'G':
propogate = Instance->XLines->add_gline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str());
Instance->XLines->gline_set_creation_time(params[1].c_str(), atoi(params[3].c_str()));
+ Utils->lines_to_apply |= APPLY_GLINES;
break;
case 'K':
propogate = Instance->XLines->add_kline(atoi(params[4].c_str()), params[2].c_str(), params[5].c_str(), params[1].c_str());
+ Utils->lines_to_apply |= APPLY_KLINES;
break;
default:
/* Just in case... */
@@ -2679,8 +2691,9 @@ class TreeSocket : public InspSocket
}
if (!this->bursting)
{
- Instance->Log(DEBUG,"Applying lines...");
- Instance->XLines->apply_lines(APPLY_ZLINES|APPLY_GLINES|APPLY_QLINES);
+ Instance->Log(DEBUG,"Applying lines with mask %d...", Utils->lines_to_apply);
+ Instance->XLines->apply_lines(Utils->lines_to_apply);
+ Utils->lines_to_apply = 0;
}
return true;
}
@@ -3368,7 +3381,9 @@ class TreeSocket : public InspSocket
if (this->bursting)
{
this->bursting = false;
- Instance->XLines->apply_lines(APPLY_ZLINES|APPLY_GLINES|APPLY_QLINES);
+ Instance->Log(DEBUG,"Applying lines with mask %d...", Utils->lines_to_apply);
+ Instance->XLines->apply_lines(Utils->lines_to_apply);
+ Utils->lines_to_apply = 0;
}
if (prefix == "")
{
@@ -3386,7 +3401,9 @@ class TreeSocket : public InspSocket
if (this->bursting)
{
this->bursting = false;
- Instance->XLines->apply_lines(APPLY_ZLINES|APPLY_GLINES|APPLY_QLINES);
+ Instance->Log(DEBUG,"Applying lines with mask %d...", Utils->lines_to_apply);
+ Instance->XLines->apply_lines(Utils->lines_to_apply);
+ Utils->lines_to_apply = 0;
}
if (prefix == "")
{
@@ -3513,7 +3530,9 @@ class TreeSocket : public InspSocket
else if (command == "ENDBURST")
{
this->bursting = false;
- Instance->XLines->apply_lines(APPLY_ZLINES|APPLY_GLINES|APPLY_QLINES);
+ Instance->Log(DEBUG,"Applying lines with mask %d...", Utils->lines_to_apply);
+ Instance->XLines->apply_lines(Utils->lines_to_apply);
+ Utils->lines_to_apply = 0;
std::string sourceserv = this->myhost;
if (this->InboundServerName != "")
{
@@ -3784,6 +3803,8 @@ SpanningTreeUtilities::SpanningTreeUtilities(InspIRCd* Instance, ModuleSpanningT
{
Bindings.clear();
+ lines_to_apply = 0;
+
this->TreeRoot = new TreeServer(this, ServerInstance, ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc);
modulelist* ml = ServerInstance->FindInterface("InspSocketHook");
--
cgit v1.3.1-10-gc9f91