summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2014-07-28 14:42:01 +0200
committerAttila Molnar <attilamolnar@hush.com>2014-07-28 14:42:01 +0200
commit2a18ae111e7c1e0d0d26c54e8bd00a1a0affcf75 (patch)
treeaae3c41ce9e94be281a6b31b1f3d5735cfae065a
parentd618b3c186e58a55ab5103da2790459daed6c45e (diff)
m_spanningtree Quit all split users in one go
-rw-r--r--src/modules/m_spanningtree/treeserver.cpp13
-rw-r--r--src/modules/m_spanningtree/treeserver.h4
2 files changed, 9 insertions, 8 deletions
diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp
index a47522203..99c9ed751 100644
--- a/src/modules/m_spanningtree/treeserver.cpp
+++ b/src/modules/m_spanningtree/treeserver.cpp
@@ -182,12 +182,13 @@ void TreeServer::SQuitChild(TreeServer* server, const std::string& reason)
}
int num_lost_servers = 0;
- int num_lost_users = 0;
+ server->SQuitInternal(num_lost_servers);
+
const std::string quitreason = GetName() + " " + server->GetName();
ModuleSpanningTree* st = Utils->Creator;
st->SplitInProgress = true;
- server->SQuitInternal(quitreason, num_lost_servers, num_lost_users);
+ int num_lost_users = QuitUsers(quitreason);
st->SplitInProgress = false;
ServerInstance->SNO->WriteToSnoMask(IsRoot() ? 'l' : 'L', "Netsplit complete, lost \002%d\002 user%s on \002%d\002 server%s.",
@@ -201,20 +202,19 @@ void TreeServer::SQuitChild(TreeServer* server, const std::string& reason)
ServerInstance->GlobalCulls.AddItem(server);
}
-void TreeServer::SQuitInternal(const std::string& reason, int& num_lost_servers, int& num_lost_users)
+void TreeServer::SQuitInternal(int& num_lost_servers)
{
ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Server %s lost in split", GetName().c_str());
for (ChildServers::const_iterator i = Children.begin(); i != Children.end(); ++i)
{
TreeServer* server = *i;
- server->SQuitInternal(reason, num_lost_servers, num_lost_users);
+ server->SQuitInternal(num_lost_servers);
}
// Mark server as dead
isdead = true;
num_lost_servers++;
- num_lost_users += QuitUsers(reason);
RemoveHash();
}
@@ -229,7 +229,8 @@ int TreeServer::QuitUsers(const std::string &reason)
User* user = i->second;
// Increment the iterator now because QuitUser() removes the user from the container
++i;
- if (user->server == this)
+ TreeServer* server = TreeServer::Get(user);
+ if (server->IsDead())
ServerInstance->Users->QuitUser(user, publicreason, &reason);
}
return original_size - users.size();
diff --git a/src/modules/m_spanningtree/treeserver.h b/src/modules/m_spanningtree/treeserver.h
index 86666211f..35af65107 100644
--- a/src/modules/m_spanningtree/treeserver.h
+++ b/src/modules/m_spanningtree/treeserver.h
@@ -71,7 +71,7 @@ class TreeServer : public Server
/** Used by SQuit logic to recursively remove servers
*/
- void SQuitInternal(const std::string& reason, int& num_lost_servers, int& num_lost_users);
+ void SQuitInternal(int& num_lost_servers);
/** Remove the reference to this server from the hash maps
*/
@@ -113,7 +113,7 @@ class TreeServer : public Server
GetParent()->SQuitChild(this, reason);
}
- int QuitUsers(const std::string &reason);
+ static int QuitUsers(const std::string& reason);
/** Get route.
* The 'route' is defined as the locally-