From f11df046884c1c8692e6d2748a983a56a2217e17 Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 2 Nov 2007 15:58:46 +0000 Subject: 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 --- src/xline.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) 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); } -- cgit v1.2.3