summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/users.h2
-rw-r--r--src/cmd_whowas.cpp13
-rw-r--r--src/inspircd.cpp2
-rw-r--r--src/users.cpp17
4 files changed, 22 insertions, 12 deletions
diff --git a/include/users.h b/include/users.h
index 4633f1cd2..a682554f1 100644
--- a/include/users.h
+++ b/include/users.h
@@ -826,7 +826,7 @@ namespace irc
/** Called every hour by the core to remove expired entries
*/
- void MaintainWhoWas(time_t TIME);
+ void MaintainWhoWas(InspIRCd* ServerInstance, time_t TIME);
};
};
diff --git a/src/cmd_whowas.cpp b/src/cmd_whowas.cpp
index fe3171fc5..399214d70 100644
--- a/src/cmd_whowas.cpp
+++ b/src/cmd_whowas.cpp
@@ -18,8 +18,6 @@
#include "users.h"
#include "commands/cmd_whowas.h"
-
-
extern "C" command_t* init_command(InspIRCd* Instance)
{
return new cmd_whowas(Instance);
@@ -29,18 +27,24 @@ CmdResult cmd_whowas::Handle (const char** parameters, int pcnt, userrec* user)
{
irc::whowas::whowas_users::iterator i = ServerInstance->whowas.find(parameters[0]);
+ ServerInstance->Log(DEBUG,"Entered cmd_whowas");
+
if (i == ServerInstance->whowas.end())
{
+ ServerInstance->Log(DEBUG,"No such nick in whowas");
user->WriteServ("406 %s %s :There was no such nickname",user->nick,parameters[0]);
+ user->WriteServ("369 %s %s :End of WHOWAS",user->nick,parameters[0]);
return CMD_FAILURE;
}
else
{
+ ServerInstance->Log(DEBUG,"Whowas set found");
irc::whowas::whowas_set* grp = i->second;
if (grp->size())
{
for (irc::whowas::whowas_set::iterator ux = grp->begin(); ux != grp->end(); ux++)
{
+ ServerInstance->Log(DEBUG,"Spool whowas entry");
irc::whowas::WhoWasGroup* u = *ux;
time_t rawtime = u->signon;
tm *timeinfo;
@@ -65,12 +69,13 @@ CmdResult cmd_whowas::Handle (const char** parameters, int pcnt, userrec* user)
}
else
{
+ ServerInstance->Log(DEBUG,"Oops, empty whowas set found");
user->WriteServ("406 %s %s :There was no such nickname",user->nick,parameters[0]);
+ user->WriteServ("369 %s %s :End of WHOWAS",user->nick,parameters[0]);
return CMD_FAILURE;
}
}
-
- user->WriteServ("369 %s %s :End of WHOWAS",user->nick,parameters[0]);
+ user->WriteServ("369 %s %s :End of WHOWAS",user->nick,parameters[0]);
return CMD_SUCCESS;
}
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 2f35c9528..e9c459394 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -664,7 +664,7 @@ void InspIRCd::DoOneIteration(bool process_module_sockets)
WriteOpers("*** \002EH?!\002 -- Time is flowing BACKWARDS in this dimension! Clock drifted backwards %d secs.",abs(OLDTIME-TIME));
if ((TIME % 3600) == 0)
{
- irc::whowas::MaintainWhoWas(TIME);
+ irc::whowas::MaintainWhoWas(this, TIME);
}
Timers->TickTimers(TIME);
this->DoBackgroundUserStuff(TIME);
diff --git a/src/users.cpp b/src/users.cpp
index e80a476f3..51692958c 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -24,7 +24,6 @@
#include "xline.h"
#include "cull_list.h"
-irc::whowas::whowas_users whowas;
static unsigned long already_sent[MAX_DESCRIPTORS] = {0};
typedef std::map<irc::string,char*> opertype_t;
@@ -809,9 +808,9 @@ namespace irc
}
/* every hour, run this function which removes all entries over 3 days */
- void MaintainWhoWas(time_t t)
+ void MaintainWhoWas(InspIRCd* ServerInstance, time_t t)
{
- for (whowas_users::iterator iter = ::whowas.begin(); iter != ::whowas.end(); iter++)
+ for (whowas_users::iterator iter = ServerInstance->whowas.begin(); iter != ServerInstance->whowas.end(); iter++)
{
whowas_set* n = (whowas_set*)iter->second;
if (n->size())
@@ -831,21 +830,27 @@ namespace irc
/* adds or updates an entry in the whowas list */
void userrec::AddToWhoWas()
{
- irc::whowas::whowas_users::iterator iter = whowas.find(this->nick);
+ irc::whowas::whowas_users::iterator iter = ServerInstance->whowas.find(this->nick);
- if (iter == whowas.end())
+ ServerInstance->Log(DEBUG,"Add to whowas lists");
+
+ if (iter == ServerInstance->whowas.end())
{
+ ServerInstance->Log(DEBUG,"Adding new whowas set for %s",this->nick);
irc::whowas::whowas_set* n = new irc::whowas::whowas_set;
irc::whowas::WhoWasGroup *a = new irc::whowas::WhoWasGroup(this);
n->push_back(a);
- whowas[this->nick] = n;
+ ServerInstance->whowas[this->nick] = n;
}
else
{
irc::whowas::whowas_set* group = (irc::whowas::whowas_set*)iter->second;
+ ServerInstance->Log(DEBUG,"Using existing whowas group for %s",this->nick);
+
if (group->size() > 10)
{
+ ServerInstance->Log(DEBUG,"Trimming existing group to ten entries for %s",this->nick);
irc::whowas::WhoWasGroup *a = (irc::whowas::WhoWasGroup*)*(group->begin());
DELETE(a);
group->pop_front();