From 684d0250a465ab096a7dec4f67bd2d4620cec54a Mon Sep 17 00:00:00 2001 From: brain Date: Wed, 19 Jul 2006 20:17:14 +0000 Subject: Stability fix git-svn-id: http://svn.inspircd.org/repository/branches/1_0_stable@4452 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/userprocess.cpp | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) (limited to 'src/userprocess.cpp') diff --git a/src/userprocess.cpp b/src/userprocess.cpp index 9ae68cbfd..237cd61bb 100644 --- a/src/userprocess.cpp +++ b/src/userprocess.cpp @@ -341,24 +341,21 @@ void DoBackgroundUserStuff(time_t TIME) { CullList GlobalGoners; - size_t f = local_users.size(); + int cfd = 0; - for (std::vector::iterator count2 = local_users.begin(); count2 != local_users.end(); count2++) + /* 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++) { /* GRONK */ - if (f != local_users.size()) + if (count2 >= local_users.size()) break; - /* Sanity checks for corrupted iterators (yes, really) */ - userrec* curr = NULL; - - 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. @@ -407,20 +404,18 @@ void DoBackgroundUserStuff(time_t TIME) curr->nping = TIME+curr->pingmax; } - /* GANK */ - if (f != local_users.size()) - break; - /* * 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; + } } } } -- cgit v1.3.1-10-gc9f91