diff options
author | Sadie Powell <sadie@witchery.services> | 2020-02-18 17:49:32 +0000 |
---|---|---|
committer | Sadie Powell <sadie@witchery.services> | 2020-02-18 18:56:14 +0000 |
commit | 2e0cc3684df72b2a8de45b354848af43c6b47606 (patch) | |
tree | 5fb6b9f587309746c2311e5e3043062523cdc122 /src/xline.cpp | |
parent | 5ddbcd3f56bb79a5dc6b693fc2c6ad7a46ba5a3c (diff) |
Generalise XLine stats numerics using RPL_STATS from aircd.
Diffstat (limited to 'src/xline.cpp')
-rw-r--r-- | src/xline.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/xline.cpp b/src/xline.cpp index 13ea2f97c..04ac67f68 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -498,13 +498,36 @@ void XLineManager::InvokeStats(const std::string& type, unsigned int numeric, St 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); + stats.AddRow(numeric, i->second->Displayable(), i->second->set_time, i->second->duration, i->second->source, i->second->reason); i = safei; } } } +bool XLineManager::InvokeStats(const std::string& type, Stats::Context& context) +{ + ContainerIter citer = lookup_lines.find(type); + if (citer == lookup_lines.end()) + return false; + + for (LookupIter liter = citer->second.begin(); liter != citer->second.end(); ) + { + // 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++; + + 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() { |