Remove next_call garbage.. It didn't really do much more than obfuscate things. InspIRCd::DoBackgroundUserStuff() is now called once per second, roughly. This will (of course) not be going into 1.1.x

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8241 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
w00t 2007-10-21 12:22:39 +00:00
parent 7c5ab78be2
commit 4487dde76f
6 changed files with 57 additions and 97 deletions

View File

@ -279,9 +279,8 @@ class CoreExport InspIRCd : public classbase
void InitialiseUID();
/** Perform background user events such as PING checks
* @param TIME the current time
*/
void DoBackgroundUserStuff(time_t TIME);
void DoBackgroundUserStuff();
/** Returns true when all modules have done pre-registration checks on a user
* @param user The user to verify
@ -463,10 +462,6 @@ class CoreExport InspIRCd : public classbase
*/
XLineManager* XLines;
/** The time we next call our ping timeout and reg timeout checks
*/
time_t next_call;
/** Set to the current signal recieved
*/
int s_signal;

View File

@ -144,21 +144,10 @@ CmdResult cmd_nick::Handle (const char** parameters, int pcnt, User *user)
if (ServerInstance->Config->NoUserDns)
{
user->dns_done = true;
ServerInstance->next_call = ServerInstance->Time();
}
else
{
user->StartDNSLookup();
if (user->dns_done)
{
/* Cached result or instant failure - fall right through if possible */
ServerInstance->next_call = ServerInstance->Time();
}
else
{
if (ServerInstance->next_call > ServerInstance->Time() + ServerInstance->Config->dns_timeout)
ServerInstance->next_call = ServerInstance->Time() + ServerInstance->Config->dns_timeout;
}
}
}
if (user->registered == REG_NICKUSER)

View File

