1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2008 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 #include "commands/cmd_rehash.h"
20 extern "C" DllExport Command* init_command(InspIRCd* Instance)
22 return new CommandRehash(Instance);
25 CmdResult CommandRehash::Handle (const char* const* parameters, int pcnt, User *user)
27 user->WriteServ("382 %s %s :Rehashing",user->nick,ServerConfig::CleanFilename(ServerInstance->ConfigFileName));
28 std::string parameter;
29 std::string old_disabled = ServerInstance->Config->DisabledCommands;
32 parameter = parameters[0];
36 ServerInstance->SNO->WriteToSnoMask('A', "%s is rehashing config file %s",user->nick,ServerConfig::CleanFilename(ServerInstance->ConfigFileName));
37 ServerInstance->Logs->CloseLogs();
38 if (!ServerInstance->OpenLog(ServerInstance->Config->argv, ServerInstance->Config->argc))
39 user->WriteServ("NOTICE %s :*** ERROR: Could not open logfile %s: %s", user->nick, ServerInstance->Config->logpath.c_str(), strerror(errno));
40 ServerInstance->RehashUsersAndChans();
41 FOREACH_MOD(I_OnGarbageCollect, OnGarbageCollect());
42 if (!ServerInstance->ConfigThread)
44 ServerInstance->ConfigThread = new ConfigReaderThread(ServerInstance, false, user);
45 ServerInstance->Threads->Create(ServerInstance->ConfigThread);
49 /* A rehash is already in progress! ahh shit. */
50 user->WriteServ("*** NOTICE %s :*** Could not rehash: A rehash is already in progress.", user->nick);
54 * ALL THIS STUFF HERE NEEDS TO BE HOOKED TO THE 'DEATH' OF THE REHASH THREAD
55 * VIA SOME NOTIFICATION EVENT. WE CANT JUST CALL IT ALL HERE.
58 // Get XLine to do it's thing.
59 /*ServerInstance->XLines->CheckELines();
60 ServerInstance->XLines->ApplyLines();
61 ServerInstance->Res->Rehash();
62 ServerInstance->ResetMaxBans();*/
65 /* TODO: Same as above for all this stuff, really */
66 if (old_disabled != ServerInstance->Config->DisabledCommands)
67 InitializeDisabledCommands(ServerInstance->Config->DisabledCommands, ServerInstance);
69 FOREACH_MOD(I_OnRehash,OnRehash(user, parameter));
71 ServerInstance->BuildISupport();