Rehash on SIGHUP

git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@951 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2008-02-10 16:45:18 +00:00
parent 8e33a7370f
commit e326f6eb35
3 changed files with 34 additions and 0 deletions
+7
View File
@@ -54,6 +54,10 @@ static void die(int sig) {
exit(sig);
}
static void rehash(int sig) {
CZNC::Get().SetNeedRehash(true);
}
int main(int argc, char** argv) {
CString sConfig;
CString sDataDir = "";
@@ -241,6 +245,9 @@ int main(int argc, char** argv) {
sigaction(SIGSEGV, &sa, (struct sigaction*) NULL);
sigaction(SIGTERM, &sa, (struct sigaction*) NULL);
sa.sa_handler = rehash;
sigaction(SIGHUP, &sa, (struct sigaction*) NULL);
int iRet = 0;
try {
+23
View File
@@ -23,6 +23,7 @@ CZNC::CZNC() {
m_uBytesRead = 0;
m_uBytesWritten = 0;
m_pConnectUserTimer = NULL;
m_bNeedRehash = false;
}
CZNC::~CZNC() {
@@ -176,6 +177,28 @@ bool CZNC::HandleUserDeletion()
int CZNC::Loop() {
while (true) {
CString sError;
map<CString, CUser*>::iterator it;
map<CString, CUser*>::iterator end;
if (GetNeedRehash()) {
SetNeedRehash(false);
bool b = RehashConfig(sError);
end = m_msUsers.end();
for (it = m_msUsers.begin(); it != end; it++) {
if (it->second->IsAdmin()) {
if (b) {
it->second->PutStatus("Rehashing succeeded");
} else {
it->second->PutStatus("Rehashing failed: " + sError);
it->second->PutStatus("ZNC is in some possibly inconsistent state!");
}
}
}
}
// Check for users that need to be deleted
if (HandleUserDeletion()) {
// Also remove those user(s) from the config file
+4
View File
@@ -124,12 +124,14 @@ public:
void UpdateTrafficStats();
// Setters
void SetNeedRehash(bool b) { m_bNeedRehash = b; }
void SetStatusPrefix(const CString& s) { m_sStatusPrefix = (s.empty()) ? "*" : s; }
void SetISpoofFile(const CString& s) { m_sISpoofFile = s; }
void SetISpoofFormat(const CString& s) { m_sISpoofFormat = (s.empty()) ? "global { reply \"%\" }" : s; }
// !Setters
// Getters
bool GetNeedRehash() { return m_bNeedRehash; }
CSockManager& GetManager() { return m_Manager; }
#ifdef _MODULES
CGlobalModules& GetModules() { return *m_pModules; }
@@ -177,7 +179,9 @@ private:
bool DoRehash(CString& sError);
// Returns true if something was done
bool HandleUserDeletion();
protected:
bool m_bNeedRehash;
vector<CListener*> m_vpListeners;
map<CString,CUser*> m_msUsers;
map<CString,CUser*> m_msDelUsers;