]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/commands/cmd_rehash.cpp
Remove out of date doc and fix typo in commands/cmd_*.cpp
[user/henk/code/inspircd.git] / src / commands / cmd_rehash.cpp
index 1fa6e5731b8c730c07c7ac372c6ef83dee3d14c6..f71219f7561729f5cdbead9efed86dcd59798c98 100644 (file)
 
 #include "inspircd.h"
 
-/** Handle /REHASH. These command handlers can be reloaded by the core,
- * and handle basic RFC1459 commands. Commands within modules work
- * the same way, however, they can be fully unloaded, where these
- * may not.
+/** Handle /REHASH.
  */
 class CommandRehash : public Command
 {
@@ -33,8 +30,7 @@ class CommandRehash : public Command
         */
        CommandRehash ( Module* parent) : Command(parent,"REHASH",0) { flags_needed = 'o'; Penalty = 2; syntax = "[<servermask>]"; }
        /** Handle command.
-        * @param parameters The parameters to the comamnd
-        * @param pcnt The number of parameters passed to teh command
+        * @param parameters The parameters to the command
         * @param user The user issuing the command
         * @return A value from CmdResult to indicate command success or failure.
         */
@@ -45,7 +41,7 @@ CmdResult CommandRehash::Handle (const std::vector<std::string>& parameters, Use
 {
        std::string param = parameters.size() ? parameters[0] : "";
 
-       FOREACH_MOD(I_OnPreRehash,OnPreRehash(user, param));
+       FOREACH_MOD(OnPreRehash, (user, param));
 
        if (param.empty())
        {
@@ -68,34 +64,25 @@ CmdResult CommandRehash::Handle (const std::vector<std::string>& parameters, Use
                if (param[0] == '-')
                        param = param.substr(1);
 
-               FOREACH_MOD(I_OnModuleRehash,OnModuleRehash(user, param));
+               FOREACH_MOD(OnModuleRehash, (user, param));
                return CMD_SUCCESS;
        }
 
        // Rehash for me. Try to start the rehash thread
        if (!ServerInstance->ConfigThread)
        {
-               std::string m = user->nick + " is rehashing config file " + ServerConfig::CleanFilename(ServerInstance->ConfigFileName.c_str()) + " on " + ServerInstance->Config->ServerName;
+               std::string m = user->nick + " is rehashing config file " + FileSystem::GetFileName(ServerInstance->ConfigFileName) + " on " + ServerInstance->Config->ServerName;
                ServerInstance->SNO->WriteGlobalSno('a', m);
 
                if (IS_LOCAL(user))
-                       user->WriteNumeric(RPL_REHASHING, "%s %s :Rehashing",
-                               user->nick.c_str(),ServerConfig::CleanFilename(ServerInstance->ConfigFileName.c_str()));
+                       user->WriteNumeric(RPL_REHASHING, "%s :Rehashing", FileSystem::GetFileName(ServerInstance->ConfigFileName).c_str());
                else
-                       ServerInstance->PI->SendUserNotice(user, std::string("*** Rehashing server ") +
-                               ServerConfig::CleanFilename(ServerInstance->ConfigFileName.c_str()));
+                       ServerInstance->PI->SendUserNotice(user, "*** Rehashing server " + FileSystem::GetFileName(ServerInstance->ConfigFileName));
 
                /* Don't do anything with the logs here -- logs are restarted
                 * after the config thread has completed.
                 */
-               ServerInstance->RehashUsersAndChans();
-               FOREACH_MOD(I_OnGarbageCollect, OnGarbageCollect());
-
-
-               ServerInstance->ConfigThread = new ConfigReaderThread(user->uuid);
-               ServerInstance->Threads->Start(ServerInstance->ConfigThread);
-
-               return CMD_SUCCESS;
+               ServerInstance->Rehash(user->uuid);
        }
        else
        {
@@ -104,12 +91,13 @@ CmdResult CommandRehash::Handle (const std::vector<std::string>& parameters, Use
                 * XXX, todo: we should find some way to kill runaway rehashes that are blocking, this is a major problem for unrealircd users
                 */
                if (IS_LOCAL(user))
-                       user->WriteServ("NOTICE %s :*** Could not rehash: A rehash is already in progress.", user->nick.c_str());
+                       user->WriteNotice("*** Could not rehash: A rehash is already in progress.");
                else
                        ServerInstance->PI->SendUserNotice(user, "*** Could not rehash: A rehash is already in progress.");
-
-               return CMD_FAILURE;
        }
+
+       // Always return success so spanningtree forwards an incoming REHASH even if we failed
+       return CMD_SUCCESS;
 }