diff options
author | peavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-11-13 00:45:37 +0000 |
---|---|---|
committer | peavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-11-13 00:45:37 +0000 |
commit | 41f62a2a3badd6b7dbffb4fdb995c41ef709462c (patch) | |
tree | b87fbf24939d47fe28a066716e0a61682f2d8f87 /src/users.cpp | |
parent | f09dc35b5b03eb19e70333fbb8e5fe6f92c7edee (diff) |
add <whowas> config option to control whowas behaviour. *may break*
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5731 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/users.cpp')
-rw-r--r-- | src/users.cpp | 55 |
1 files changed, 53 insertions, 2 deletions
diff --git a/src/users.cpp b/src/users.cpp index 5d6ac2ce7..f3278186b 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -869,7 +869,7 @@ namespace irc whowas_set* n = (whowas_set*)iter->second; if (n->size()) { - while ((n->begin() != n->end()) && ((*n->begin())->signon < t - 259200)) // 3 days + while ((n->begin() != n->end()) && ((*n->begin())->signon < t - ServerInstance->Config->WhoWasMaxKeep)) { WhoWasGroup *a = *(n->begin()); DELETE(a); @@ -878,6 +878,51 @@ namespace irc } } } + /* on rehash, refactor maps according to new conf values */ + void PruneWhoWas(InspIRCd* ServerInstance, time_t t) + { + int groupsize = ServerInstance->Config->WhoWasGroupSize; + int maxgroups = ServerInstance->Config->WhoWasMaxGroups; + int maxkeep = ServerInstance->Config->WhoWasMaxKeep; + + int groupcount = 0; + for (whowas_users_fifo::iterator iter = ServerInstance->whowas_fifo.begin(); iter != ServerInstance->whowas_fifo.end(); iter++) + { + groupcount++; + + if (groupcount > maxgroups || iter->first < t - maxkeep) + { + whowas_set* n = (whowas_set*)ServerInstance->whowas.find(iter->second)->second; + if (n->size()) + { + while (n->begin() != n->end()) + { + WhoWasGroup *a = *(n->begin()); + DELETE(a); + n->erase(n->begin()); + } + } + ServerInstance->whowas.erase(iter->second); + ServerInstance->whowas_fifo.erase(iter->first); + } + else { + whowas_set* n = (whowas_set*)ServerInstance->whowas.find(iter->second)->second; + if (n->size()) + { + int nickcount = 0; + while (n->begin() != n->end()) + { + nickcount++; + if (nickcount > groupsize){ + WhoWasGroup *a = *(n->begin()); + DELETE(a); + n->erase(n->begin()); + } + } + } + } + } + } }; }; @@ -895,6 +940,12 @@ void userrec::AddToWhoWas() irc::whowas::WhoWasGroup *a = new irc::whowas::WhoWasGroup(this); n->push_back(a); ServerInstance->whowas[this->nick] = n; + ServerInstance->whowas_fifo[ServerInstance->Time()] = this->nick; + if ((int)(ServerInstance->whowas.size()) > ServerInstance->Config->WhoWasMaxGroups) + { + ServerInstance->whowas.erase(ServerInstance->whowas_fifo.begin()->second); + ServerInstance->whowas_fifo.erase(ServerInstance->whowas_fifo.begin()); + } } else { @@ -902,7 +953,7 @@ void userrec::AddToWhoWas() ServerInstance->Log(DEBUG,"Using existing whowas group for %s",this->nick); - if (group->size() > 10) + if ((int)(group->size()) > ServerInstance->Config->WhoWasMaxGroups) { ServerInstance->Log(DEBUG,"Trimming existing group to ten entries for %s",this->nick); irc::whowas::WhoWasGroup *a = (irc::whowas::WhoWasGroup*)*(group->begin()); |