summaryrefslogtreecommitdiff
path: root/src/commands/cmd_rehash.cpp
diff options
context:
space:
mode:
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2008-04-08 15:00:28 +0000
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>2008-04-08 15:00:28 +0000
commit94ab2b6eb5c8d719da0d9b72bc74ee29017d7995 (patch)
tree887e329ba879c4a674d8570f94c906644aeeef37 /src/commands/cmd_rehash.cpp
parent395a610c2cf3d3712962e2048cde7244ed16e765 (diff)
Remote REHASH stuff, this drove me nuts but should probably work now.. thx brain
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9423 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/commands/cmd_rehash.cpp')
-rw-r--r--src/commands/cmd_rehash.cpp70
1 files changed, 48 insertions, 22 deletions
diff --git a/src/commands/cmd_rehash.cpp b/src/commands/cmd_rehash.cpp
index 32cd43569..41b6936f6 100644
--- a/src/commands/cmd_rehash.cpp
+++ b/src/commands/cmd_rehash.cpp
@@ -25,34 +25,60 @@ extern "C" DllExport Command* init_command(InspIRCd* Instance)
CmdResult CommandRehash::Handle (const char* const* parameters, int pcnt, User *user)
{
user->WriteNumeric(382, "%s %s :Rehashing",user->nick,ServerConfig::CleanFilename(ServerInstance->ConfigFileName));
- std::string parameter;
std::string old_disabled = ServerInstance->Config->DisabledCommands;
- if (pcnt)
+
+ ServerInstance->Logs->Log("fuckingrehash", DEBUG, "parc %d p0 %s", pcnt, parameters[0]);
+ if (pcnt && parameters[0][0] != '-')
{
- parameter = parameters[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
+ else if (pcnt)
{
- ServerInstance->SNO->WriteToSnoMask('A', "%s is rehashing config file %s",user->nick,ServerConfig::CleanFilename(ServerInstance->ConfigFileName));
- ServerInstance->Logs->CloseLogs();
- if (!ServerInstance->OpenLog(ServerInstance->Config->argv, ServerInstance->Config->argc))
- user->WriteServ("NOTICE %s :*** ERROR: Could not open logfile %s: %s", user->nick, ServerInstance->Config->logpath.c_str(), strerror(errno));
- ServerInstance->RehashUsersAndChans();
- FOREACH_MOD(I_OnGarbageCollect, OnGarbageCollect());
- if (!ServerInstance->ConfigThread)
- {
- ServerInstance->Config->RehashUser = user;
- ServerInstance->Config->RehashParameter = parameter;
+ ServerInstance->Logs->Log("fuckingrehash", DEBUG, "rehash for a subsystem, ignoring");
+ FOREACH_MOD(I_OnRehash,OnRehash(user, parameters[0]));
+ return CMD_SUCCESS;
+ }
- ServerInstance->ConfigThread = new ConfigReaderThread(ServerInstance, false, user);
- ServerInstance->Threads->Create(ServerInstance->ConfigThread);
- }
- else
- {
- /* A rehash is already in progress! ahh shit. */
+ // Rehash for me.
+ FOREACH_MOD(I_OnRehash,OnRehash(user, ""));
+
+ std::string m = std::string(user->nick) + " is rehashing config file " + ServerConfig::CleanFilename(ServerInstance->ConfigFileName);
+ ServerInstance->SNO->WriteToSnoMask('A', m);
+ ServerInstance->PI->SendSNONotice("A", m);
+ ServerInstance->Logs->CloseLogs();
+
+ if (!ServerInstance->OpenLog(ServerInstance->Config->argv, ServerInstance->Config->argc))
+ {
+ m = std::string("ERROR: Could not open logfile ") + ServerInstance->Config->logpath + ":" + strerror(errno);
+ ServerInstance->SNO->WriteToSnoMask('A', m);
+ ServerInstance->PI->SendSNONotice("A", m);
+ }
+
+ ServerInstance->RehashUsersAndChans();
+ FOREACH_MOD(I_OnGarbageCollect, OnGarbageCollect());
+
+ if (!ServerInstance->ConfigThread)
+ {
+ ServerInstance->Config->RehashUser = user;
+ ServerInstance->Config->RehashParameter = pcnt ? parameters[0] : "";
+
+ ServerInstance->ConfigThread = new ConfigReaderThread(ServerInstance, false, user);
+ ServerInstance->Threads->Create(ServerInstance->ConfigThread);
+ }
+ else
+ {
+ /* A rehash is already in progress! ahh shit. */
+ if (IS_LOCAL(user))
user->WriteServ("NOTICE %s :*** Could not rehash: A rehash is already in progress.", user->nick);
- return CMD_FAILURE;
- }
+ else
+ ServerInstance->PI->SendUserNotice(user, "*** Could not rehash: A rehash is already in progress.");
+
+ return CMD_FAILURE;
}
return CMD_SUCCESS;