From c35089b8cfd108ccfb85077f74236e704ba7cf55 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Fri, 13 Jun 2014 15:59:37 +0200 Subject: Make the default ProtocolInterface instance part of class InspIRCd The protocol module no longer has to delete it on load and construct it on unload, only assign a new value to ServerInstance->PI --- include/inspircd.h | 4 ++++ src/inspircd.cpp | 6 +----- src/modules/m_spanningtree/main.cpp | 3 +-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/include/inspircd.h b/include/inspircd.h index 17dca94d5..42454f354 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -408,6 +408,10 @@ class CoreExport InspIRCd */ ProtocolInterface* PI; + /** Default implementation of the ProtocolInterface, does nothing + */ + ProtocolInterface DefaultProtocolInterface; + /** Holds extensible for user operquit */ StringExtItem OperQuit; diff --git a/src/inspircd.cpp b/src/inspircd.cpp index cb428c32a..50c79fb7b 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -134,7 +134,6 @@ void InspIRCd::Cleanup() DeleteZero(this->Modules); DeleteZero(this->SNO); DeleteZero(this->Config); - DeleteZero(this->PI); SocketEngine::Deinit(); Logs->CloseLogs(); DeleteZero(this->Logs); @@ -232,6 +231,7 @@ void InspIRCd::WritePID(const std::string &filename) InspIRCd::InspIRCd(int argc, char** argv) : ConfigFileName(INSPIRCD_CONFIG_PATH "/inspircd.conf"), + PI(&DefaultProtocolInterface), /* Functor pointer initialisation. * @@ -256,7 +256,6 @@ InspIRCd::InspIRCd(int argc, char** argv) : // Initialize so that if we exit before proper initialization they're not deleted this->Logs = 0; - this->PI = 0; this->Users = 0; this->Config = 0; this->SNO = 0; @@ -274,9 +273,6 @@ InspIRCd::InspIRCd(int argc, char** argv) : SocketEngine::Init(); - /* Default implementation does nothing */ - this->PI = new ProtocolInterface; - // Create base manager classes early, so nothing breaks this->Users = new UserManager; diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 8f0586923..2ab05e014 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -86,7 +86,6 @@ void ModuleSpanningTree::init() Utils->TreeRoot = new TreeServer; commands = new SpanningTreeCommands(this); - delete ServerInstance->PI; ServerInstance->PI = &protocolinterface; delete ServerInstance->FakeClient->server; @@ -758,7 +757,7 @@ CullResult ModuleSpanningTree::cull() ModuleSpanningTree::~ModuleSpanningTree() { - ServerInstance->PI = new ProtocolInterface; + ServerInstance->PI = &ServerInstance->DefaultProtocolInterface; Server* newsrv = new Server(ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc); SetLocalUsersServer(newsrv); -- cgit v1.2.3