Skip to content

Commit

Permalink
Rebuild clone counts on rehash
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam- committed Mar 21, 2015
1 parent c85a46f commit 7f051bc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
4 changes: 4 additions & 0 deletions include/usermanager.h
Expand Up @@ -112,6 +112,10 @@ class CoreExport UserManager
*/
void RemoveCloneCounts(User *user);

/** Rebuild clone counts
*/
void RehashCloneCounts();

/** Return the number of global clones of this user
* @param user The user to get a count for
* @return The global clone count of this user
Expand Down
1 change: 1 addition & 0 deletions src/configreader.cpp
Expand Up @@ -963,6 +963,7 @@ void ConfigReaderThread::Finish()
* XXX: The order of these is IMPORTANT, do not reorder them without testing
* thoroughly!!!
*/
ServerInstance->Users->RehashCloneCounts();
ServerInstance->XLines->CheckELines();
ServerInstance->XLines->ApplyLines();
ServerInstance->Res->Rehash();
Expand Down
16 changes: 16 additions & 0 deletions src/usermanager.cpp
Expand Up @@ -287,6 +287,22 @@ void UserManager::RemoveCloneCounts(User *user)
}
}

void UserManager::RehashCloneCounts()
{
local_clones.clear();
global_clones.clear();

const user_hash& hash = *ServerInstance->Users->clientlist;
for (user_hash::const_iterator i = hash.begin(); i != hash.end(); ++i)
{
User* u = i->second;

if (IS_LOCAL(u))
AddLocalClone(u);
AddGlobalClone(u);
}
}

unsigned long UserManager::GlobalCloneCount(User *user)
{
clonemap::iterator x = global_clones.find(user->GetCIDRMask());
Expand Down

0 comments on commit 7f051bc

Please sign in to comment.