Commit 42dd81fc authored by Michael Ott's avatar Michael Ott
Browse files

Remove delays on IPMI read errors

parent 2f5bacbb
......@@ -59,7 +59,6 @@ IPMIHost::IPMIHost(const std::string &name)
_sessionTimeout(0),
_retransmissionTimeout(0),
_errorCount(0),
_delayNextReadUntil(0),
_xcc(nullptr) {
}
......@@ -77,7 +76,6 @@ IPMIHost::IPMIHost(const IPMIHost &other)
_sessionTimeout(other._sessionTimeout),
_retransmissionTimeout(other._retransmissionTimeout),
_errorCount(0),
_delayNextReadUntil(other._delayNextReadUntil),
_xcc(other._xcc) {
}
......@@ -101,7 +99,6 @@ IPMIHost &IPMIHost::operator=(const IPMIHost &other) {
_sessionTimeout = other._sessionTimeout;
_retransmissionTimeout = other._retransmissionTimeout;
_errorCount = 0;
_delayNextReadUntil = other._delayNextReadUntil;
_xcc = other._xcc;
return *this;
......@@ -176,7 +173,6 @@ bool IPMIHost::getSdrRecord(uint16_t recordId, std::vector<uint8_t> &record) {
}
} else {
_errorMsg = "Error opening SDR cache: " + std::string(ipmi_sdr_ctx_errormsg(sdrCtx));
increaseErrorCount();
disconnect();
}
} else {
......@@ -196,7 +192,6 @@ bool IPMIHost::getSdrRecord(uint16_t recordId, std::vector<uint8_t> &record) {
ipmi_sdr_cache_close(sdrCtx);
}
} else {
increaseErrorCount();
disconnect();
}
}
......@@ -224,13 +219,11 @@ int IPMIHost::sendRawCmd(const uint8_t *rawCmd, unsigned int rawCmdLen, void *bu
if (connect() == 0) {
if ((len = ipmi_cmd_raw(_ipmiCtx, rawCmd[0], rawCmd[1], &rawCmd[2], rawCmdLen - 2, buf, bufLen)) < 0) {
_errorMsg = "Error sending IPMI raw command: " + std::string(ipmi_ctx_errormsg(_ipmiCtx));
increaseErrorCount();
disconnect();
} else {
success = true;
}
} else {
increaseErrorCount();
disconnect();
}
}
......@@ -248,7 +241,6 @@ int IPMIHost::sendRawCmd(const uint8_t *rawCmd, unsigned int rawCmdLen, void *bu
return -1;
}
_errorCount = 0;
return len;
}
......@@ -268,7 +260,6 @@ double IPMIHost::readSensorRecord(std::vector<uint8_t> &record) {
if (_sensorReadCtx) {
if (ipmi_sensor_read(_sensorReadCtx, &record[0], record.size(), 0, &rawReading, &reading, &eventBitmask) < 0) {
_errorMsg = "Error reading IPMI record: " + std::string(ipmi_sensor_read_ctx_errormsg(_sensorReadCtx));
increaseErrorCount();
disconnect();
} else {
success = true;
......@@ -277,15 +268,12 @@ double IPMIHost::readSensorRecord(std::vector<uint8_t> &record) {
_errorMsg = "Error creating sensor context: " + std::string(ipmi_ctx_errormsg(_ipmiCtx));
}
} else {
increaseErrorCount();
disconnect();
}
}
double ret = .0;
if (success && reading) {
//TODO should _delayNextReadUntil be reset here?
_errorCount = 0;
ret = *reading;
free(reading);
} else {
......@@ -295,16 +283,6 @@ double IPMIHost::readSensorRecord(std::vector<uint8_t> &record) {
return ret;
}
void IPMIHost::increaseErrorCount() {
uint64_t now = getTimestamp();
if (_errorCount < 25) {
_errorCount++;
}
if (_errorCount > 5) {
_delayNextReadUntil = now + MS_TO_NS(500 * (_errorCount - 5));
}
}
void IPMIHost::printEntityConfig(LOG_LEVEL ll, unsigned int leadingSpaces) {
std::string leading(leadingSpaces, ' ');
LOG_VAR(ll) << leading << "UserName: " << getUserName();
......
......@@ -55,9 +55,6 @@ class IPMIHost : public EntityInterface {
/* Read the sensor specified by its record id. Returns sensor reading. */
double readSensorRecord(std::vector<uint8_t> &record);
void increaseErrorCount();
const uint64_t getDelayFactor() const;
void setAuth(uint8_t auth) { _auth = auth; }
void setHostName(const std::string &hostName) { _name = hostName; }
void setPassword(const std::string &password) { _password = password; }
......@@ -68,7 +65,6 @@ class IPMIHost : public EntityInterface {
void setUserName(const std::string &userName) { _userName = userName; }
void setSessionTimeout(uint32_t sessionTimeout) { _sessionTimeout = sessionTimeout; }
void setRetransmissionTimeout(uint32_t retransmissionTimeout) { _retransmissionTimeout = retransmissionTimeout; }
void setDelayNextReadUntil(uint64_t delayNextReadUntil) { _delayNextReadUntil = delayNextReadUntil; }
void setXCC(LenovoXCC* xcc) { _xcc = xcc; }
uint8_t getAuth() const { return _auth; }
......@@ -79,7 +75,6 @@ class IPMIHost : public EntityInterface {
uint8_t getCipher() const { return _cipher; }
uint8_t getIpmiVersion() const { return _ipmiVersion; }
const std::string &getUserName() const { return _userName; }
uint64_t getDelayNextReadUntil() const { return _delayNextReadUntil; }
LenovoXCC* getXCC() { return _xcc; }
void printEntityConfig(LOG_LEVEL ll, unsigned int leadingSpaces) final override;
......@@ -108,7 +103,6 @@ class IPMIHost : public EntityInterface {
uint32_t _retransmissionTimeout;
uint32_t _errorCount;
std::string _errorMsg;
volatile uint64_t _delayNextReadUntil;
LenovoXCC* _xcc;
};
......
......@@ -111,14 +111,6 @@ void IPMISensorGroup::read() {
reading.value = 0;
reading.timestamp = getTimestamp();
//TODO with SensorGroup refactor we lost the ability to sleep until
// delayNextRead. Instead we are now checking every time if we can read
// again. Overhead acceptable? General delayNextReadUntil implementation in
// SensorGroupTemplate required?
if (reading.timestamp < _entity->getDelayNextReadUntil()) {
return;
}
for (const auto &s : _sensors) {
try {
switch (s->getType()) {
......
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