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"
34 #include "inspstring.h"
39 #include "cull_list.h"
42 * In current implementation of CullList, this isn't used. It did odd things with a lot of sockets.
44 bool CullList::IsValid(userrec* user)
47 std::map<userrec*,time_t>::iterator es = exempt.find(user);
48 if (es != exempt.end())
51 for (user_hash::iterator u = ServerInstance->clientlist.begin(); u != ServerInstance->clientlist.end(); u++)
56 * Because there is an undetermined period of time between a user existing,
57 * and this function being called, we have to check for the following condition:
59 * Between CullList::AddItem(u) being called, and CullList::IsValid(u) being called,
60 * the user with the pointer u has quit, but only to be REPLACED WITH A NEW USER WHO
61 * BECAUSE OF ALLOCATION RULES, HAS THE SAME MEMORY ADDRESS! To prevent this, we
62 * cross reference each pointer to the user's signon time, and if the signon times
63 * do not match, we return false here to indicate this user is NOT valid as it
64 * seems to differ from the pointer snapshot we got a few seconds earlier. Should
65 * prevent a few random crashes during netsplits.
67 if (user == u->second)
68 return (u->second->signon == esignon);
73 CullItem::CullItem(userrec* u, std::string &r)
79 CullItem::CullItem(userrec* u, const char* r)
89 userrec* CullItem::GetUser()
94 std::string& CullItem::GetReason()
99 CullList::CullList(InspIRCd* Instance) : ServerInstance(Instance)
105 void CullList::AddItem(userrec* user, std::string &reason)
107 if (exempt.find(user) == exempt.end())
109 CullItem item(user,reason);
110 list.push_back(item);
111 exempt[user] = user->signon;
115 void CullList::AddItem(userrec* user, const char* reason)
117 if (exempt.find(user) == exempt.end())
119 CullItem item(user,reason);
120 list.push_back(item);
121 exempt[user] = user->signon;
125 int CullList::Apply()
130 std::vector<CullItem>::iterator a = list.begin();
132 userrec::QuitUser(ServerInstance, a->GetUser(), a->GetReason().c_str());
133 list.erase(list.begin());