From dc6720574e9a07327c3924e459029426effb450e Mon Sep 17 00:00:00 2001 From: brain Date: Tue, 28 Feb 2006 11:55:21 +0000 Subject: When quitting large amounts of users, use InspIRCd::DoOneIteration to prevent too much lag git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3378 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/cull_list.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/src/cull_list.cpp b/src/cull_list.cpp index 5a589b144..f1dd5b4d9 100644 --- a/src/cull_list.cpp +++ b/src/cull_list.cpp @@ -43,11 +43,14 @@ using namespace std; #include "commands.h" #include "xline.h" #include "inspstring.h" +#include "inspircd.h" #include "helperfuncs.h" #include "hashcomp.h" #include "typedefs.h" #include "cull_list.h" +extern InspIRCd* ServerInstance; + CullItem::CullItem(userrec* u, std::string r) { this->user = u; @@ -85,12 +88,20 @@ int CullList::Apply() int n = 0; while (list.size()) { - std::vector::iterator a = list.begin(); - userrec* u = a->GetUser(); - std::string reason = a->GetReason(); - kill_link(u,reason.c_str()); - list.erase(list.begin()); - n++; + std::vector::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. + */ + if ((n++ % 15) == 0) + { + ServerInstance->DoOneIteration(false); + } } return n; } -- cgit v1.2.3