summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2012-11-21 00:53:57 +0100
committerattilamolnar <attilamolnar@hush.com>2012-11-29 23:41:22 +0100
commit74b05d550081fb7a7b41a145cfbc333f8774d438 (patch)
tree7aa3c4931ecf1bec4e7f856b4edde052b426af6c /src
parenta589577b68cb84bc877ecdd4c0f9cb84a1581ddd (diff)
Make LocalUserList an std::list
Diffstat (limited to 'src')
-rw-r--r--src/usermanager.cpp2
-rw-r--r--src/users.cpp11
2 files changed, 7 insertions, 6 deletions
diff --git a/src/usermanager.cpp b/src/usermanager.cpp
index 279b1d3ec..bef7ccbcc 100644
--- a/src/usermanager.cpp
+++ b/src/usermanager.cpp
@@ -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()))
{
diff --git a/src/users.cpp b/src/users.cpp
index 7cfbdbc0c..e55c7e099 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -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();