summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-16 13:45:46 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-09-16 13:45:46 +0000
commit3626aeb9ce4798c73cf3a5621388406062c450f7 (patch)
treef0d056cf4cb9ee8143d91d577047463c83bc31d9 /src
parent423d9be3b1d09607ce82d09dbb6414a8b5f006c8 (diff)
Fix iteration of ServerInstance->Users->local_users now that QuitUser can modify the vector
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11732 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r--src/inspircd.cpp10
-rw-r--r--src/modules/m_close.cpp10
-rw-r--r--src/xline.cpp5
3 files changed, 15 insertions, 10 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index ce3bbc06b..1b23bff02 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -105,10 +105,12 @@ void InspIRCd::Cleanup()
}
/* Close all client sockets, or the new process inherits them */
- for (std::vector<User*>::const_iterator i = this->Users->local_users.begin(); i != this->Users->local_users.end(); i++)
+ std::vector<User*>::reverse_iterator i = Users->local_users.rbegin();
+ while (i != this->Users->local_users.rend())
{
- this->Users->QuitUser((*i), "Server shutdown");
- (*i)->CloseSocket();
+ User* u = *i++;
+ Users->QuitUser(u, "Server shutdown");
+ u->CloseSocket();
}
/* We do this more than once, so that any service providers get a
@@ -117,7 +119,7 @@ void InspIRCd::Cleanup()
*
* XXX there may be a better way to do this with 1.2
*/
- for (int tries = 0; tries < 3; tries++)
+ for (int tries = 0; tries < 4; tries++)
{
std::vector<std::string> module_names = Modules->GetAllModuleNames(0);
for (std::vector<std::string>::iterator k = module_names.begin(); k != module_names.end(); ++k)
diff --git a/src/modules/m_close.cpp b/src/modules/m_close.cpp
index e81c29d20..009d50d46 100644
--- a/src/modules/m_close.cpp
+++ b/src/modules/m_close.cpp
@@ -37,12 +37,14 @@ class CommandClose : public Command
{
std::map<std::string,int> closed;
- for (std::vector<User*>::iterator u = ServerInstance->Users->local_users.begin(); u != ServerInstance->Users->local_users.end(); u++)
+ std::vector<User*>::reverse_iterator u = ServerInstance->Users->local_users.rbegin();
+ while (u != ServerInstance->Users->local_users.rend())
{
- if ((*u)->registered != REG_ALL)
+ User* user = *u++;
+ if (user->registered != REG_ALL)
{
- ServerInstance->Users->QuitUser(*u, "Closing all unknown connections per request");
- std::string key = ConvToStr((*u)->GetIPString())+"."+ConvToStr((*u)->GetServerPort());
+ ServerInstance->Users->QuitUser(user, "Closing all unknown connections per request");
+ std::string key = ConvToStr(user->GetIPString())+"."+ConvToStr(user->GetServerPort());
closed[key]++;
}
}
diff --git a/src/xline.cpp b/src/xline.cpp
index 33219b612..b15a7ce2b 100644
--- a/src/xline.cpp
+++ b/src/xline.cpp
@@ -338,9 +338,10 @@ void XLineManager::ExpireLine(ContainerIter container, LookupIter item)
// applies lines, removing clients and changing nicks etc as applicable
void XLineManager::ApplyLines()
{
- for (std::vector<User*>::const_iterator u2 = ServerInstance->Users->local_users.begin(); u2 != ServerInstance->Users->local_users.end(); u2++)
+ std::vector<User*>::reverse_iterator u2 = ServerInstance->Users->local_users.rbegin();
+ while (u2 != ServerInstance->Users->local_users.rend())
{
- User* u = (User*)(*u2);
+ User* u = *u2++;
// Don't ban people who are exempt.
if (u->exempt)