summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/commands/cmd_rehash.cpp1
-rw-r--r--src/inspircd.cpp37
-rw-r--r--src/server.cpp1
-rw-r--r--src/usermanager.cpp11
4 files changed, 12 insertions, 38 deletions
diff --git a/src/commands/cmd_rehash.cpp b/src/commands/cmd_rehash.cpp
index abf0b7876..1ad96d794 100644
--- a/src/commands/cmd_rehash.cpp
+++ b/src/commands/cmd_rehash.cpp
@@ -88,7 +88,6 @@ CmdResult CommandRehash::Handle (const std::vector<std::string>& parameters, Use
/* Don't do anything with the logs here -- logs are restarted
* after the config thread has completed.
*/
- ServerInstance->RehashUsersAndChans();
FOREACH_MOD(I_OnGarbageCollect, OnGarbageCollect());
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 9ab7b9dbe..c34908378 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -191,41 +191,6 @@ void InspIRCd::ResetMaxBans()
i->second->ResetMaxBans();
}
-/** Because hash_map doesn't free its buckets when we delete items, we occasionally
- * recreate the hash to free them up.
- * We do this by copying the entries from the old hash to a new hash, causing all
- * empty buckets to be weeded out of the hash.
- * Since this is quite expensive, it's not done very often.
- */
-void InspIRCd::RehashUsersAndChans()
-{
- user_hash* old_users = Users->clientlist;
- Users->clientlist = new user_hash;
- for (user_hash::const_iterator n = old_users->begin(); n != old_users->end(); n++)
- Users->clientlist->insert(*n);
- delete old_users;
-
- user_hash* old_uuid = Users->uuidlist;
- Users->uuidlist = new user_hash;
- for (user_hash::const_iterator n = old_uuid->begin(); n != old_uuid->end(); n++)
- Users->uuidlist->insert(*n);
- delete old_uuid;
-
- chan_hash* old_chans = chanlist;
- chanlist = new chan_hash;
- for (chan_hash::const_iterator n = old_chans->begin(); n != old_chans->end(); n++)
- chanlist->insert(*n);
- delete old_chans;
-
- // Reset the already_sent IDs so we don't wrap it around and drop a message
- LocalUser::already_sent_id = 0;
- for (LocalUserList::const_iterator i = Users->local_users.begin(); i != Users->local_users.end(); i++)
- {
- (**i).already_sent = 0;
- (**i).RemoveExpiredInvites();
- }
-}
-
void InspIRCd::SetSignals()
{
#ifndef _WIN32
@@ -818,7 +783,7 @@ int InspIRCd::Run()
if ((TIME.tv_sec % 3600) == 0)
{
- this->RehashUsersAndChans();
+ Users->GarbageCollect();
FOREACH_MOD(I_OnGarbageCollect, OnGarbageCollect());
}
diff --git a/src/server.cpp b/src/server.cpp
index 4741f942d..691ab3842 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -59,7 +59,6 @@ void InspIRCd::Exit(int status)
void RehashHandler::Call(const std::string &reason)
{
ServerInstance->SNO->WriteToSnoMask('a', "Rehashing config file %s %s",ServerConfig::CleanFilename(ServerInstance->ConfigFileName.c_str()), reason.c_str());
- ServerInstance->RehashUsersAndChans();
FOREACH_MOD(I_OnGarbageCollect, OnGarbageCollect());
if (!ServerInstance->ConfigThread)
{
diff --git a/src/usermanager.cpp b/src/usermanager.cpp
index 58cbb7e5b..2d9c3f281 100644
--- a/src/usermanager.cpp
+++ b/src/usermanager.cpp
@@ -389,3 +389,14 @@ int UserManager::ModeCount(const char mode)
}
return c;
}
+
+void UserManager::GarbageCollect()
+{
+ // Reset the already_sent IDs so we don't wrap it around and drop a message
+ LocalUser::already_sent_id = 0;
+ for (LocalUserList::const_iterator i = this->local_users.begin(); i != this->local_users.end(); i++)
+ {
+ (**i).already_sent = 0;
+ (**i).RemoveExpiredInvites();
+ }
+}