summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPeter Powell <petpow@saberuk.com>2019-10-17 17:17:39 +0100
committerPeter Powell <petpow@saberuk.com>2019-10-17 17:17:39 +0100
commite3deb783406e15cf496afab6971a908215b2ea81 (patch)
tree93a08baff27b27f541bd32dc79a594460100c194 /src
parent08393c002803b93ac53a6a1a0a5272e76b6ae5e4 (diff)
Add an event which is fired when the server shuts down.
Diffstat (limited to 'src')
-rw-r--r--src/inspircd.cpp5
-rw-r--r--src/modules.cpp1
2 files changed, 5 insertions, 1 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 70e5fcf38..f35482f61 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -93,8 +93,11 @@ void InspIRCd::Cleanup()
}
ports.clear();
- // Disconnect all local users
+ // Tell modules that we're shutting down.
const std::string quitmsg = "Server shutting down";
+ FOREACH_MOD(OnShutdown, (quitmsg));
+
+ // Disconnect all local users
const UserManager::LocalList& list = Users.GetLocalUsers();
while (!list.empty())
ServerInstance->Users.QuitUser(list.front(), quitmsg);
diff --git a/src/modules.cpp b/src/modules.cpp
index 4087a1d62..500bb708a 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -141,6 +141,7 @@ void Module::OnServiceAdd(ServiceProvider&) { DetachEvent(I_OnServiceAdd); }
void Module::OnServiceDel(ServiceProvider&) { DetachEvent(I_OnServiceDel); }
ModResult Module::OnUserWrite(LocalUser*, ClientProtocol::Message&) { DetachEvent(I_OnUserWrite); return MOD_RES_PASSTHRU; }
ModResult Module::OnConnectionFail(LocalUser*, BufferedSocketError) { DetachEvent(I_OnConnectionFail); return MOD_RES_PASSTHRU; }
+void Module::OnShutdown(const std::string& reason) { DetachEvent(I_OnShutdown); }
ServiceProvider::ServiceProvider(Module* Creator, const std::string& Name, ServiceType Type)
: creator(Creator), name(Name), service(Type)