X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcommands%2Fcmd_rehash.cpp;h=cab5934572b01433ad778833213508fef700e913;hb=9ebc0997ccd8c6eea8742d0f9c59b9e3f78c85fc;hp=0f60f4a6df8abf5d8e506b713916656060868220;hpb=9954ce7e652fdf1bef963b3a133724e8a8eb4cad;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/commands/cmd_rehash.cpp b/src/commands/cmd_rehash.cpp index 0f60f4a6d..cab593457 100644 --- a/src/commands/cmd_rehash.cpp +++ b/src/commands/cmd_rehash.cpp @@ -22,23 +22,20 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance) return new CommandRehash(Instance); } -CmdResult CommandRehash::Handle (const char* const* parameters, int pcnt, User *user) +CmdResult CommandRehash::Handle (const std::vector& parameters, User *user) { std::string old_disabled = ServerInstance->Config->DisabledCommands; - ServerInstance->Logs->Log("fuckingrehash", DEBUG, "parc %d p0 %s", pcnt, parameters[0]); - if (pcnt && parameters[0][0] != '-') + if (parameters.size() && parameters[0][0] != '-') { if (!ServerInstance->MatchText(ServerInstance->Config->ServerName, parameters[0])) { - ServerInstance->Logs->Log("fuckingrehash", DEBUG, "rehash for a server, and not for us"); FOREACH_MOD(I_OnRehash,OnRehash(user, parameters[0])); return CMD_SUCCESS; // rehash for a server, and not for us } } - else if (pcnt) + else if (parameters.size()) { - ServerInstance->Logs->Log("fuckingrehash", DEBUG, "rehash for a subsystem, ignoring"); FOREACH_MOD(I_OnRehash,OnRehash(user, parameters[0])); return CMD_SUCCESS; } @@ -46,10 +43,13 @@ CmdResult CommandRehash::Handle (const char* const* parameters, int pcnt, User * // Rehash for me. FOREACH_MOD(I_OnRehash,OnRehash(user, "")); - // XXX write this to a remote user correctly - user->WriteNumeric(382, "%s %s :Rehashing",user->nick,ServerConfig::CleanFilename(ServerInstance->ConfigFileName)); + if (IS_LOCAL(user)) + user->WriteNumeric(RPL_REHASHING, "%s %s :Rehashing",user->nick.c_str(),ServerConfig::CleanFilename(ServerInstance->ConfigFileName)); + else + ServerInstance->PI->SendUserNotice(user, std::string("*** Rehashing server ") + ServerInstance->ConfigFileName); + - std::string m = std::string(user->nick) + " is rehashing config file " + ServerConfig::CleanFilename(ServerInstance->ConfigFileName) + " on " + ServerInstance->Config->ServerName; + std::string m = user->nick + " is rehashing config file " + ServerConfig::CleanFilename(ServerInstance->ConfigFileName) + " on " + ServerInstance->Config->ServerName; ServerInstance->SNO->WriteToSnoMask('A', m); ServerInstance->Logs->CloseLogs(); @@ -65,16 +65,19 @@ CmdResult CommandRehash::Handle (const char* const* parameters, int pcnt, User * if (!ServerInstance->ConfigThread) { ServerInstance->Config->RehashUser = user; - ServerInstance->Config->RehashParameter = pcnt ? parameters[0] : ""; + ServerInstance->Config->RehashParameter = parameters.size() ? parameters[0] : ""; ServerInstance->ConfigThread = new ConfigReaderThread(ServerInstance, false, user); ServerInstance->Threads->Create(ServerInstance->ConfigThread); } else { - /* A rehash is already in progress! ahh shit. */ + /* + * A rehash is already in progress! ahh shit. + * 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); + user->WriteServ("NOTICE %s :*** Could not rehash: A rehash is already in progress.", user->nick.c_str()); else ServerInstance->PI->SendUserNotice(user, "*** Could not rehash: A rehash is already in progress.");