void InspIRCd::Cleanup()
{
- std::vector<std::string> mymodnames;
- int MyModCount = this->Modules->GetCount();
-
if (Config)
{
for (unsigned int i = 0; i < Config->ports.size(); i++)
*/
for (int tries = 0; tries < 3; tries++)
{
- MyModCount = this->Modules->GetCount();
- mymodnames.clear();
-
- if (MyModCount)
+ 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 */
- for (int j = 0; j <= MyModCount; j++)
- mymodnames.push_back(Config->module_names[j]);
-
- for (int k = 0; k <= MyModCount; k++)
- this->Modules->Unload(mymodnames[k].c_str());
+ this->Modules->Unload(k->c_str());
}
-
}
/* Close logging */
Config->forcedebug = do_debug;
Config->writelog = !do_nolog;
Config->ClearStack();
- Config->Read(true, NULL);
- // Get XLine to do it's thing.
- this->XLines->CheckELines();
- this->XLines->ApplyLines();
-
- this->Modules->modules.resize(255);
- this->Modules->handles.resize(255);
+ this->Modes = new ModeParser(this);
+ this->AddServerName(Config->ServerName);
/*
* Initialise SID/UID.
SE->RecoverFromFork();
- this->Modes = new ModeParser(this);
- this->AddServerName(Config->ServerName);
- CheckDie();
- int bounditems = BindPorts(true, found_ports, pl);
+ this->Res = new DNS(this);
- for(int t = 0; t < 255; t++)
- Config->global_implementation[t] = 0;
+ /* Read config, pass 0. At the end if this pass,
+ * the Config->IncludeFiles is populated, we call
+ * Config->StartDownloads to initialize the downlaods of all
+ * these files.
+ */
+ Config->Read(true, NULL, 0);
+ Config->StartDownloads();
+
+ /* Now the downloads are started, we monitor them for completion.
+ * On completion, we call Read again with pass = 1.
+ * NOTE: We really should add a timeout here
+ */
- memset(&Config->implement_lists,0,sizeof(Config->implement_lists));
+ while (Config->Downloading())
+ {
+ SE->DispatchEvents();
+ this->BufferedSocketCull();
+ }
printf("\n");
- this->Res = new DNS(this);
+ if (Config->FileErrors)
+ {
+ /* One or more file download/access errors, do not
+ * proceed to second pass
+ */
+ Exit(EXIT_STATUS_CONFIG);
+ }
- this->Modules->LoadAll();
+ /* We have all the files we can get, initiate pass 1 */
+ Config->Read(true, NULL, 1);
+
+ // Get XLine to do it's thing.
+ this->XLines->CheckELines();
+ this->XLines->ApplyLines();
+
+
+ CheckDie();
+ int bounditems = BindPorts(true, found_ports, pl);
+
+ printf("\n");
+
+ /*this->Modules->LoadAll();*/
/* Just in case no modules were loaded - fix for bug #101 */
this->BuildISupport();
*/
bool InspIRCd::AllModulesReportReady(User* user)
{
- if (!Config->global_implementation[I_OnCheckReady])
- return true;
-
- for (int i = 0; i <= this->Modules->GetCount(); i++)
+ for (EventHandlerIter i = Modules->EventHandlers[I_OnCheckReady].begin(); i != Modules->EventHandlers[I_OnCheckReady].end(); ++i)
{
- if (Config->implement_lists[i][I_OnCheckReady])
- {
- int res = this->Modules->modules[i]->OnCheckReady(user);
- if (!res)
- return false;
- }
+ int res = (*i)->OnCheckReady(user);
+ if (!res)
+ return false;
}
+
return true;
}