summaryrefslogtreecommitdiff
path: root/modules/core/os_reload.cpp
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2010-08-17 19:27:37 -0400
committerAdam <Adam@anope.org>2010-08-17 19:27:37 -0400
commite65d8b2f3dfdb40858259b3bb48ef6998c31e62f (patch)
treefd845bdef5664d025ab19c262ae2c5e9d23d7bb2 /modules/core/os_reload.cpp
parent2575008baa5c9d0ca789680da1a3b81dc74786f7 (diff)
Rewrote the config reader to better handle invalid configs.
This prevents Anope from exploding when /os reload has errors.
Diffstat (limited to 'modules/core/os_reload.cpp')
-rw-r--r--modules/core/os_reload.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/modules/core/os_reload.cpp b/modules/core/os_reload.cpp
index a01625026..4344efcff 100644
--- a/modules/core/os_reload.cpp
+++ b/modules/core/os_reload.cpp
@@ -22,26 +22,31 @@ class CommandOSReload : public Command
CommandReturn Execute(User *u, const std::vector<Anope::string> &params)
{
- if (!read_config(1))
+ try
{
- quitmsg = "Error during the reload of the configuration file!";
- quitting = true;
+ ServerConfig *newconfig = new ServerConfig();
+ delete Config;
+ Config = newconfig;
+ FOREACH_MOD(I_OnReload, OnReload(false));
+ }
+ catch (const ConfigException &ex)
+ {
+ Alog() << "Error reloading configuration file: " << ex.GetReason();
}
- FOREACH_MOD(I_OnReload, OnReload(false));
- notice_lang(Config.s_OperServ, u, OPER_RELOAD);
+ notice_lang(Config->s_OperServ, u, OPER_RELOAD);
return MOD_CONT;
}
bool OnHelp(User *u, const Anope::string &subcommand)
{
- notice_help(Config.s_OperServ, u, OPER_HELP_RELOAD);
+ notice_help(Config->s_OperServ, u, OPER_HELP_RELOAD);
return true;
}
void OnServHelp(User *u)
{
- notice_lang(Config.s_OperServ, u, OPER_HELP_CMD_RELOAD);
+ notice_lang(Config->s_OperServ, u, OPER_HELP_CMD_RELOAD);
}
};