From 6640762196b39ef01df420966af256556add78ca Mon Sep 17 00:00:00 2001 From: Ken Moore Date: Mon, 22 Feb 2016 12:53:27 -0500 Subject: [PATCH] Fix up the timers in the event watcher. Due to the multi-threading, we need to create the timers in the start() function instead of the constructor. --- src/server/EventWatcher.cpp | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/server/EventWatcher.cpp b/src/server/EventWatcher.cpp index 3de5f8a..af62542 100644 --- a/src/server/EventWatcher.cpp +++ b/src/server/EventWatcher.cpp @@ -11,7 +11,17 @@ // === PUBLIC === EventWatcher::EventWatcher(){ qRegisterMetaType("EventWatcher::EVENT_TYPE"); - + //Only put non-thread-specific stuff here + starting = true; + oldhostname = sysadm::General::RunCommand("hostname").simplified(); + +} + +EventWatcher::~EventWatcher(){ +} + +void EventWatcher::start(){ + //Make sure that any new timer/etc are setup here (multi-thread issues) starting = true; watcher = new QFileSystemWatcher(this); filechecktimer = new QTimer(this); @@ -20,24 +30,17 @@ EventWatcher::EventWatcher(){ connect(watcher, SIGNAL(fileChanged(const QString&)), this, SLOT(WatcherUpdate(const QString&)) ); connect(watcher, SIGNAL(directoryChanged(const QString&)), this, SLOT(WatcherUpdate(const QString&)) ); connect(filechecktimer, SIGNAL(timeout()), this, SLOT( CheckLogFiles()) ); - - oldhostname = sysadm::General::RunCommand("hostname").simplified(); syschecktimer = new QTimer(this); syschecktimer->setSingleShot(false); syschecktimer->setInterval(900000); //15 minute checks connect(syschecktimer, SIGNAL(timeout()), this, SLOT( CheckSystemState()) ); -} - -EventWatcher::~EventWatcher(){ -} - -void EventWatcher::start(){ - starting = true; // - Life Preserver Events WatcherUpdate(LPLOG); //load it initially (will also add it to the watcher); WatcherUpdate(LPERRLOG); //load it initially (will also add it to the watcher); filechecktimer->start(); + syschecktimer->start(); + QTimer::singleShot(0, this, SLOT(CheckSystemState()) ); starting = false; }