summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-11-02 15:58:46 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2007-11-02 15:58:46 +0000
commitf11df046884c1c8692e6d2748a983a56a2217e17 (patch)
tree869b339ad204648de7d5b302d006d49924d48ce4 /src
parentebbc4b3d54e3176d6c4c77493cb5cc0157b5c006 (diff)
Expire lines on burst, and ensure that if an eline expires while we're checking elines, the iterator is not trashed
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8465 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/xline.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/src/xline.cpp b/src/xline.cpp
index b41b69c89..c44bf9017 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -73,10 +73,18 @@ void XLineManager::CheckELines()
{
User* u = (User*)(*u2);
- for (LookupIter i = ELines.begin(); i != ELines.end(); i++)
+ /* This uses safe iteration to ensure that if a line expires here, it doenst trash the iterator */
+ LookupIter safei;
+
+ for (LookupIter i = ELines.begin(); i != ELines.end(); )
{
+ safei = i;
+ safei++;
+
XLine *e = i->second;
u->exempt = e->Matches(u);
+
+ i = safei;
}
}
}
@@ -89,6 +97,21 @@ XLineLookup* XLineManager::GetAll(const std::string &type)
if (n == lookup_lines.end())
return NULL;
+ LookupIter safei;
+ const time_t current = ServerInstance->Time();
+
+ /* Expire any dead ones, before sending */
+ for (LookupIter x = n->second.begin(); x != n->second.end(); )
+ {
+ safei = x;
+ safei++;
+ if (current > x->second->expiry)
+ {
+ ExpireLine(n, x);
+ }
+ x = safei;
+ }
+
return &(n->second);
}