summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/modules.h8
-rw-r--r--src/inspircd.cpp5
-rw-r--r--src/modules.cpp1
3 files changed, 12 insertions, 2 deletions
diff --git a/include/modules.h b/include/modules.h
index bf8b65343..d739f0cf1 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -217,7 +217,7 @@ enum Implementation
I_OnUserConnect, I_OnUserPreQuit, I_OnUserQuit, I_OnUserDisconnect, I_OnUserJoin, I_OnUserPart,
I_OnSendSnotice, I_OnUserPreJoin, I_OnUserPreKick, I_OnUserKick, I_OnOper,
I_OnUserPreInvite, I_OnUserInvite, I_OnUserPreMessage, I_OnUserPreNick,
- I_OnUserPostMessage, I_OnUserMessageBlocked, I_OnMode,
+ I_OnUserPostMessage, I_OnUserMessageBlocked, I_OnMode, I_OnShutdown,
I_OnDecodeMetaData, I_OnAcceptConnection, I_OnUserInit, I_OnUserPostInit,
I_OnChangeHost, I_OnChangeRealName, I_OnAddLine, I_OnDelLine, I_OnExpireLine,
I_OnUserPostNick, I_OnPreMode, I_On005Numeric, I_OnKill, I_OnLoadModule,
@@ -950,6 +950,12 @@ class CoreExport Module : public classbase, public usecountbase
* disconnect the user, or MOD_RES_PASSTHRU to let another module handle the event.
*/
virtual ModResult OnConnectionFail(LocalUser* user, BufferedSocketError error);
+
+ /** Called before a server shuts down.
+ * @param reason The reason the server is shutting down.
+ * @param restart Whether the server is restarting.
+ */
+ virtual void OnShutdown(const std::string& reason);
};
/** ModuleManager takes care of all things module-related
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)