From 9eadffd061f3586247a42f470a957142d6173889 Mon Sep 17 00:00:00 2001 From: brain Date: Sun, 22 Apr 2007 10:18:54 +0000 Subject: Fix memory consumption of m_slence, users silence lists arent deleted till they quit, they should be deleted when they empty their list to save ram git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6823 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_silence.cpp | 21 +++++++++------------ src/modules/m_silence_ext.cpp | 25 ++++++++++--------------- 2 files changed, 19 insertions(+), 27 deletions(-) (limited to 'src') diff --git a/src/modules/m_silence.cpp b/src/modules/m_silence.cpp index 5c8e5fdef..9aa891129 100644 --- a/src/modules/m_silence.cpp +++ b/src/modules/m_silence.cpp @@ -79,22 +79,19 @@ class cmd_silence : public command_t // does it contain any entries and does it exist? if (sl) { - if (sl->size()) + silencelist::iterator i = sl->find(mask.c_str()); + if (i != sl->end()) { - silencelist::iterator i = sl->find(mask.c_str()); - if (i != sl->end()) + sl->erase(i); + user->WriteServ("950 %s %s :Removed %s from silence list",user->nick, user->nick, mask.c_str()); + if (!sl->size()) { - sl->erase(i); - user->WriteServ("950 %s %s :Removed %s from silence list",user->nick, user->nick, mask.c_str()); + // tidy up -- if a user's list is empty, theres no use having it + // hanging around in the user record. + DELETE(sl); + user->Shrink("silence_list"); } } - else - { - // tidy up -- if a user's list is empty, theres no use having it - // hanging around in the user record. - DELETE(sl); - user->Shrink("silence_list"); - } } } else if (action == '+') diff --git a/src/modules/m_silence_ext.cpp b/src/modules/m_silence_ext.cpp index ba76abc29..8b40c90bb 100644 --- a/src/modules/m_silence_ext.cpp +++ b/src/modules/m_silence_ext.cpp @@ -117,27 +117,22 @@ class cmd_silence : public command_t // does it contain any entries and does it exist? if (sl) { - if (sl->size()) + for (silencelist::iterator i = sl->begin(); i != sl->end(); i++) { - for (silencelist::iterator i = sl->begin(); i != sl->end(); i++) + // search through for the item + irc::string listitem = i->first.c_str(); + if (listitem == mask && i->second == pattern) { - // search through for the item - irc::string listitem = i->first.c_str(); - if (listitem == mask && i->second == pattern) + sl->erase(i); + user->WriteServ("950 %s %s :Removed %s %s from silence list",user->nick, user->nick, mask.c_str(), DecompPattern(pattern).c_str()); + if (!sl->size()) { - sl->erase(i); - user->WriteServ("950 %s %s :Removed %s %s from silence list",user->nick, user->nick, mask.c_str(), DecompPattern(pattern).c_str()); - break; + DELETE(sl); + user->Shrink("silence_list"); } + break; } } - else - { - // tidy up -- if a user's list is empty, theres no use having it - // hanging around in the user record. - DELETE(sl); - user->Shrink("silence_list"); - } } } else if (action == '+') -- cgit v1.2.3