-void InspIRCd::Cleanup()
-{
- if (Config)
- {
- for (unsigned int i = 0; i < Config->ports.size(); i++)
- {
- /* This calls the constructor and closes the listening socket */
- delete Config->ports[i];
- }
-
- Config->ports.clear();
- }
-
- /* Close all client sockets, or the new process inherits them */
- for (std::vector<User*>::const_iterator i = this->Users->local_users.begin(); i != this->Users->local_users.end(); i++)
- {
- (*i)->SetWriteError("Server shutdown");
- (*i)->CloseSocket();
- }
-
- /* We do this more than once, so that any service providers get a
- * chance to be unhooked by the modules using them, but then get
- * a chance to be removed themsleves.
- *
- * XXX there may be a better way to do this with 1.2
- */
- for (int tries = 0; tries < 3; tries++)
- {
- std::vector<std::string> module_names = Modules->GetAllModuleNames(0);
- for (std::vector<std::string>::iterator k = module_names.begin(); k != module_names.end(); ++k)
- {
- /* Unload all modules, so they get a chance to clean up their listeners */
- this->Modules->Unload(k->c_str());
- }
- }
- /* Remove core commands */
- Parser->RemoveCommands("<core>");
-
- /* Cleanup Server Names */
- for(servernamelist::iterator itr = servernames.begin(); itr != servernames.end(); ++itr)
- delete (*itr);
-
- /* Delete objects dynamically allocated in constructor
- * (destructor would be more appropriate, but we're likely exiting)
- */
-
- // Must be deleted before modes as it decrements modelines
- if (this->Users)
- {
- delete this->Users;
- this->Users = 0;
- }
-
- if (this->Modes)
- {
- delete this->Modes;
- this->Modes = 0;
- }
-
- if (this->XLines)
- {
- delete this->XLines;
- this->XLines = 0;
- }
-
- if (this->Parser)
- {
- delete this->Parser;
- this->Parser = 0;
-
- if (this->stats)
- {
- delete this->stats;
- this->stats = 0;
- }
-
- if (this->Modules)
- {
- delete this->Modules;
- this->Modules = 0;
- }
-
- if (this->BanCache)
- delete this->BanCache;
- this->BanCache = 0;
- }
-
- if (this->SNO)
- {
- delete this->SNO;
- this->SNO = 0;
- }
-
- if (this->Config)
- {
- delete this->Config;
- this->Config = 0;
- }
-
- if (this->Res)
- {
- delete this->Res;
- this->Res = 0;
- }
-
- if (this->chanlist)
- {
- delete chanlist;
- chanlist = 0;
- }
-
- if (this->PI)
- {
- delete this->PI;
- this->PI = 0;
- }
-
- if (this->Threads)
- {
- delete this->Threads;
- this->Threads = 0;
- }
-
- /* Needs to be deleted after Res, DNS has a timer */
- if (this->Timers)
- {
- delete this->Timers;
- this->Timers = 0;
- }
-
- /* Close logging */
- this->Logs->CloseLogs();
-
- if (this->Logs)
- {
- delete this->Logs;
- this->Logs = 0;
- }
-}
-
-void InspIRCd::Restart(const std::string &reason)
-{
- /* SendError flushes each client's queue,
- * regardless of writeability state
- */
- this->SendError(reason);
-
- /* Figure out our filename (if theyve renamed it, we're boned) */
- std::string me;
-
-#ifdef WINDOWS
- char module[MAX_PATH];
- if (GetModuleFileName(NULL, module, MAX_PATH))
- me = module;
-#else
- me = Config->MyDir + "/inspircd";