Commit 047daea3 authored by Micha Mueller's avatar Micha Mueller
Browse files

Temporary workaround to avoid segfaults when reloading plugins

TODO: find a way to wait for all handlers dispatched by _strand to finish
parent 70facac4
......@@ -29,6 +29,9 @@ BACnetClient::BACnetClient() {
}
BACnetClient::~BACnetClient() {
if (_strand) {
delete _strand;
}
datalink_cleanup();
}
......
......@@ -18,7 +18,9 @@ BACnetConfigurator::BACnetConfigurator() {
}
BACnetConfigurator::~BACnetConfigurator() {
delete _bacClient;
if (_bacClient) {
delete _bacClient;
}
}
bool BACnetConfigurator::readConfig(std::string cfgPath) {
......
......@@ -39,6 +39,7 @@ public:
for (auto s : _sensors) {
s->stopPolling();
}
sleep(10);
delete _bacClient;
_bacClient = NULL;
_templateSensors.clear();
......
......@@ -46,6 +46,7 @@ namespace DCDB {
for (auto s : _sensors) {
s->stopPolling();
}
sleep(10);
_hosts.clear();
_templateSensors.clear();
return Configurator::reReadConfig();
......
......@@ -41,7 +41,11 @@ IPMIHost::IPMIHost(const std::string& hostName, uint32_t retransmissionTimeout,
_delayNextReadUntil = 0;
}
IPMIHost::~IPMIHost() {}
IPMIHost::~IPMIHost() {
if (_strand) {
delete _strand;
}
}
int IPMIHost::connect() {
if (!(_ipmiCtx = ipmi_ctx_create())) {
......
......@@ -39,6 +39,7 @@ public:
for (auto s : _sensors) {
s->stopPolling();
}
sleep(10);
_pdus.clear();
_templateSensors.clear();
return Configurator::reReadConfig();
......
......@@ -26,7 +26,9 @@ PDUUnit::PDUUnit() {
}
PDUUnit::~PDUUnit() {
// TODO Auto-generated destructor stub
if (_strand) {
delete _strand;
}
}
uint64_t PDUUnit::readValue(const xmlPathVector_t& xmlPath) {
......
......@@ -40,6 +40,7 @@ public:
for (auto s : _sensors) {
s->stopPolling();
}
sleep(10);
_connections.clear();
_templateSensors.clear();
return Configurator::reReadConfig();
......
......@@ -25,6 +25,10 @@ SNMPConnection::~SNMPConnection() {
free(_snmpSession.community);
_snmpSession.community_len = 0;
}
if (_strand) {
delete _strand;
}
}
void SNMPConnection::initializeStrand(boost::asio::io_service& io) {
......
......@@ -50,7 +50,7 @@ void SNMPSensor::init(boost::asio::io_service& io) {
if (_connection) {
_connection->initializeStrand(io);
} else {
LOG(error) << "No host set for sensor " << _name << "! Cannot initialize sensor.";
LOG(error) << "No connection set for sensor " << _name << "! Cannot initialize sensor.";
}
Sensor::init(io);
}
......@@ -76,7 +76,5 @@ void SNMPSensor::stopPolling() {
_keepRunning = 0;
//cancel any outstanding readAsync()
_timer->cancel();
//wait until read() finished before closing _file
_timer->wait();
LOG(info) << "Sensor " << _name << " stopped.";
}
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