mirror of
https://github.com/inspircd/inspircd.git
synced 2025-03-10 11:09:04 -04:00
Report failure to load configs
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@8571 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
parent
1a0357cc2c
commit
a004ad524f
@ -242,10 +242,10 @@ class CoreExport ServerConfig : public Extensible
|
|||||||
*/
|
*/
|
||||||
bool CheckOnce(char* tag);
|
bool CheckOnce(char* tag);
|
||||||
|
|
||||||
std::map<std::string, std::istream*> IncludedFiles;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
std::map<std::string, std::istream*> IncludedFiles;
|
||||||
|
|
||||||
size_t TotalDownloaded;
|
size_t TotalDownloaded;
|
||||||
size_t FileErrors;
|
size_t FileErrors;
|
||||||
|
|
||||||
|
@ -1268,7 +1268,7 @@ void ServerConfig::StartDownloads()
|
|||||||
ServerInstance->Log(DEBUG,"Begin download for %s", file.c_str());
|
ServerInstance->Log(DEBUG,"Begin download for %s", file.c_str());
|
||||||
if ((file[0] == '/') || (file.substr(0, 7) == "file://"))
|
if ((file[0] == '/') || (file.substr(0, 7) == "file://"))
|
||||||
{
|
{
|
||||||
ServerInstance->Log(DEBUG,"Core-handled schema for %s %s", file.c_str(), file.substr(0,7).c_str());
|
ServerInstance->Log(DEBUG,"Core-handled schema for %s", file.c_str());
|
||||||
/* For file:// schema files, we use std::ifstream which is a derivative of std::istream.
|
/* For file:// schema files, we use std::ifstream which is a derivative of std::istream.
|
||||||
* For all other file schemas, we use a std::stringstream.
|
* For all other file schemas, we use a std::stringstream.
|
||||||
*/
|
*/
|
||||||
@ -1282,7 +1282,11 @@ void ServerConfig::StartDownloads()
|
|||||||
x->second = conf;
|
x->second = conf;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
delete x->second;
|
||||||
|
x->second = NULL;
|
||||||
FileErrors++;
|
FileErrors++;
|
||||||
|
}
|
||||||
|
|
||||||
TotalDownloaded++;
|
TotalDownloaded++;
|
||||||
}
|
}
|
||||||
@ -1290,6 +1294,12 @@ void ServerConfig::StartDownloads()
|
|||||||
{
|
{
|
||||||
/* Modules handle these */
|
/* Modules handle these */
|
||||||
ServerInstance->Log(DEBUG,"Module-handled schema for %s", x->first.c_str());
|
ServerInstance->Log(DEBUG,"Module-handled schema for %s", x->first.c_str());
|
||||||
|
|
||||||
|
/* For now, error it */
|
||||||
|
FileErrors++;
|
||||||
|
TotalDownloaded++;
|
||||||
|
delete x->second;
|
||||||
|
x->second = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1321,8 +1331,8 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const char* filename, std::o
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Check if the file open failed first */
|
std::map<std::string, std::istream*>::iterator x = IncludedFiles.find(filename);
|
||||||
if (IncludedFiles.find(filename) == IncludedFiles.end())
|
if (x == IncludedFiles.end())
|
||||||
{
|
{
|
||||||
if (pass == 0)
|
if (pass == 0)
|
||||||
{
|
{
|
||||||
@ -1340,7 +1350,15 @@ bool ServerConfig::LoadConf(ConfigDataHash &target, const char* filename, std::o
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (x->second)
|
||||||
conf = IncludedFiles.find(filename)->second;
|
conf = IncludedFiles.find(filename)->second;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
errorstream << "File " << filename << " could not be opened." << std::endl;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Start reading characters... */
|
/* Start reading characters... */
|
||||||
|
@ -515,6 +515,12 @@ InspIRCd::InspIRCd(int argc, char** argv)
|
|||||||
/* One or more file download/access errors, do not
|
/* One or more file download/access errors, do not
|
||||||
* proceed to second pass
|
* proceed to second pass
|
||||||
*/
|
*/
|
||||||
|
for (std::map<std::string, std::istream*>::iterator x = Config->IncludedFiles.begin(); x != Config->IncludedFiles.end(); ++x)
|
||||||
|
{
|
||||||
|
if (!x->second)
|
||||||
|
printf("ERROR: Failed to access the file: %s.\n", x->first.c_str());
|
||||||
|
}
|
||||||
|
printf("Initialisation of configuration failed.\n");
|
||||||
Exit(EXIT_STATUS_CONFIG);
|
Exit(EXIT_STATUS_CONFIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user