summaryrefslogtreecommitdiff
path: root/src/userprocess.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-19 20:17:26 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-07-19 20:17:26 +0000
commit9221bcb5a9b029927a48a32376decc9928f32f70 (patch)
treefc76a1ec49d68e254b41906adb5f21202aece715 /src/userprocess.cpp
parent69ae63ecd25c63b4f6d446fae28af9c8d1caac4d (diff)
Stability fix
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4453 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/userprocess.cpp')
-rw-r--r--src/userprocess.cpp28
1 files changed, 16 insertions, 12 deletions
diff --git a/src/userprocess.cpp b/src/userprocess.cpp
index a401efeb1..7ea5167a5 100644
--- a/src/userprocess.cpp
+++ b/src/userprocess.cpp
@@ -320,18 +320,20 @@ void DoBackgroundUserStuff(time_t TIME)
{
CullList GlobalGoners;
- for (std::vector<userrec*>::iterator count2 = local_users.begin(); count2 != local_users.end(); count2++)
+ int cfd = 0;
+
+ /* XXX: IT IS NOT SAFE TO USE AN ITERATOR HERE. DON'T EVEN THINK ABOUT IT. */
+ for (unsigned long count2 = 0; count2 != local_users.size(); count2++)
{
- /* Sanity checks for corrupted iterators (yes, really) */
- userrec* curr = NULL;
+ if (count2 >= local_users.size())
+ break;
- if (*count2)
- curr = (userrec*)(*count2);
- if ((long)curr == -1)
- return;
+ userrec* curr = local_users[count2];
if (curr)
{
+ cfd = curr->fd;
+
/*
* registration timeout -- didnt send USER/NICK/HOST
* in the time specified in their connection class.
@@ -384,12 +386,14 @@ void DoBackgroundUserStuff(time_t TIME)
* We can flush the write buffer as the last thing we do, because if they
* match any of the above conditions its no use flushing their buffer anyway.
*/
- curr->FlushWriteBuf();
-
- if (*curr->GetWriteError())
+ if ((cfd > 0) && (cfd < MAX_DESCRIPTORS) && (fd_ref_table[cfd] == curr) && (curr))
{
- GlobalGoners.AddItem(curr,curr->GetWriteError());
- continue;
+ curr->FlushWriteBuf();
+ if (*curr->GetWriteError())
+ {
+ GlobalGoners.AddItem(curr,curr->GetWriteError());
+ continue;
+ }
}
}
}