Skip to content

Commit

Permalink
Only write pidfile if we have parsed a valid configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel De Graaf committed Jul 17, 2011
1 parent 9fa891e commit 56b0435
Showing 1 changed file with 27 additions and 23 deletions.
50 changes: 27 additions & 23 deletions src/configreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -556,39 +556,43 @@ void ServerConfig::Read()

void ServerConfig::Apply(ServerConfig* old, const std::string& TheUserUID)
{
/* The stuff in here may throw CoreException, be sure we're in a position to catch it. */
try
if (status.errors.str().empty())
{
ConfigTagList binds = GetTags("bind");
if (binds.first == binds.second)
status.errors << "Config error: you must define at least one <bind> block\n";
for (int Index = 0; Index * sizeof(Deprecated) < sizeof(ChangedConfig); Index++)
/* The stuff in here may throw CoreException, be sure we're in a position to catch it. */
try
{
std::string dummy;
if (GetTag(ChangedConfig[Index].tag)->readString(ChangedConfig[Index].value, dummy, true))
status.errors << "Your configuration contains a deprecated value: <"
<< ChangedConfig[Index].tag << ":" << ChangedConfig[Index].value << "> - " << ChangedConfig[Index].reason
<< " (at " << GetTag(ChangedConfig[Index].tag)->getTagLocation() << ")\n";
}
ConfigTagList binds = GetTags("bind");
if (binds.first == binds.second)
status.errors << "Config error: you must define at least one <bind> block\n";
for (int Index = 0; Index * sizeof(Deprecated) < sizeof(ChangedConfig); Index++)
{
std::string dummy;
if (GetTag(ChangedConfig[Index].tag)->readString(ChangedConfig[Index].value, dummy, true))
status.errors << "Your configuration contains a deprecated value: <"
<< ChangedConfig[Index].tag << ":" << ChangedConfig[Index].value << "> - " << ChangedConfig[Index].reason
<< " (at " << GetTag(ChangedConfig[Index].tag)->getTagLocation() << ")\n";
}

Fill();
Fill();

// Handle special items
CrossCheckOperClassType();
CrossCheckConnectBlocks(old);
}
catch (CoreException &ce)
{
status.errors << ce.GetReason() << "\n";
// Handle special items
CrossCheckOperClassType();
CrossCheckConnectBlocks(old);
}
catch (CoreException &ce)
{
status.errors << ce.GetReason() << "\n";
}
}

// write once here, to try it out and make sure its ok
ServerInstance->WritePID(this->PID);

// Check errors before dealing with failed binds, since continuing on failed bind is wanted in some circumstances.
if (!status.errors.str().empty())
status.fatal = true;

// write once here, to try it out and make sure its ok
if (!status.fatal)
ServerInstance->WritePID(this->PID);

/*
* These values can only be set on boot. Keep their old values. Do it before we send messages so we actually have a servername.
*/
Expand Down

0 comments on commit 56b0435

Please sign in to comment.