}
}
- if (!removed_modules.empty())
+ if (pass == 0)
{
- for (std::vector<std::string>::iterator removing = removed_modules.begin(); removing != removed_modules.end(); removing++)
+ if (!removed_modules.empty())
{
- if (ServerInstance->Modules->Unload(removing->c_str()))
- {
- ServerInstance->SNO->WriteToSnoMask('A', "REHASH UNLOADED MODULE: %s",removing->c_str());
- if (user)
- user->WriteServ("973 %s %s :Module %s successfully unloaded.",user->nick, removing->c_str(), removing->c_str());
- rem++;
- }
- else
+ for (std::vector<std::string>::iterator removing = removed_modules.begin(); removing != removed_modules.end(); removing++)
{
- if (user)
- user->WriteServ("972 %s %s :%s",user->nick, removing->c_str(), ServerInstance->Modules->LastError().c_str());
+ if (ServerInstance->Modules->Unload(removing->c_str()))
+ {
+ ServerInstance->SNO->WriteToSnoMask('A', "REHASH UNLOADED MODULE: %s",removing->c_str());
+ if (user)
+ user->WriteServ("973 %s %s :Module %s successfully unloaded.",user->nick, removing->c_str(), removing->c_str());
+ rem++;
+ }
+ else
+ {
+ if (user)
+ user->WriteServ("972 %s %s :%s",user->nick, removing->c_str(), ServerInstance->Modules->LastError().c_str());
+ }
}
}
- }
- if (!added_modules.empty())
- {
- for (std::vector<std::string>::iterator adding = added_modules.begin(); adding != added_modules.end(); adding++)
+ if (!added_modules.empty())
{
- /* Skip over modules that are aleready loaded for some reason */
- if (ServerInstance->Modules->Find(*adding))
- continue;
-
- if (bail)
- printf_c("[\033[1;32m*\033[0m] Loading module:\t\033[1;32m%s\033[0m\n", adding->c_str());
-
- if (ServerInstance->Modules->Load(adding->c_str()))
- {
- ServerInstance->SNO->WriteToSnoMask('A', "REHASH LOADED MODULE: %s",adding->c_str());
- if (user)
- user->WriteServ("975 %s %s :Module %s successfully loaded.",user->nick, adding->c_str(), adding->c_str());
-
- add++;
- }
- else
+ for (std::vector<std::string>::iterator adding = added_modules.begin(); adding != added_modules.end(); adding++)
{
- if (user)
- user->WriteServ("974 %s %s :%s",user->nick, adding->c_str(), ServerInstance->Modules->LastError().c_str());
-
+ /* Skip over modules that are aleready loaded for some reason */
+ if (ServerInstance->Modules->Find(*adding))
+ continue;
+
if (bail)
+ printf_c("[\033[1;32m*\033[0m] Loading module:\t\033[1;32m%s\033[0m\n", adding->c_str());
+
+ if (ServerInstance->Modules->Load(adding->c_str()))
+ {
+ ServerInstance->SNO->WriteToSnoMask('A', "REHASH LOADED MODULE: %s",adding->c_str());
+ if (user)
+ user->WriteServ("975 %s %s :Module %s successfully loaded.",user->nick, adding->c_str(), adding->c_str());
+
+ add++;
+ }
+ else
{
- printf_c("\n[\033[1;31m*\033[0m] %s\n\n", ServerInstance->Modules->LastError().c_str());
- ServerInstance->Exit(EXIT_STATUS_MODULE);
+ if (user)
+ user->WriteServ("974 %s %s :%s",user->nick, adding->c_str(), ServerInstance->Modules->LastError().c_str());
+
+ if (bail)
+ {
+ printf_c("\n[\033[1;31m*\033[0m] %s\n\n", ServerInstance->Modules->LastError().c_str());
+ ServerInstance->Exit(EXIT_STATUS_MODULE);
+ }
}
}
}
}
/* XXX: This can and will block! */
-void ServerConfig::DoDownloads()
+int ServerConfig::DoDownloads()
{
ServerInstance->Logs->Log("CONFIG",DEBUG,"In DoDownloads()");
+ int new_downloads = 0;
+
/* Reads all local files into the IncludedFiles map, then initiates sockets for the remote ones */
for (std::map<std::string, std::istream*>::iterator x = IncludedFiles.begin(); x != IncludedFiles.end(); ++x)
{
if (CompletedFiles.find(x->first) != CompletedFiles.end())
continue;
+ new_downloads++;
+
ServerInstance->Logs->Log("CONFIG",DEBUG,"StartDownloads File: %s", x->first.c_str());
std::string file = x->first;
else
{
/* Search new file here for more includes to parse */
+ ServerInstance->Logs->Log("CONFIG",DEBUG,"Searching for further includes in %s", x->first.c_str());
}
}
CompletedFiles[x->first] = true;
}
+
+ ServerInstance->Logs->Log("CONFIG",DEBUG,"Returning %d from DoDownloads()", new_downloads);
+
+ return new_downloads;
}
bool ServerConfig::LoadConf(ConfigDataHash &target, const char* filename, std::ostringstream &errorstream, int pass, std::istream *scan_for_includes_only)
{
+ ServerInstance->Logs->Log("CONFIG",DEBUG,"Enter loadconf");
std::string line;
std::istream* conf = NULL;
char ch;
if (std::string(filename) == CONFIG_FILE)
{
+ ServerInstance->Logs->Log("CONFIG",DEBUG,"Main config!");
if (!scan_for_includes_only)
{
conf = new std::ifstream(filename);
errorstream << "File " << filename << " could not be opened." << std::endl;
return false;
}
+ ServerInstance->Logs->Log("CONFIG",DEBUG,"Set main conf");
}
}
else
{
+ ServerInstance->Logs->Log("CONFIG",DEBUG,"Not main config file");
std::map<std::string, std::istream*>::iterator x = IncludedFiles.find(filename);
if (x == IncludedFiles.end())
{
+ ServerInstance->Logs->Log("CONFIG",DEBUG,"File doesnt exist in map");
if (pass == 0)
{
ServerInstance->Logs->Log("CONFIG",DEBUG,"Push include file %s onto map", filename);
}
else
{
+ ServerInstance->Logs->Log("CONFIG",DEBUG,"File exists in map");
if (!scan_for_includes_only)
{
if (x->second)
- conf = IncludedFiles.find(filename)->second;
+ {
+ ServerInstance->Logs->Log("CONFIG",DEBUG,"Retrieve conf");
+ conf = x->second;
+ }
else
{
+ ServerInstance->Logs->Log("CONFIG",DEBUG,"NULL entry, file not found");
errorstream << "File " << filename << " could not be opened." << std::endl;
return false;
}
}
}
+ if (!conf)
+ return false;
+
ServerInstance->Logs->Log("CONFIG",DEBUG,"Start to read conf %s %08lx", filename, conf);
/* Start reading characters... */
is a newline missing from the end of the file: " << filename << ":" << linenumber << std::endl;
}
- if (!scan_for_includes_only)
- delete conf;
+ /*if (!scan_for_includes_only)
+ delete conf;*/
return true;
}
void ConfigReaderThread::Run()
{
- ServerInstance->Config->Read(true, NULL, 0);
+ do
+ {
+ ServerInstance->Config->Read(true, NULL, 0);
+ }
+ while (ServerInstance->Config->DoDownloads() > 0);
+
ServerInstance->Config->Read(true, NULL, 1);
}