@ -55,9 +55,8 @@ CmdResult cmd_user::Handle (const char** parameters, int pcnt, User *user)
if (user->registered == REG_NICKUSER)
{
int MOD_RESULT = 0;
/* user is registered now, bit 0 = USER command, bit 1 = sent a NICK command */
if (ServerInstance->next_call > ServerInstance->Time() + ServerInstance->Config->dns_timeout)
ServerInstance->next_call = ServerInstance->Time() + ServerInstance->Config->dns_timeout;
FOREACH_RESULT(I_OnUserRegister,OnUserRegister(user));
if (MOD_RESULT > 0)
return CMD_FAILURE;

View File

@ -338,7 +338,6 @@ InspIRCd::InspIRCd(int argc, char** argv)
this->SNO = new SnomaskManager(this);
this->TIME = this->OLDTIME = this->startup_time = time(NULL);
this->time_delta = 0;
this->next_call = this->TIME + 3;
srand(this->TIME);
*this->LogFileName = 0;
@ -615,14 +614,18 @@ int InspIRCd::Run()
if (TIME != OLDTIME)
{
if (TIME < OLDTIME)
{
WriteOpers("*** \002EH?!\002 -- Time is flowing BACKWARDS in this dimension! Clock drifted backwards %d secs.",abs(OLDTIME-TIME));
}
if ((TIME % 3600) == 0)
{
this->RehashUsersAndChans();
FOREACH_MOD_I(this, I_OnGarbageCollect, OnGarbageCollect());
}
Timers->TickTimers(TIME);
this->DoBackgroundUserStuff(TIME);
this->DoBackgroundUserStuff();
if ((TIME % 5) == 0)
{

View File

@ -320,7 +320,6 @@ class IdentRequestSocket : public EventHandler
if (*ident && ServerInstance->IsIdent(ident))
{
result = ident;
ServerInstance->next_call = ServerInstance->Time();
}
break;

View File

@ -181,102 +181,77 @@ void ProcessUserHandler::Call(User* cu)
* It is intended to do background checking on all the user structs, e.g.
* stuff like ping checks, registration timeouts, etc.
*/
void InspIRCd::DoBackgroundUserStuff(time_t TIME)
void InspIRCd::DoBackgroundUserStuff()
{
/* Is it time yet? */
if (TIME < next_call)
return;
else
/*
* loop over all local users..
*/
for (std::vector<User*>::iterator count2 = local_users.begin(); count2 != local_users.end(); count2++)
{
/* Time we actually need to call this again */
const time_t DUMMY_VALUE = 32768;
next_call = TIME + DUMMY_VALUE;
User *curr = *count2;
for (std::vector<User*>::iterator count2 = local_users.begin(); count2 != local_users.end(); count2++)
if ((curr->registered != REG_ALL) && (TIME > curr->timeout))
{
User* curr = *count2;
/*
* registration timeout -- didnt send USER/NICK/HOST
* in the time specified in their connection class.
*/
if ((TIME > curr->timeout) && (curr->registered != REG_ALL))
curr->muted = true;
User::QuitUser(this, curr, "Registration timeout");
continue;
}
/*
* `ready` means that the user has provided NICK/USER(/PASS), and all modules agree
* that the user is okay to proceed. The one thing we are then waiting for is DNS, which we do here...
*/
bool ready = ((curr->registered == REG_NICKUSER) && AllModulesReportReady(curr));
if (ready)
{
if (!curr->dns_done)
{
curr->muted = true;
User::QuitUser(this, curr, "Registration timeout");
continue;
}
else
{
if ((curr->registered != REG_ALL) && (next_call > (time_t)curr->timeout))
next_call = curr->timeout;
}
/*
* user has signed on with USER/NICK/PASS, and dns has completed, all the modules
* say this user is ok to proceed, fully connect them.
*/
bool ready = ((curr->registered == REG_NICKUSER) && AllModulesReportReady(curr));
if ((TIME > curr->signon) && (ready))
{
if (!curr->dns_done)
/*
* DNS isn't done yet?
* Cool. Check for timeout.
*/
if (TIME > curr->signon)
{
/* FZZZZZZZZT, timeout! */
curr->WriteServ("NOTICE Auth :*** Could not resolve your hostname: Request timed out; using your IP address (%s) instead.", curr->GetIPString());
curr->dns_done = true;
}
this->stats->statsDnsBad++;
curr->FullConnect();
continue;
}
else
{
if ((curr->registered == REG_NICKUSER) && (ready) && (next_call > curr->signon))
next_call = curr->signon;
}
if ((curr->dns_done) && (curr->registered == REG_NICKUSER) && (ready))
{
curr->FullConnect();
continue;
}
else
{
if ((curr->registered == REG_NICKUSER) && (ready) && (next_call > curr->signon + this->Config->dns_timeout))
next_call = curr->signon + this->Config->dns_timeout;
}
// It's time to PING this user. Send them a ping.
if ((TIME > curr->nping) && (curr->registered == REG_ALL))
{
// This user didn't answer the last ping, remove them
if (!curr->lastping)
{
/* Everybody loves boobies. */
time_t time = this->Time(false) - (curr->nping - curr->pingmax);
char message[MAXBUF];
snprintf(message, MAXBUF, "Ping timeout: %ld second%s", (long)time, time > 1 ? "s" : "");
curr->muted = true;
curr->lastping = 1;
curr->nping = TIME+curr->pingmax;
User::QuitUser(this, curr, message);
this->stats->statsDnsBad++;
curr->FullConnect();
continue;
}
curr->Write("PING :%s",this->Config->ServerName);
curr->lastping = 0;
curr->nping = TIME+curr->pingmax;
}
else
{
if ((curr->registered == REG_ALL) && (next_call > curr->nping))
next_call = curr->nping;
/* DNS passed, connect the user */
curr->FullConnect();
continue;
}
}
/* If theres nothing to do, trigger in the next second, something might come up */
time_t delta = next_call - TIME;
if (delta == DUMMY_VALUE)
// It's time to PING this user. Send them a ping.
if ((TIME > curr->nping) && (curr->registered == REG_ALL))
{
next_call = TIME + 1;
delta = 1;
// This user didn't answer the last ping, remove them
if (!curr->lastping)
{
/* Everybody loves boobies. */
time_t time = this->Time(false) - (curr->nping - curr->pingmax);
char message[MAXBUF];
snprintf(message, MAXBUF, "Ping timeout: %ld second%s", (long)time, time > 1 ? "s" : "");
curr->muted = true;
curr->lastping = 1;
curr->nping = TIME+curr->pingmax;
User::QuitUser(this, curr, message);
continue;
}
curr->Write("PING :%s",this->Config->ServerName);
curr->lastping = 0;
curr->nping = TIME+curr->pingmax;
}
}
}