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 * ---------------------------------------------------
21 #include "cull_list.h"
24 * In current implementation of CullList, this isn't used. It did odd things with a lot of sockets.
26 bool CullList::IsValid(userrec* user)
29 std::map<userrec*,time_t>::iterator es = exempt.find(user);
30 if (es != exempt.end())
33 for (user_hash::iterator u = ServerInstance->clientlist.begin(); u != ServerInstance->clientlist.end(); u++)
38 * Because there is an undetermined period of time between a user existing,
39 * and this function being called, we have to check for the following condition:
41 * Between CullList::AddItem(u) being called, and CullList::IsValid(u) being called,
42 * the user with the pointer u has quit, but only to be REPLACED WITH A NEW USER WHO
43 * BECAUSE OF ALLOCATION RULES, HAS THE SAME MEMORY ADDRESS! To prevent this, we
44 * cross reference each pointer to the user's signon time, and if the signon times
45 * do not match, we return false here to indicate this user is NOT valid as it
46 * seems to differ from the pointer snapshot we got a few seconds earlier. Should
47 * prevent a few random crashes during netsplits.
49 if (user == u->second)
50 return (u->second->signon == esignon);
55 CullItem::CullItem(userrec* u, std::string &r)
61 CullItem::CullItem(userrec* u, const char* r)
71 userrec* CullItem::GetUser()
76 std::string& CullItem::GetReason()
81 CullList::CullList(InspIRCd* Instance) : ServerInstance(Instance)
87 void CullList::AddItem(userrec* user, std::string &reason)
89 if (exempt.find(user) == exempt.end())
91 CullItem item(user,reason);
93 exempt[user] = user->signon;
97 void CullList::AddItem(userrec* user, const char* reason)
99 if (exempt.find(user) == exempt.end())
101 CullItem item(user,reason);
102 list.push_back(item);
103 exempt[user] = user->signon;
107 int CullList::Apply()
112 std::vector<CullItem>::iterator a = list.begin();
114 userrec::QuitUser(ServerInstance, a->GetUser(), a->GetReason().c_str());
115 list.erase(list.begin());