diff options
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/core/core_oper/cmd_die.cpp | 23 | ||||
| -rw-r--r-- | modules/core/core_oper/cmd_restart.cpp | 31 | ||||
| -rw-r--r-- | modules/core/core_oper/core_oper.h | 8 | ||||
| -rw-r--r-- | modules/spanningtree/main.cpp | 2 | ||||
| -rw-r--r-- | modules/spanningtree/main.h | 2 |
5 files changed, 5 insertions, 61 deletions
diff --git a/modules/core/core_oper/cmd_die.cpp b/modules/core/core_oper/cmd_die.cpp index 61d7658bb..f7aa67613 100644 --- a/modules/core/core_oper/cmd_die.cpp +++ b/modules/core/core_oper/cmd_die.cpp @@ -37,32 +37,11 @@ CommandDie::CommandDie(const WeakModulePtr& parent) syntax = { "<servername>" }; } -void DieRestart::SendError(const std::string& message) -{ - ClientProtocol::Messages::Error errormsg(message); - ClientProtocol::Event errorevent(ServerInstance->GetRFCEvents().error, errormsg); - - for (auto* user : ServerInstance->Users.GetLocalUsers()) - { - if (user->IsFullyConnected()) - { - user->WriteNotice(message); - } - else - { - // Partially connected users receive ERROR, not a NOTICE - user->Send(errorevent); - } - } -} - CmdResult CommandDie::Handle(User* user, const Params& parameters) { if (insp::casemapped_equals(parameters[0], ServerInstance->Config->ServerName)) { - const std::string diebuf = "*** DIE command from " + user->GetMask() + ". Terminating."; - ServerInstance->Logs.Critical(MODNAME, diebuf); - DieRestart::SendError(diebuf); + ServerInstance->SNO.WriteGlobalSno('a', "DIE command from {}, shutting down server.", user->GetRealMask()); ServerInstance->Exit(EXIT_SUCCESS); } return CmdResult::FAILURE; diff --git a/modules/core/core_oper/cmd_restart.cpp b/modules/core/core_oper/cmd_restart.cpp index 0274bfac3..030f98362 100644 --- a/modules/core/core_oper/cmd_restart.cpp +++ b/modules/core/core_oper/cmd_restart.cpp @@ -23,13 +23,6 @@ */ -#ifdef _WIN32 -# include <process.h> -#else -# include <fcntl.h> -# include <unistd.h> -#endif - #include "inspircd.h" #include "core_oper.h" @@ -42,31 +35,11 @@ CommandRestart::CommandRestart(const WeakModulePtr& parent) CmdResult CommandRestart::Handle(User* user, const Params& parameters) { - ServerInstance->Logs.Normal(MODNAME, "Restart: {}", user->nick); if (insp::casemapped_equals(parameters[0], ServerInstance->Config->ServerName)) { ServerInstance->SNO.WriteGlobalSno('a', "RESTART command from {}, restarting server.", user->GetRealMask()); - - DieRestart::SendError("Server restarting."); - -#ifdef FD_CLOEXEC - /* XXX: This hack sets FD_CLOEXEC on all possible file descriptors, so they're closed if the execvp() below succeeds. - * Certainly, this is not a nice way to do things and it's slow when the fd limit is high. - * - * A better solution would be to set the close-on-exec flag for each fd we create (or create them with O_CLOEXEC), - * however there is no guarantee that third party libs will do the same. - */ - for (int i = (int)SocketEngine::GetMaxFds(); --i > 2; ) - { - int flags = fcntl(i, F_GETFD); - if (flags != -1) - fcntl(i, F_SETFD, flags | FD_CLOEXEC); - } -#endif - - execvp(ServerInstance->CommandLine.argv[0], ServerInstance->CommandLine.argv); - ServerInstance->SNO.WriteGlobalSno('a', "Failed RESTART - could not execute '{}' ({})", - ServerInstance->CommandLine.argv[0], strerror(errno)); + const auto error = ServerInstance->Restart(); + ServerInstance->SNO.WriteGlobalSno('a', "Failed RESTART: {}", error); } return CmdResult::FAILURE; } diff --git a/modules/core/core_oper/core_oper.h b/modules/core/core_oper/core_oper.h index 48375946e..d6729ad26 100644 --- a/modules/core/core_oper/core_oper.h +++ b/modules/core/core_oper/core_oper.h @@ -29,14 +29,6 @@ enum ERR_NOOPERHOST = 491, }; -namespace DieRestart -{ - /** Send an ERROR to partially connected users and a NOTICE to fully connected users - * @param message Message to send - */ - void SendError(const std::string& message); -} - class CommandDie final : public Command { diff --git a/modules/spanningtree/main.cpp b/modules/spanningtree/main.cpp index 5cd582fe0..6a3bf5495 100644 --- a/modules/spanningtree/main.cpp +++ b/modules/spanningtree/main.cpp @@ -854,7 +854,7 @@ void ModuleSpanningTree::OnMode(User* source, User* u, Channel* c, const Modes:: } } -void ModuleSpanningTree::OnShutdown(const std::string& reason) +void ModuleSpanningTree::OnShutdown(const std::string& reason, bool restarting) { const TreeServer::ChildServers& children = Utils->TreeRoot->GetChildren(); while (!children.empty()) diff --git a/modules/spanningtree/main.h b/modules/spanningtree/main.h index a1d114991..5b2e2d882 100644 --- a/modules/spanningtree/main.h +++ b/modules/spanningtree/main.h @@ -186,7 +186,7 @@ public: void OnUnloadModule(const ModulePtr& mod) override; ModResult OnAcceptConnection(int newsock, ListenSocket* from, const irc::sockets::sockaddrs& client, const irc::sockets::sockaddrs& server) override; void OnMode(User* source, User* u, Channel* c, const Modes::ChangeList& modes, ModeParser::ModeProcessFlag processflags) override; - void OnShutdown(const std::string& reason) override; + void OnShutdown(const std::string& reason, bool restarting) override; void OnDecodeMetadata(Extensible* target, const std::string& extname, const std::string& extdata) override; Cullable::Result Cull() override; ~ModuleSpanningTree() override; |
