mirror of
https://github.com/znc/znc.git
synced 2026-08-07 09:22:55 +02:00
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:
+2
-1
@@ -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
@@ -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
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user