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;
54 bool CullList::IsValid(userrec* user)
56 for (user_hash::iterator u = clientlist.begin(); u != clientlist.end(); u++)
58 userrec* u2 = (userrec*)*u;
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);
93 names.push_back(user->nick);
103 std::vector<CullItem>::iterator a = list.begin();
104 userrec* u = a->GetUser();
105 /* Because ServerInstance->DoOneIteration can
106 * take the user away from us in the middle of
107 * our operation, we should check to see if this
108 * pointer is still valid by iterating the hash.
109 * It's expensive, yes, but the DoOneIteration
110 * call stops it being horrendously bad.
114 kill_link(u,a->GetReason().c_str());
115 list.erase(list.begin());
116 /* So that huge numbers of quits dont block,
117 * we yield back to our mainloop every 15
119 * The DoOneIteration call basically acts
120 * like a software threading mechanism.
122 if (((n++) % 15) == 0)
124 ServerInstance->DoOneIteration(false);