aboutsummaryrefslogtreecommitdiffstats
path: root/src/xline.cpp
diff options
context:
space:
mode:
authorGravatar Sadie Powell2020-02-19 01:29:45 +0000
committerGravatar Sadie Powell2020-02-19 01:29:45 +0000
commit7bdd72f634f994dcbd9bfbc865d0087143fb748d (patch)
tree11784350f097d56704426e604fdc0009ec35afb2 /src/xline.cpp
parentMove FindNickOnly to UserManager. (diff)
parentBump the module ABI version. (diff)
Merge branch 'insp3' into master.
Diffstat (limited to 'src/xline.cpp')
-rw-r--r--src/xline.cpp38
1 files changed, 17 insertions, 21 deletions
diff --git a/src/xline.cpp b/src/xline.cpp
index 012e9c53a..e3b2b82e2 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -477,35 +477,31 @@ void XLineManager::ApplyLines()
pending_lines.clear();
}
-void XLineManager::InvokeStats(const std::string& type, unsigned int numeric, Stats::Context& stats)
+bool XLineManager::InvokeStats(const std::string& type, Stats::Context& context)
{
- ContainerIter n = lookup_lines.find(type);
-
- time_t current = ServerInstance->Time();
-
- LookupIter safei;
+ ContainerIter citer = lookup_lines.find(type);
+ if (citer == lookup_lines.end())
+ return false;
- if (n != lookup_lines.end())
+ for (LookupIter liter = citer->second.begin(); liter != citer->second.end(); )
{
- XLineLookup& list = n->second;
- for (LookupIter i = list.begin(); i != list.end(); )
- {
- safei = i;
- safei++;
+ // We might be about to expire the XLine so we have to increment the
+ // iterator early to avoid doing that causing iterator invalidation.
+ LookupIter current = liter++;
- if (i->second->duration && current > i->second->expiry)
- {
- ExpireLine(n, i);
- }
- else
- stats.AddRow(numeric, i->second->Displayable()+" "+
- ConvToStr(i->second->set_time)+" "+ConvToStr(i->second->duration)+" "+i->second->source+" :"+i->second->reason);
- i = safei;
+ XLine* xline = current->second;
+ if (xline->duration && xline->expiry <= ServerInstance->Time())
+ {
+ // This XLine has expired so remove and skip it.
+ ExpireLine(citer, current);
+ continue;
}
+
+ context.AddRow(RPL_STATS, context.GetSymbol(), xline->Displayable(), xline->set_time, xline->duration, xline->source, xline->reason);
}
+ return true;
}
-
XLineManager::XLineManager()
{
GLineFactory* GFact;