summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-02-28 11:55:21 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-02-28 11:55:21 +0000
commitdc6720574e9a07327c3924e459029426effb450e (patch)
treed0b428f8dbfbec667945b4bd4f2335ce17da184a /src
parent7e918919b0fdb9d0ed7c8e8bd3b02bf86b1591e7 (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/cull_list.cpp23
1 files changed, 17 insertions, 6 deletions
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<CullItem>::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<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.
+ */
+ if ((n++ % 15) == 0)
+ {
+ ServerInstance->DoOneIteration(false);
+ }
}
return n;
}