Scheduling of quiet vs. verbose config saving

Rename the current ECONFIG_NEED_WRITE to ECONFIG_NEED_VERBOSE_WRITE
as it always broadcasts the result for SIGUSR1, even on success.
Keep ECONFIG_NEED_WRITE for cases where the config should be written
without a notification of success.
This commit is contained in:
J-P Nurmi
2014-10-12 23:29:56 +02:00
parent a888d38511
commit 206c149f48
3 changed files with 9 additions and 6 deletions
+2 -1
View File
@@ -40,7 +40,8 @@ public:
enum ConfigState {
ECONFIG_NOTHING,
ECONFIG_NEED_REHASH,
ECONFIG_NEED_WRITE
ECONFIG_NEED_WRITE,
ECONFIG_NEED_VERBOSE_WRITE
};
void DeleteUsers();
+1 -1
View File
@@ -146,7 +146,7 @@ static void signalHandler(int sig) {
break;
case SIGUSR1:
CUtils::PrintMessage("Caught SIGUSR1");
CZNC::Get().SetConfigState(CZNC::ECONFIG_NEED_WRITE);
CZNC::Get().SetConfigState(CZNC::ECONFIG_NEED_VERBOSE_WRITE);
break;
default:
CUtils::PrintMessage("WTF? Signal handler called for a signal it doesn't know?");
+6 -4
View File
@@ -184,7 +184,8 @@ void CZNC::Loop() {
while (true) {
CString sError;
switch (GetConfigState()) {
ConfigState eState = GetConfigState();
switch (eState) {
case ECONFIG_NEED_REHASH:
SetConfigState(ECONFIG_NOTHING);
@@ -196,12 +197,13 @@ void CZNC::Loop() {
}
break;
case ECONFIG_NEED_WRITE:
case ECONFIG_NEED_VERBOSE_WRITE:
SetConfigState(ECONFIG_NOTHING);
if (WriteConfig()) {
Broadcast("Writing the config succeeded", true);
} else {
if (!WriteConfig()) {
Broadcast("Writing the config file failed", true);
} else if (eState == ECONFIG_NEED_VERBOSE_WRITE) {
Broadcast("Writing the config succeeded", true);
}
break;
case ECONFIG_NOTHING: