diff options
author | Peter Powell <petpow@saberuk.com> | 2019-09-23 11:51:09 +0100 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2019-09-23 13:18:19 +0100 |
commit | cf5d382b822cecd54fdbc77e4c1c4de8a8aa3c35 (patch) | |
tree | f05c9f3c3acfc863dd053abacde791f32fa216f1 | |
parent | a4305d8f3c3e613be839bdcd61a1d14c87fed5aa (diff) |
Add whether the server split with an error to OnServerSplit.
-rw-r--r-- | include/modules/server.h | 24 | ||||
-rw-r--r-- | src/modules/m_sasl.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treeserver.cpp | 10 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treeserver.h | 10 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treesocket2.cpp | 2 |
6 files changed, 34 insertions, 16 deletions
diff --git a/include/modules/server.h b/include/modules/server.h index 259da868f..c758df364 100644 --- a/include/modules/server.h +++ b/include/modules/server.h @@ -19,6 +19,11 @@ #pragma once +#ifdef __GNUC__ +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif + #include "event.h" namespace ServerProtocol @@ -61,10 +66,16 @@ class ServerProtocol::LinkEventListener */ virtual void OnServerLink(const Server* server) { } - /** Fired when a server splits - * @param server Server that split - */ - virtual void OnServerSplit(const Server* server) { } + /** Fired when a server splits + * @param server Server that split + * @param error Whether the server split because of an error. + */ + virtual void OnServerSplit(const Server* server, bool error) { OnServerSplit(server); } + + /** Fired when a server splits + * @param server Server that split + */ + DEPRECATED_METHOD(virtual void OnServerSplit(const Server* server)) { } }; class ServerProtocol::MessageEventListener @@ -134,3 +145,8 @@ class ServerEventListener { } }; + +#ifdef __GNUC__ +# pragma GCC diagnostic pop +#endif + diff --git a/src/modules/m_sasl.cpp b/src/modules/m_sasl.cpp index 28bce2bf3..9813ba6b5 100644 --- a/src/modules/m_sasl.cpp +++ b/src/modules/m_sasl.cpp @@ -59,7 +59,7 @@ class ServerTracker Update(server, true); } - void OnServerSplit(const Server* server) CXX11_OVERRIDE + void OnServerSplit(const Server* server, bool error) CXX11_OVERRIDE { Update(server, false); } diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 2848ce940..3e992f39f 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -689,7 +689,7 @@ void ModuleSpanningTree::OnUnloadModule(Module* mod) { TreeServer* server = i->second; if (!server->IsRoot()) - FOREACH_MOD_CUSTOM(GetLinkEventProvider(), ServerProtocol::LinkEventListener, OnServerSplit, (server)); + FOREACH_MOD_CUSTOM(GetLinkEventProvider(), ServerProtocol::LinkEventListener, OnServerSplit, (server, false)); } return; } diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp index 2b143269c..c463ef1c8 100644 --- a/src/modules/m_spanningtree/treeserver.cpp +++ b/src/modules/m_spanningtree/treeserver.cpp @@ -172,7 +172,7 @@ void TreeServer::FinishBurst() FinishBurstInternal(); } -void TreeServer::SQuitChild(TreeServer* server, const std::string& reason) +void TreeServer::SQuitChild(TreeServer* server, const std::string& reason, bool error) { stdalgo::erase(Children, server); @@ -188,7 +188,7 @@ void TreeServer::SQuitChild(TreeServer* server, const std::string& reason) } unsigned int num_lost_servers = 0; - server->SQuitInternal(num_lost_servers); + server->SQuitInternal(num_lost_servers, error); const std::string quitreason = GetName() + " " + server->GetName(); unsigned int num_lost_users = QuitUsers(quitreason); @@ -204,14 +204,14 @@ void TreeServer::SQuitChild(TreeServer* server, const std::string& reason) ServerInstance->GlobalCulls.AddItem(server); } -void TreeServer::SQuitInternal(unsigned int& num_lost_servers) +void TreeServer::SQuitInternal(unsigned int& num_lost_servers, bool error) { 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(num_lost_servers); + server->SQuitInternal(num_lost_servers, error); } // Mark server as dead @@ -220,7 +220,7 @@ void TreeServer::SQuitInternal(unsigned int& num_lost_servers) RemoveHash(); if (!Utils->Creator->dying) - FOREACH_MOD_CUSTOM(Utils->Creator->GetLinkEventProvider(), ServerProtocol::LinkEventListener, OnServerSplit, (this)); + FOREACH_MOD_CUSTOM(Utils->Creator->GetLinkEventProvider(), ServerProtocol::LinkEventListener, OnServerSplit, (this, error)); } unsigned int TreeServer::QuitUsers(const std::string& reason) diff --git a/src/modules/m_spanningtree/treeserver.h b/src/modules/m_spanningtree/treeserver.h index 90841d0b4..14413cd92 100644 --- a/src/modules/m_spanningtree/treeserver.h +++ b/src/modules/m_spanningtree/treeserver.h @@ -74,7 +74,7 @@ class TreeServer : public Server /** Used by SQuit logic to recursively remove servers */ - void SQuitInternal(unsigned int& num_lost_servers); + void SQuitInternal(unsigned int& num_lost_servers, bool error); /** Remove the reference to this server from the hash maps */ @@ -103,15 +103,17 @@ class TreeServer : public Server /** SQuit a server connected to this server, removing the given server and all servers behind it * @param server Server to squit, must be directly below this server * @param reason Reason for quitting the server, sent to opers and other servers + * @param error Whether the server is being squit because of an error. */ - void SQuitChild(TreeServer* server, const std::string& reason); + void SQuitChild(TreeServer* server, const std::string& reason, bool error = false); /** SQuit this server, removing this server and all servers behind it * @param reason Reason for quitting the server, sent to opers and other servers + * @param error Whether the server is being squit because of an error. */ - void SQuit(const std::string& reason) + void SQuit(const std::string& reason, bool error = false) { - GetParent()->SQuitChild(this, reason); + GetParent()->SQuitChild(this, reason, error); } static unsigned int QuitUsers(const std::string& reason); diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp index 966d624bb..13ede628a 100644 --- a/src/modules/m_spanningtree/treesocket2.cpp +++ b/src/modules/m_spanningtree/treesocket2.cpp @@ -415,7 +415,7 @@ void TreeSocket::Close() // If the connection is fully up (state CONNECTED) // then propogate a netsplit to all peers. if (MyRoot) - MyRoot->SQuit(getError()); + MyRoot->SQuit(getError(), true); ServerInstance->SNO->WriteGlobalSno('l', "Connection to '\002%s\002' failed.", linkID.c_str()); |