summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-07-01 22:55:54 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2009-07-01 22:55:54 +0000
commitb9e42dee051a50f448b87d4d670d897c915fd55b (patch)
treeb5eb94105a436ab8dd9a71bef685f9adbc0e0c8a
parentc384697c88aa54b5a532cd2edce3c063c70d7868 (diff)
Fix error reporting on rehash
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11425 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r--include/configreader.h2
-rw-r--r--src/configreader.cpp67
2 files changed, 27 insertions, 42 deletions
diff --git a/include/configreader.h b/include/configreader.h
index 36e5badfd..cc0c06d38 100644
--- a/include/configreader.h
+++ b/include/configreader.h
@@ -339,7 +339,7 @@ class CoreExport ServerConfig : public Extensible
/** Error stream, contains error output from any failed configuration parsing.
*/
- std::ostringstream errstr;
+ std::stringstream errstr;
/** True if this configuration is valid enough to run with */
bool valid;
diff --git a/src/configreader.cpp b/src/configreader.cpp
index 4c7b96900..eb1418590 100644
--- a/src/configreader.cpp
+++ b/src/configreader.cpp
@@ -721,8 +721,9 @@ void ServerConfig::Read()
static char announceinvites[MAXBUF]; /* options:announceinvites setting */
static char disabledumodes[MAXBUF]; /* Disabled usermodes */
static char disabledcmodes[MAXBUF]; /* Disabled chanmodes */
- /* std::ostringstream::clear() does not clear the string itself, only the error flags. */
valid = true;
+ /* std::ostringstream::clear() does not clear the string itself, only the error flags. */
+ errstr.clear();
errstr.str().clear();
include_stack.clear();
@@ -952,7 +953,6 @@ void ServerConfig::Read()
if (!Values[Index].validation_function(this, Values[Index].tag, Values[Index].value, vi))
throw CoreException("One or more values in your configuration file failed to validate. Please see your ircd.log for more information.");
- // XXX: ServerInstance->Threads->Lock();
switch (dt)
{
case DT_NOSPACES:
@@ -981,7 +981,6 @@ void ServerConfig::Read()
ValueContainerChar* vcc = (ValueContainerChar*)Values[Index].val;
if (*(vi.GetString()) && !ServerInstance->IsChannel(vi.GetString(), MAXBUF))
{
- // XXX: ServerInstance->Threads->Unlock();
throw CoreException("The value of <"+std::string(Values[Index].tag)+":"+Values[Index].value+"> is not a valid channel name");
}
vcc->Set(vi.GetString(), strlen(vi.GetString()) + 1);
@@ -1014,7 +1013,6 @@ void ServerConfig::Read()
}
/* We're done with this now */
delete Values[Index].val;
- // XXX: ServerInstance->Threads->Unlock();
}
/* Read the multiple-tag items (class tags, connect tags, etc)
@@ -1023,9 +1021,7 @@ void ServerConfig::Read()
*/
for (int Index = 0; MultiValues[Index].tag; ++Index)
{
- // XXX: ServerInstance->Threads->Lock();
MultiValues[Index].init_function(this, MultiValues[Index].tag);
- // XXX: ServerInstance->Threads->Unlock();
int number_of_tags = ConfValueEnum(MultiValues[Index].tag);
@@ -1040,7 +1036,6 @@ void ServerConfig::Read()
dt &= ~DT_ALLOW_NEWLINE;
dt &= ~DT_ALLOW_WILD;
- // XXX: ServerInstance->Threads->Lock();
/* We catch and rethrow any exception here just so we can free our mutex
*/
try
@@ -1119,10 +1114,8 @@ void ServerConfig::Read()
}
catch (CoreException &e)
{
- // XXX: ServerInstance->Threads->Unlock();
throw e;
}
- // XXX: ServerInstance->Threads->Unlock();
}
MultiValues[Index].validation_function(this, MultiValues[Index].tag, (char**)MultiValues[Index].items, vl, MultiValues[Index].datatype);
}
@@ -1143,7 +1136,6 @@ void ServerConfig::Read()
return;
}
- // XXX: ServerInstance->Threads->Lock();
for (int i = 0; i < ConfValueEnum("type"); ++i)
{
char item[MAXBUF], classn[MAXBUF], classes[MAXBUF];
@@ -1198,6 +1190,20 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
}
}
+ User* user = useruid.empty() ? NULL : ServerInstance->FindNick(useruid);
+
+ while (errstr.good())
+ {
+ std::string line;
+ getline(errstr, line, '\n');
+ if (user)
+ user->WriteServ("NOTICE %s :*** %s", user->nick.c_str(), line.c_str());
+ else
+ ServerInstance->SNO->WriteGlobalSno('a', line);
+ }
+
+ errstr.clear();
+ errstr.str().clear();
/* No old configuration -> initial boot, nothing more to do here */
if (!old)
@@ -1217,12 +1223,8 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
{
ServerInstance->SNO->WriteToSnoMask('a', "*** REHASH UNLOADED MODULE: %s",removing->c_str());
- if (!useruid.empty())
- {
- User* user = ServerInstance->FindNick(useruid);
- if (user)
- user->WriteNumeric(RPL_UNLOADEDMODULE, "%s %s :Module %s successfully unloaded.",user->nick.c_str(), removing->c_str(), removing->c_str());
- }
+ if (user)
+ user->WriteNumeric(RPL_UNLOADEDMODULE, "%s %s :Module %s successfully unloaded.",user->nick.c_str(), removing->c_str(), removing->c_str());
else
ServerInstance->SNO->WriteToSnoMask('a', "Module %s successfully unloaded.", removing->c_str());
@@ -1230,12 +1232,8 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
}
else
{
- if (!useruid.empty())
- {
- User* user = ServerInstance->FindNick(useruid);
- if (user)
- user->WriteNumeric(ERR_CANTUNLOADMODULE, "%s %s :Failed to unload module %s: %s",user->nick.c_str(), removing->c_str(), removing->c_str(), ServerInstance->Modules->LastError().c_str());
- }
+ if (user)
+ user->WriteNumeric(ERR_CANTUNLOADMODULE, "%s %s :Failed to unload module %s: %s",user->nick.c_str(), removing->c_str(), removing->c_str(), ServerInstance->Modules->LastError().c_str());
else
ServerInstance->SNO->WriteToSnoMask('a', "Failed to unload module %s: %s", removing->c_str(), ServerInstance->Modules->LastError().c_str());
}
@@ -1249,12 +1247,8 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
if (ServerInstance->Modules->Load(adding->c_str()))
{
ServerInstance->SNO->WriteToSnoMask('a', "*** REHASH LOADED MODULE: %s",adding->c_str());
- if (!useruid.empty())
- {
- User* user = ServerInstance->FindNick(useruid);
- if (user)
- user->WriteNumeric(RPL_LOADEDMODULE, "%s %s :Module %s successfully loaded.",user->nick.c_str(), adding->c_str(), adding->c_str());
- }
+ if (user)
+ user->WriteNumeric(RPL_LOADEDMODULE, "%s %s :Module %s successfully loaded.",user->nick.c_str(), adding->c_str(), adding->c_str());
else
ServerInstance->SNO->WriteToSnoMask('a', "Module %s successfully loaded.", adding->c_str());
@@ -1262,25 +1256,16 @@ void ServerConfig::Apply(ServerConfig* old, const std::string &useruid)
}
else
{
- if (!useruid.empty())
- {
- User* user = ServerInstance->FindNick(useruid);
- if (user)
- user->WriteNumeric(ERR_CANTLOADMODULE, "%s %s :Failed to load module %s: %s",user->nick.c_str(), adding->c_str(), adding->c_str(), ServerInstance->Modules->LastError().c_str());
- }
+ if (user)
+ user->WriteNumeric(ERR_CANTLOADMODULE, "%s %s :Failed to load module %s: %s",user->nick.c_str(), adding->c_str(), adding->c_str(), ServerInstance->Modules->LastError().c_str());
else
ServerInstance->SNO->WriteToSnoMask('a', "Failed to load module %s: %s", adding->c_str(), ServerInstance->Modules->LastError().c_str());
}
}
}
- // XXX: ServerInstance->Threads->Unlock();
- if (!useruid.empty())
- {
- User* user = ServerInstance->FindNick(useruid);
- if (user)
- user->WriteServ("NOTICE %s :*** Successfully rehashed server.", user->nick.c_str());
- }
+ if (user)
+ user->WriteServ("NOTICE %s :*** Successfully rehashed server.", user->nick.c_str());
else
ServerInstance->SNO->WriteToSnoMask('a', "*** Successfully rehashed server.");
}