1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 #include "cull_list.h"
19 * In current implementation of CullList, this isn't used. It did odd things with a lot of sockets.
21 bool CullList::IsValid(userrec* user)
24 std::map<userrec*,time_t>::iterator es = exempt.find(user);
25 if (es != exempt.end())
28 for (user_hash::iterator u = ServerInstance->clientlist.begin(); u != ServerInstance->clientlist.end(); u++)
33 * Because there is an undetermined period of time between a user existing,
34 * and this function being called, we have to check for the following condition:
36 * Between CullList::AddItem(u) being called, and CullList::IsValid(u) being called,
37 * the user with the pointer u has quit, but only to be REPLACED WITH A NEW USER WHO
38 * BECAUSE OF ALLOCATION RULES, HAS THE SAME MEMORY ADDRESS! To prevent this, we
39 * cross reference each pointer to the user's signon time, and if the signon times
40 * do not match, we return false here to indicate this user is NOT valid as it
41 * seems to differ from the pointer snapshot we got a few seconds earlier. Should
42 * prevent a few random crashes during netsplits.
44 if (user == u->second)
45 return (u->second->signon == esignon);
50 CullItem::CullItem(userrec* u, std::string &r)
56 CullItem::CullItem(userrec* u, const char* r)
66 userrec* CullItem::GetUser()
71 std::string& CullItem::GetReason()
76 CullList::CullList(InspIRCd* Instance) : ServerInstance(Instance)
82 void CullList::AddItem(userrec* user, std::string &reason)
84 if (exempt.find(user) == exempt.end())
86 CullItem item(user,reason);
88 exempt[user] = user->signon;
92 void CullList::AddItem(userrec* user, const char* reason)
94 if (exempt.find(user) == exempt.end())
96 CullItem item(user,reason);
98 exempt[user] = user->signon;
102 int CullList::Apply()
107 std::vector<CullItem>::iterator a = list.begin();
109 userrec::QuitUser(ServerInstance, a->GetUser(), a->GetReason().c_str());
110 list.erase(list.begin());