mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-09 18:49:03 -04:00
Make LocalUserList an std::list
This commit is contained in:
parent
a589577b68
commit
74b05d5500
@ -66,7 +66,7 @@ struct ResourceRecord;
|
||||
|
||||
/** A list holding local users, this is the type of UserManager::local_users
|
||||
*/
|
||||
typedef std::vector<LocalUser*> LocalUserList;
|
||||
typedef std::list<LocalUser*> LocalUserList;
|
||||
|
||||
/** A list of failed port bindings, used for informational purposes on startup */
|
||||
typedef std::vector<std::pair<std::string, std::string> > FailedPortList;
|
||||
|
@ -52,7 +52,7 @@ class CoreExport UserManager
|
||||
*/
|
||||
user_hash* uuidlist;
|
||||
|
||||
/** Local client list, a vector containing only local clients
|
||||
/** Local client list, a list containing only local clients
|
||||
*/
|
||||
LocalUserList local_users;
|
||||
|
||||
|
@ -747,6 +747,10 @@ class CoreExport LocalUser : public User, public InviteBase
|
||||
|
||||
UserIOHandler eh;
|
||||
|
||||
/** Position in UserManager::local_users
|
||||
*/
|
||||
LocalUserList::iterator localuseriter;
|
||||
|
||||
/** Stats counter for bytes inbound
|
||||
*/
|
||||
int bytes_in;
|
||||
|
@ -73,7 +73,7 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs
|
||||
ServerInstance->Users->AddLocalClone(New);
|
||||
ServerInstance->Users->AddGlobalClone(New);
|
||||
|
||||
this->local_users.push_back(New);
|
||||
New->localuseriter = this->local_users.insert(local_users.end(), New);
|
||||
|
||||
if ((this->local_users.size() > ServerInstance->Config->SoftLimit) || (this->local_users.size() >= (unsigned int)ServerInstance->SE->GetMaxFds()))
|
||||
{
|
||||
|
@ -219,6 +219,7 @@ User::User(const std::string &uid, const std::string& sid, int type)
|
||||
|
||||
LocalUser::LocalUser(int myfd, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* servaddr)
|
||||
: User(ServerInstance->GetUID(), ServerInstance->Config->ServerName, USERTYPE_LOCAL), eh(this),
|
||||
localuseriter(ServerInstance->Users->local_users.end()),
|
||||
bytes_in(0), bytes_out(0), cmds_in(0), cmds_out(0), nping(0), CommandFloodPenalty(0),
|
||||
already_sent(0)
|
||||
{
|
||||
@ -539,11 +540,11 @@ CullResult User::cull()
|
||||
|
||||
CullResult LocalUser::cull()
|
||||
{
|
||||
LocalUserList::iterator x = find(ServerInstance->Users->local_users.begin(),ServerInstance->Users->local_users.end(),this);
|
||||
if (x != ServerInstance->Users->local_users.end())
|
||||
ServerInstance->Users->local_users.erase(x);
|
||||
else
|
||||
ServerInstance->Logs->Log("USERS", DEBUG, "Failed to remove user from vector");
|
||||
// The iterator is initialized to local_users.end() in the constructor. It is
|
||||
// overwritten in UserManager::AddUser() with the real iterator so this check
|
||||
// is only a precaution currently.
|
||||
if (localuseriter != ServerInstance->Users->local_users.end())
|
||||
ServerInstance->Users->local_users.erase(localuseriter);
|
||||
|
||||
ClearInvites();
|
||||
eh.cull();
|
||||
|
Loading…
x
Reference in New Issue
Block a user