- for (std::vector<User*>::const_iterator i = this->Users->local_users.begin(); i != this->Users->local_users.end(); i++)
- {
- this->Users->QuitUser((*i), "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;
- }
-
+ LocalUserList::reverse_iterator i = Users->local_users.rbegin();
+ while (i != this->Users->local_users.rend())
+ {
+ User* u = *i++;
+ Users->QuitUser(u, "Server shutdown");
+ }
+
+ GlobalCulls.Apply();
+ Modules->UnloadAll();
+
+ /* 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 (FakeClient)
+ FakeClient->cull();
+ if (Res)
+ Res->cull();
+ DeleteZero(this->FakeClient);
+ DeleteZero(this->Users);
+ DeleteZero(this->Modes);
+ DeleteZero(this->XLines);
+ DeleteZero(this->Parser);
+ DeleteZero(this->stats);
+ DeleteZero(this->Modules);
+ DeleteZero(this->BanCache);
+ DeleteZero(this->SNO);
+ DeleteZero(this->Config);
+ DeleteZero(this->Res);
+ DeleteZero(this->chanlist);
+ DeleteZero(this->PI);
+ DeleteZero(this->Threads);
+ DeleteZero(this->Timers);
+ DeleteZero(this->SE);