Commit d92d905a authored by Alessio Netti's avatar Alessio Netti
Browse files

Fixing segfault on return from main in dcdbpusher and other changes

- "Fixed" segmentation fault occurring after the return of dcdbpusher's
main by not unloading dynamic libraries in PluginManager's destructor
- Error log messages in Aggregator plugin changed to Debug level
- Added Wno-unused-variable and Wno-unused-function compile flags
- Tweaked the stop method of TesterSensorGroup
- Re-worked the destructor of SARParser in ProcFS plugin
parent 7c2c345a
...@@ -67,7 +67,7 @@ void AggregatorAnalyzer::computeSum(int unitID) { ...@@ -67,7 +67,7 @@ void AggregatorAnalyzer::computeSum(int unitID) {
// Getting the most recent values as specified in _window // Getting the most recent values as specified in _window
_buffer = _queryEngine.querySensor(in->getName(), _window, 0, _buffer); _buffer = _queryEngine.querySensor(in->getName(), _window, 0, _buffer);
if(!_buffer || _buffer->empty()) { if(!_buffer || _buffer->empty()) {
LOG(error) << "Analyzer " << _name << " cannot read from sensor " << in->getName() << "!"; LOG(debug) << "Analyzer " << _name << " cannot read from sensor " << in->getName() << "!";
return; return;
} }
...@@ -88,7 +88,7 @@ void AggregatorAnalyzer::computeAvg(int unitID) { ...@@ -88,7 +88,7 @@ void AggregatorAnalyzer::computeAvg(int unitID) {
// Getting the most recent values as specified in _window // Getting the most recent values as specified in _window
_buffer = _queryEngine.querySensor(in->getName(), _window, 0, _buffer); _buffer = _queryEngine.querySensor(in->getName(), _window, 0, _buffer);
if(!_buffer || _buffer->empty()) { if(!_buffer || _buffer->empty()) {
LOG(error) << "Analyzer " << _name << " cannot read from sensor " << in->getName() << "!"; LOG(debug) << "Analyzer " << _name << " cannot read from sensor " << in->getName() << "!";
return; return;
} }
...@@ -113,7 +113,7 @@ void AggregatorAnalyzer::computeMax(int unitID) { ...@@ -113,7 +113,7 @@ void AggregatorAnalyzer::computeMax(int unitID) {
// Getting the most recent values as specified in _window // Getting the most recent values as specified in _window
_buffer = _queryEngine.querySensor(in->getName(), _window, 0, _buffer); _buffer = _queryEngine.querySensor(in->getName(), _window, 0, _buffer);
if(!_buffer || _buffer->empty()) { if(!_buffer || _buffer->empty()) {
LOG(error) << "Analyzer " << _name << " cannot read from sensor " << in->getName() << "!"; LOG(debug) << "Analyzer " << _name << " cannot read from sensor " << in->getName() << "!";
return; return;
} }
...@@ -136,7 +136,7 @@ void AggregatorAnalyzer::computeMin(int unitID) { ...@@ -136,7 +136,7 @@ void AggregatorAnalyzer::computeMin(int unitID) {
// Getting the most recent values as specified in _window // Getting the most recent values as specified in _window
_buffer = _queryEngine.querySensor(in->getName(), _window, 0, _buffer); _buffer = _queryEngine.querySensor(in->getName(), _window, 0, _buffer);
if(!_buffer || _buffer->empty()) { if(!_buffer || _buffer->empty()) {
LOG(error) << "Analyzer " << _name << " cannot read from sensor " << in->getName() << "!"; LOG(debug) << "Analyzer " << _name << " cannot read from sensor " << in->getName() << "!";
return; return;
} }
......
...@@ -6,5 +6,5 @@ DEFAULT_VERSION = 0.3 ...@@ -6,5 +6,5 @@ DEFAULT_VERSION = 0.3
GIT_VERSION = $(shell git describe --tags 2>/dev/null|sed 's/-\([0-9]*\)/.\1/') GIT_VERSION = $(shell git describe --tags 2>/dev/null|sed 's/-\([0-9]*\)/.\1/')
VERSION := $(if $(GIT_VERSION),$(GIT_VERSION),$(DEFAULT_VERSION)) VERSION := $(if $(GIT_VERSION),$(GIT_VERSION),$(DEFAULT_VERSION))
CXXFLAGS = -std=c++11 -O2 -g -Wall -fmessage-length=0 -DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG -DBOOST_LOG_DYN_LINK -DVERSION=\"$(VERSION)\" CXXFLAGS = -std=c++11 -O2 -g -Wall -fmessage-length=0 -DBOOST_DATE_TIME_POSIX_TIME_STD_CONFIG -DBOOST_LOG_DYN_LINK -DVERSION=\"$(VERSION)\" -Wno-unused-function -Wno-unused-variable
OS = $(shell uname -s) OS = $(shell uname -s)
...@@ -37,7 +37,9 @@ PluginManager::PluginManager(const pluginSettings_t& pluginSettings) : ...@@ -37,7 +37,9 @@ PluginManager::PluginManager(const pluginSettings_t& pluginSettings) :
_cfgFilePath("./") {} _cfgFilePath("./") {}
PluginManager::~PluginManager() { PluginManager::~PluginManager() {
unloadPlugin(); for(const auto& p : _plugins)
p.destroy(p.configurator);
_plugins.clear();
} }
bool PluginManager::loadPlugin(const string& name, bool PluginManager::loadPlugin(const string& name,
......
...@@ -441,7 +441,7 @@ int main(int argc, char** argv) { ...@@ -441,7 +441,7 @@ int main(int argc, char** argv) {
mqttThread.join(); mqttThread.join();
LOG(info) << "MQTTPusher stopped"; LOG(info) << "MQTTPusher stopped";
LOG(info) << "Tear down objects..."; LOG(info) << "Tearing down objects...";
_sensorMap.clear(); _sensorMap.clear();
delete _httpsServer; delete _httpsServer;
delete _mqttPusher; delete _mqttPusher;
......
...@@ -54,7 +54,7 @@ ProcfsParser::ProcfsParser(std::string path) { ...@@ -54,7 +54,7 @@ ProcfsParser::ProcfsParser(std::string path) {
* Class destructor. * Class destructor.
* *
*/ */
ProcfsParser::~ProcfsParser() { close(); } ProcfsParser::~ProcfsParser() { ProcfsParser::close(); }
/** /**
* Initializes the parser. * Initializes the parser.
...@@ -512,6 +512,11 @@ bool ProcstatParser::_readMetrics() { ...@@ -512,6 +512,11 @@ bool ProcstatParser::_readMetrics() {
// ************************************************************** // **************************************************************
// Definitions for the SARParser class // Definitions for the SARParser class
/**
* Class destructor.
*
*/
SARParser::~SARParser() { SARParser::close(); }
/** /**
* Closes the parser. * Closes the parser.
......
...@@ -201,6 +201,7 @@ class SARParser : public ProcstatParser { ...@@ -201,6 +201,7 @@ class SARParser : public ProcstatParser {
public: public:
SARParser(const std::string path = "") : ProcstatParser(path) {} SARParser(const std::string path = "") : ProcstatParser(path) {}
void close() override; void close() override;
virtual ~SARParser();
protected: protected:
bool _readMetrics() override; bool _readMetrics() override;
......
...@@ -66,6 +66,11 @@ void TesterSensorGroup::start() { ...@@ -66,6 +66,11 @@ void TesterSensorGroup::start() {
} }
void TesterSensorGroup::stop() { void TesterSensorGroup::stop() {
if(_keepRunning == 0) {
LOG(info) << "Sensorgroup " << _groupName << " already stopped.";
return;
}
_keepRunning = 0; _keepRunning = 0;
//wait before closing _file //wait before closing _file
wait(); wait();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment