summaryrefslogtreecommitdiff
path: root/src/cull_list.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-02-28 12:07:03 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-02-28 12:07:03 +0000
commitb477cc1c3439faa8f50a46a0c5f3dd9082007bec (patch)
tree0c2aa15c9ee0d707e5591563cb742214c17c2d3f /src/cull_list.cpp
parentdc6720574e9a07327c3924e459029426effb450e (diff)
Made it safe to quits and nickchanges
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3379 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/cull_list.cpp')
-rw-r--r--src/cull_list.cpp40
1 files changed, 31 insertions, 9 deletions
diff --git a/src/cull_list.cpp b/src/cull_list.cpp
index f1dd5b4d9..b06b80f7f 100644
--- a/src/cull_list.cpp
+++ b/src/cull_list.cpp
@@ -51,6 +51,17 @@ using namespace std;
extern InspIRCd* ServerInstance;
+bool CullList::IsValid(userrec* user)
+{
+ for (user_hash::iterator u = clientlist.begin(); u != clientlist.end(); u++)
+ {
+ userrec* u2 = (userrec*)*u;
+ if (user == u2)
+ return true;
+ }
+ return false;
+}
+
CullItem::CullItem(userrec* u, std::string r)
{
this->user = u;
@@ -79,6 +90,7 @@ void CullList::AddItem(userrec* user, std::string reason)
{
CullItem item(user,reason);
list.push_back(item);
+ names.push_back(user->nick);
exempt[user] = 1;
}
}
@@ -90,17 +102,27 @@ int CullList::Apply()
{
std::vector<CullItem>::iterator a = list.begin();
userrec* u = a->GetUser();
- kill_link(u,a->GetReason().c_str());
- list.erase(list.begin());
- /* So that huge numbers of quits dont block,
- * we yield back to our mainloop every 15
- * iterations.
- * The DoOneIteration call basically acts
- * like a software threading mechanism.
+ /* Because ServerInstance->DoOneIteration can
+ * take the user away from us in the middle of
+ * our operation, we should check to see if this
+ * pointer is still valid by iterating the hash.
+ * It's expensive, yes, but the DoOneIteration
+ * call stops it being horrendously bad.
*/
- if ((n++ % 15) == 0)
+ if (IsValid(u))
{
- ServerInstance->DoOneIteration(false);
+ kill_link(u,a->GetReason().c_str());
+ list.erase(list.begin());
+ /* So that huge numbers of quits dont block,
+ * we yield back to our mainloop every 15
+ * iterations.
+ * The DoOneIteration call basically acts
+ * like a software threading mechanism.
+ */
+ if (((n++) % 15) == 0)
+ {
+ ServerInstance->DoOneIteration(false);
+ }
}
}
return n;