From 206c149f48c414255aeee00260a2efecead9a105 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Sun, 12 Oct 2014 23:29:56 +0200 Subject: [PATCH] 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. --- include/znc/znc.h | 3 ++- src/main.cpp | 2 +- src/znc.cpp | 10 ++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/include/znc/znc.h b/include/znc/znc.h index b4f3e8de..be053042 100644 --- a/include/znc/znc.h +++ b/include/znc/znc.h @@ -40,7 +40,8 @@ public: enum ConfigState { ECONFIG_NOTHING, ECONFIG_NEED_REHASH, - ECONFIG_NEED_WRITE + ECONFIG_NEED_WRITE, + ECONFIG_NEED_VERBOSE_WRITE }; void DeleteUsers(); diff --git a/src/main.cpp b/src/main.cpp index 02fcf897..844c8a3d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -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?"); diff --git a/src/znc.cpp b/src/znc.cpp index 9734c799..fdd36f42 100644 --- a/src/znc.cpp +++ b/src/znc.cpp @@ -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: