diff options
-rw-r--r-- | include/inspircd.h | 7 | ||||
-rw-r--r-- | src/cmd_nick.cpp | 11 | ||||
-rw-r--r-- | src/cmd_user.cpp | 3 | ||||
-rw-r--r-- | src/inspircd.cpp | 7 | ||||
-rw-r--r-- | src/modules/m_ident.cpp | 1 | ||||
-rw-r--r-- | src/userprocess.cpp | 121 |
6 files changed, 55 insertions, 95 deletions
diff --git a/include/inspircd.h b/include/inspircd.h index 9e3fd16de..28d2d534c 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -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; diff --git a/src/cmd_nick.cpp b/src/cmd_nick.cpp index d350b26b6..f23ad93fa 100644 --- a/src/cmd_nick.cpp +++ b/src/cmd_nick.cpp @@ -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) diff --git a/src/cmd_user.cpp b/src/cmd_user.cpp index a3d10a723..740674833 100644 --- a/src/cmd_user.cpp +++ b/src/cmd_user.cpp @@ -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; diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 54243e807..d0b5bbbe0 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -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) { diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index 9926e5350..9a3c595a6 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -320,7 +320,6 @@ class IdentRequestSocket : public EventHandler if (*ident && ServerInstance->IsIdent(ident)) { result = ident; - ServerInstance->next_call = ServerInstance->Time(); } break; diff --git a/src/userprocess.cpp b/src/userprocess.cpp index 02ceaa9e5..33057c52d 100644 --- a/src/userprocess.cpp +++ b/src/userprocess.cpp @@ -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; - } - 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)) + 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) { - 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; } - 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)) - { + /* DNS passed, connect the user */ 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)) + // 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) { - // 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; + /* 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; } - else - { - if ((curr->registered == REG_ALL) && (next_call > curr->nping)) - next_call = curr->nping; - } - } - - /* If theres nothing to do, trigger in the next second, something might come up */ - time_t delta = next_call - TIME; - if (delta == DUMMY_VALUE) - { - next_call = TIME + 1; - delta = 1; + curr->Write("PING :%s",this->Config->ServerName); + curr->lastping = 0; + curr->nping = TIME+curr->pingmax; } } } |