Commit ba3a8bda authored by Micha Mueller's avatar Micha Mueller
Browse files

Add failsafe to prevent sensors getting started multiple times

parent 26fead8b
......@@ -61,6 +61,12 @@ void BACnetSensor::init(boost::asio::io_service& io) {
}
void BACnetSensor::startPolling() {
if (_keepRunning) {
//we have been started already
LOG(info) << "Sensor " << _name << " already running.";
return;
}
if (_bacClient) {
_keepRunning = 1;
_timer->async_wait(_bacClient->getStrand()->wrap(std::bind(&BACnetSensor::readAsync, this)));
......
......@@ -79,6 +79,12 @@ namespace DCDB {
}
void IPMISensor::startPolling() {
if (_keepRunning) {
//we have been started already
LOG(info) << "Sensor " << _name << " already running.";
return;
}
if (_host) {
_keepRunning = 1;
_timer->async_wait(_host->getStrand()->wrap(boost::bind(&IPMISensor::readAsync, this)));
......
......@@ -55,6 +55,12 @@ void PDUSensor::init(boost::asio::io_service& io) {
}
void PDUSensor::startPolling() {
if (_keepRunning) {
//we have been started already
LOG(info) << "Sensor " << _name << " already running.";
return;
}
if (_pdu) {
_keepRunning = 1;
_timer->async_wait(_pdu->getStrand()->wrap(std::bind(&PDUSensor::readAsync, this)));
......
......@@ -64,6 +64,12 @@ void PerfCounter::readAsync() {
}
void PerfCounter::startPolling() {
if (_keepRunning) {
//we have been started already
LOG(info) << "Sensor " << _name << " already running.";
return;
}
//open perf-counter
struct perf_event_attr pe;
......
......@@ -70,6 +70,12 @@ void SysfsSensor::readAsync() {
}
void SysfsSensor::startPolling() {
if (_keepRunning) {
//we have been started already
LOG(info) << "Sensor " << _name << " already running.";
return;
}
if(_file == NULL) {
_file = fopen(_path.c_str(), "r");
if (_file == NULL) {
......
Supports Markdown
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