summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/modules/reload.h2
-rw-r--r--src/coremods/core_reloadmodule.cpp14
2 files changed, 15 insertions, 1 deletions
diff --git a/include/modules/reload.h b/include/modules/reload.h
index 6ee30c45e..dcdbc95e9 100644
--- a/include/modules/reload.h
+++ b/include/modules/reload.h
@@ -71,7 +71,7 @@ namespace ReloadModule
virtual void OnReloadModuleSave(Module* mod, CustomData& cd) = 0;
/** Restore data after a reload. Only called if data was added in OnReloadModuleSave().
- * @param mod Reloaded module
+ * @param mod Reloaded module, if NULL the reload failed and the module no longer exists
* @param data Pointer that was passed to CustomData::add() in OnReloadModuleSave() at the time when the module's state
* was saved
*/
diff --git a/src/coremods/core_reloadmodule.cpp b/src/coremods/core_reloadmodule.cpp
index 755b49abf..0d01d9e85 100644
--- a/src/coremods/core_reloadmodule.cpp
+++ b/src/coremods/core_reloadmodule.cpp
@@ -236,6 +236,10 @@ class DataKeeper
* @param newmod Newly loaded instance of the module which had its data saved
*/
void Restore(Module* newmod);
+
+ /** Handle reload failure
+ */
+ void Fail();
};
void DataKeeper::DoSaveUsers()
@@ -468,6 +472,14 @@ void DataKeeper::Restore(Module* newmod)
ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Restore finished");
}
+void DataKeeper::Fail()
+{
+ this->mod = NULL;
+
+ ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Restore failed, notifying modules");
+ DoRestoreModules();
+}
+
void DataKeeper::RestoreObj(const OwnedModesExts& data, Extensible* extensible, ModeType modetype, Modes::ChangeList& modechange)
{
RestoreExtensions(data.extlist, extensible);
@@ -583,6 +595,8 @@ class ReloadAction : public HandlerBase0<void>
Module* newmod = ServerInstance->Modules->Find(name);
datakeeper.Restore(newmod);
}
+ else
+ datakeeper.Fail();
ServerInstance->SNO->WriteGlobalSno('a', "RELOAD MODULE: %s %ssuccessfully reloaded", passedname.c_str(), result ? "" : "un");
User* user = ServerInstance->FindUUID(uuid);