diff options
author | Attila Molnar <attilamolnar@hush.com> | 2014-01-24 13:08:13 +0100 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-01-24 13:08:13 +0100 |
commit | f1f8173bb5ca5f5ce01ad92d0ccd309f232fc138 (patch) | |
tree | f9dc48385b78066d8da9fba546f979d6686f4be3 /src | |
parent | 932e8d13f81c7c94a89dc3702f6d45bc185f5dcf (diff) |
Convert LocalUserList to an intrusively linked list
Diffstat (limited to 'src')
-rw-r--r-- | src/inspircd.cpp | 9 | ||||
-rw-r--r-- | src/usermanager.cpp | 5 | ||||
-rw-r--r-- | src/users.cpp | 13 | ||||
-rw-r--r-- | src/xline.cpp | 6 |
4 files changed, 9 insertions, 24 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp index fb33f1937..12962d92d 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -107,12 +107,9 @@ void InspIRCd::Cleanup() ports.clear(); /* Close all client sockets, or the new process inherits them */ - LocalUserList::reverse_iterator i = Users->local_users.rbegin(); - while (i != this->Users->local_users.rend()) - { - User* u = *i++; - Users->QuitUser(u, "Server shutdown"); - } + LocalUserList& list = Users->local_users; + for (LocalUserList::iterator i = list.begin(); i != list.end(); ++i) + Users->QuitUser(*i, "Server shutdown"); GlobalCulls.Apply(); Modules->UnloadAll(); diff --git a/src/usermanager.cpp b/src/usermanager.cpp index 29d1f7370..13646f225 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -28,7 +28,7 @@ UserManager::UserManager() : clientlist(new user_hash) , uuidlist(new user_hash) - , unregistered_count(0), local_count(0) + , unregistered_count(0) { } @@ -81,8 +81,7 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs ServerInstance->Users->AddLocalClone(New); ServerInstance->Users->AddGlobalClone(New); - New->localuseriter = this->local_users.insert(local_users.end(), New); - local_count++; + this->local_users.push_front(New); if ((this->local_users.size() > ServerInstance->Config->SoftLimit) || (this->local_users.size() >= (unsigned int)ServerInstance->SE->GetMaxFds())) { diff --git a/src/users.cpp b/src/users.cpp index df42d2a9c..6ec46883f 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -86,7 +86,6 @@ User::User(const std::string& uid, Server* srv, int type) LocalUser::LocalUser(int myfd, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* servaddr) : User(ServerInstance->UIDGen.GetUID(), ServerInstance->FakeClient->server, 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) { @@ -337,17 +336,7 @@ CullResult User::cull() CullResult LocalUser::cull() { - // 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_count--; - ServerInstance->Users->local_users.erase(localuseriter); - } - else - ServerInstance->Logs->Log("USERS", LOG_DEFAULT, "ERROR: LocalUserIter does not point to a valid entry for " + this->nick); - + ServerInstance->Users->local_users.erase(this); ClearInvites(); eh.cull(); return User::cull(); diff --git a/src/xline.cpp b/src/xline.cpp index 63a64d6b9..d2fd9a5be 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -430,10 +430,10 @@ void XLineManager::ExpireLine(ContainerIter container, LookupIter item) // applies lines, removing clients and changing nicks etc as applicable void XLineManager::ApplyLines() { - LocalUserList::reverse_iterator u2 = ServerInstance->Users->local_users.rbegin(); - while (u2 != ServerInstance->Users->local_users.rend()) + LocalUserList& list = ServerInstance->Users->local_users; + for (LocalUserList::iterator j = list.begin(); j != list.end(); ++j) { - LocalUser* u = *u2++; + LocalUser* u = *j; // Don't ban people who are exempt. if (u->exempt) |