summaryrefslogtreecommitdiff
path: root/src/userprocess.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-10-28 17:19:55 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-10-28 17:19:55 +0000
commit35529718181c14610669054fcc0a80b8bf305666 (patch)
tree72162fdda3d58bfb5cdafc93be2545e9073eb61a /src/userprocess.cpp
parentb132870564a6dd2f123f458c53f2cee5d28a9124 (diff)
Needs more testing but seems to work: In DoBackgroundUserStuff(), calculate the time value of when we actually do need enter the function body again, and dont run function body again till that time
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5568 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/userprocess.cpp')
-rw-r--r--src/userprocess.cpp46
1 files changed, 44 insertions, 2 deletions
diff --git a/src/userprocess.cpp b/src/userprocess.cpp
index cb204989d..327cd88f3 100644
--- a/src/userprocess.cpp
+++ b/src/userprocess.cpp
@@ -245,8 +245,16 @@ void InspIRCd::ProcessUser(userrec* cu)
*/
void InspIRCd::DoBackgroundUserStuff(time_t TIME)
{
+ /* Is it time yet? */
+ if (TIME < next_call)
+ return;
+
CullList GlobalGoners(this);
+ /* Time we actually need to call this again */
+ const time_t DUMMY_VALUE = 32768;
+ next_call = TIME + DUMMY_VALUE;
+
/* XXX: IT IS NOT SAFE TO USE AN ITERATOR HERE. DON'T EVEN THINK ABOUT IT. */
for (unsigned long count2 = 0; count2 != this->local_users.size(); count2++)
{
@@ -268,11 +276,18 @@ void InspIRCd::DoBackgroundUserStuff(time_t TIME)
GlobalGoners.AddItem(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.
*/
- if ((TIME > curr->signon) && (curr->registered == REG_NICKUSER) && (AllModulesReportReady(curr)))
+ bool ready = AllModulesReportReady(curr);
+ if ((TIME > curr->signon) && (curr->registered == REG_NICKUSER) && (ready))
{
curr->dns_done = true;
//ZapThisDns(curr->fd);
@@ -280,13 +295,25 @@ void InspIRCd::DoBackgroundUserStuff(time_t TIME)
curr->FullConnect(&GlobalGoners);
continue;
}
- if ((curr->dns_done) && (curr->registered == REG_NICKUSER) && (AllModulesReportReady(curr)))
+ else
+ {
+ if ((curr->registered == REG_NICKUSER) && (ready) && (next_call > curr->signon))
+ next_call = curr->signon;
+ }
+
+ if ((curr->dns_done) && (curr->registered == REG_NICKUSER) && (ready))
{
this->Log(DEBUG,"dns done, registered=3, and modules ready, OK");
curr->FullConnect(&GlobalGoners);
//ZapThisDns(curr->fd);
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))
{
@@ -305,6 +332,11 @@ void InspIRCd::DoBackgroundUserStuff(time_t TIME)
curr->lastping = 0;
curr->nping = TIME+curr->pingmax;
}
+ else
+ {
+ if ((curr->registered == REG_ALL) && (next_call > curr->nping))
+ next_call = curr->nping;
+ }
/*
* We can flush the write buffer as the last thing we do, because if they
@@ -321,6 +353,16 @@ void InspIRCd::DoBackgroundUserStuff(time_t TIME)
}
+ /* 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;
+ }
+
+ this->Log(DEBUG,"Time now is %lu, next time we actually need to call this is %lu (%lu secs from now)", TIME, next_call, delta);
+
/* Remove all the queued users who are due to be quit, free memory used. */
GlobalGoners.Apply();