summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/inspircd.h6
-rw-r--r--include/usermanager.h6
-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
6 files changed, 18 insertions, 44 deletions
diff --git a/include/inspircd.h b/include/inspircd.h
index 099b9dd87..2e1cfbd21 100644
--- a/include/inspircd.h
+++ b/include/inspircd.h
@@ -822,12 +822,6 @@ class CoreExport InspIRCd
*/
void Cleanup();
- /** This copies the user and channel hash_maps into new hash maps.
- * This frees memory used by the hash_map allocator (which it neglects
- * to free, most of the time, using tons of ram)
- */
- void RehashUsersAndChans();
-
/** Resets the cached max bans value on all channels.
* Called by rehash.
*/
diff --git a/include/usermanager.h b/include/usermanager.h
index 3d7fe88fb..812d8e2f2 100644
--- a/include/usermanager.h
+++ b/include/usermanager.h
@@ -70,6 +70,12 @@ class CoreExport UserManager
*/
clonemap global_clones;
+ /**
+ * Reset the already_sent IDs so we don't wrap it around and drop a message
+ * Also removes all expired invites
+ */
+ void GarbageCollect();
+
/** Add a client to the system.
* This will create a new User, insert it into the user_hash,
* initialize it as not yet registered, and add it to the socket engine.
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();
+ }
+}