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->WriteNumeric(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->Config->RehashUser = user;
45 ServerInstance->Config->RehashParameter = parameter;
47 ServerInstance->ConfigThread = new ConfigReaderThread(ServerInstance, false, user);
48 ServerInstance->Threads->Create(ServerInstance->ConfigThread);
52 /* A rehash is already in progress! ahh shit. */
53 user->WriteServ("NOTICE %s :*** Could not rehash: A rehash is already in progress.", user->nick);