Skip to content

Commit

Permalink
Various rehash fixes that it seems were introduced by untested code.
Browse files Browse the repository at this point in the history
- Remove unused ReportConfigError member
- Don't report successful load (and spam modules that failed to load) if there is a config error
- Restore server name before attempting to send error string to client(s) otherwise most of them won't recieve the notifications.
Fixes bug #891. Still to come: report errors loudly on startup regardless of debug mode.

git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11450 e03df62e-2008-0410-955e-edbf42e46eb7
  • Loading branch information
rburchell committed Aug 1, 2009
1 parent ee465c2 commit c71db5c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 15 deletions.
4 changes: 0 additions & 4 deletions include/configreader.h
Expand Up @@ -800,10 +800,6 @@ class CoreExport ServerConfig : public Extensible
*/
bool StartsWithWindowsDriveLetter(const std::string &path);

/** Report a configuration error given in errormessage.
*/
void ReportConfigError(const std::string &errormessage);

/** Load 'filename' into 'target', with the new config parser everything is parsed into
* tag/key/value at load-time rather than at read-value time.
*/
Expand Down
28 changes: 17 additions & 11 deletions src/configreader.cpp
Expand Up @@ -707,12 +707,6 @@ bool DoneMaxBans(ServerConfig*, const char*)
return true;
}

void ServerConfig::ReportConfigError(const std::string &errormessage)
{
ServerInstance->Logs->Log("CONFIG",DEFAULT, "There were errors in your configuration file: %s", errormessage.c_str());
errstr << errormessage << std::endl;
}

void ServerConfig::Read()
{
static char maxkeep[MAXBUF]; /* Temporary buffer for WhoWasMaxKeep value */
Expand Down Expand Up @@ -1171,12 +1165,22 @@ void ServerConfig::Read()
void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
{
int rem = 0, add = 0;
bool errors = false;
// write once here, to try it out and make sure its ok
ServerInstance->WritePID(this->PID);

FailedPortList pl;
ServerInstance->BindPorts(pl);

/*
* These values can only be set on boot. Keep their old values. Do it before we send messages so we actually have a servername.
*/
if (old)
{
memcpy(this->ServerName, old->ServerName, sizeof(this->ServerName));
memcpy(this->sid, old->sid, sizeof(this->sid));
}

if (pl.size())
{
errstr << "Not all your client ports could be bound.\nThe following port(s) failed to bind:\n";
Expand All @@ -1194,6 +1198,9 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)

while (errstr.good())
{
if (errors == false)
ServerInstance->Logs->Log("CONFIG",DEFAULT, "There were errors in your configuration file:");
errors = true; // XXX: has to be a nicer way to accomplish this.
std::string line;
getline(errstr, line, '\n');
if (!line.empty())
Expand All @@ -1212,11 +1219,10 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
if (!old)
return;

/*
* These values can only be set on boot. Keep their old values.
*/
memcpy(this->ServerName, old->ServerName, sizeof(this->ServerName));
memcpy(this->sid, old->sid, sizeof(this->sid));
// If there were errors processing configuration, don't touch modules.
if (errors)
return;


if (!removed_modules.empty())
{
Expand Down

0 comments on commit c71db5c

Please sign in to comment.