]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Fix global clone count not being decremented on remote user quit
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 1 Nov 2009 21:53:47 +0000 (21:53 +0000)
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 1 Nov 2009 21:53:47 +0000 (21:53 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11984 e03df62e-2008-0410-955e-edbf42e46eb7

include/users.h
src/usermanager.cpp
src/users.cpp

index 48f2b470c9bc1742484cfbd34cc32baa94410c7e..ed649f1b9758c7d5d6e166d34edc4b03b694e11d 100644 (file)
@@ -723,7 +723,7 @@ class CoreExport LocalUser : public User
        InvitedList invites;
 
  public:
-       LocalUser();
+       LocalUser(int fd, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
        CullResult cull();
 
        /** Stats counter for bytes inbound
index f620a264d07d0b7112da96b6ab12f11573747d63..05f5d2c9dbcaa0c7437c6c44ad540214db513c9a 100644 (file)
@@ -24,7 +24,7 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs
        LocalUser* New = NULL;
        try
        {
-               New = new LocalUser();
+               New = new LocalUser(socket, client, server);
        }
        catch (...)
        {
@@ -33,10 +33,6 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs
                return;
        }
 
-       New->SetFd(socket);
-       memcpy(&New->client_sa, client, sizeof(irc::sockets::sockaddrs));
-       memcpy(&New->server_sa, server, sizeof(irc::sockets::sockaddrs));
-
        /* Give each of the modules an attempt to hook the user for I/O */
        FOREACH_MOD(I_OnHookIO, OnHookIO(New, via));
 
@@ -56,10 +52,9 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs
 
        this->unregistered_count++;
 
-       (*(this->clientlist))[New->uuid] = New;
-
        /* The users default nick is their UUID */
        New->nick.assign(New->uuid, 0, ServerInstance->Config->Limits.NickMax);
+       (*(this->clientlist))[New->nick] = New;
 
        New->ident.assign("unknown");
 
@@ -271,13 +266,16 @@ void UserManager::AddGlobalClone(User *user)
 
 void UserManager::RemoveCloneCounts(User *user)
 {
-       clonemap::iterator x = local_clones.find(user->GetCIDRMask());
-       if (x != local_clones.end())
+       if (IS_LOCAL(user))
        {
-               x->second--;
-               if (!x->second)
+               clonemap::iterator x = local_clones.find(user->GetCIDRMask());
+               if (x != local_clones.end())
                {
-                       local_clones.erase(x);
+                       x->second--;
+                       if (!x->second)
+                       {
+                               local_clones.erase(x);
+                       }
                }
        }
 
index 58c1050473701b5e7c44f1f813bca41ac670129f..c2cda4aea003280fb53ba9ec4937a33ddca766a4 100644 (file)
@@ -239,12 +239,16 @@ User::User(const std::string &uid, const std::string& sid, int type)
                throw CoreException("Duplicate UUID "+std::string(uuid)+" in User constructor");
 }
 
-LocalUser::LocalUser() : User(ServerInstance->GetUID(), ServerInstance->Config->ServerName, USERTYPE_LOCAL)
+LocalUser::LocalUser(int myfd, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* servaddr)
+       : User(ServerInstance->GetUID(), ServerInstance->Config->ServerName, USERTYPE_LOCAL)
 {
        bytes_in = bytes_out = cmds_in = cmds_out = 0;
        server_sa.sa.sa_family = AF_UNSPEC;
        Penalty = 0;
        lastping = nping = 0;
+       SetFd(myfd);
+       memcpy(&client_sa, client, sizeof(irc::sockets::sockaddrs));
+       memcpy(&server_sa, servaddr, sizeof(irc::sockets::sockaddrs));
 }
 
 User::~User()
@@ -588,6 +592,9 @@ CullResult User::cull()
        this->InvalidateCache();
        this->DecrementModes();
 
+       if (client_sa.sa.sa_family != AF_UNSPEC)
+               ServerInstance->Users->RemoveCloneCounts(this);
+
        ServerInstance->Users->uuidlist->erase(uuid);
        return Extensible::cull();
 }
@@ -600,8 +607,6 @@ CullResult LocalUser::cull()
        else
                ServerInstance->Logs->Log("USERS", DEBUG, "Failed to remove user from vector");
 
-       if (client_sa.sa.sa_family != AF_UNSPEC)
-               ServerInstance->Users->RemoveCloneCounts(this);
        Close();
        return User::cull();
 }