1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
19 #include "inspircd_config.h"
21 #include "inspircd_io.h"
24 #include <sys/errno.h>
28 #include <ext/hash_map>
45 #include "inspstring.h"
47 #include "helperfuncs.h"
50 #include "cull_list.h"
52 extern InspIRCd* ServerInstance;
53 extern user_hash clientlist;
55 bool CullList::IsValid(userrec* user)
57 for (user_hash::iterator u = clientlist.begin(); u != clientlist.end(); u++)
59 if (user == u->second)
65 CullItem::CullItem(userrec* u, std::string r)
71 userrec* CullItem::GetUser()
76 std::string CullItem::GetReason()
87 void CullList::AddItem(userrec* user, std::string reason)
89 if (exempt.find(user) == exempt.end())
91 CullItem item(user,reason);
102 std::vector<CullItem>::iterator a = list.begin();
103 userrec* u = a->GetUser();
104 /* Because ServerInstance->DoOneIteration can
105 * take the user away from us in the middle of
106 * our operation, we should check to see if this
107 * pointer is still valid by iterating the hash.
108 * It's expensive, yes, but the DoOneIteration
109 * call stops it being horrendously bad.
113 kill_link(u,a->GetReason().c_str());
114 list.erase(list.begin());
115 /* So that huge numbers of quits dont block,
116 * we yield back to our mainloop every 15
118 * The DoOneIteration call basically acts
119 * like a software threading mechanism.
121 if (((n++) % 15) == 0)
123 ServerInstance->DoOneIteration(false);