Fix possible seg faults in Cpu and tach
readBuf is used by inputDev in these cases to build a buffer. If the
sensor object is being destroyed while a read is in progress, the
destructor for inputDev will happen after the destructor for readBuf,
which causes an ownership problem, and likely will cause a seg fault.
Tested: Code compiles. No further testing done at this point.
Signed-off-by: Ed Tanous <edtanous@google.com>
Change-Id: Ic7d9103a9e9c51315801b7cb213662ea3332a16c
diff --git a/include/TachSensor.hpp b/include/TachSensor.hpp
index 344e518..8dd1b88 100644
--- a/include/TachSensor.hpp
+++ b/include/TachSensor.hpp
@@ -80,9 +80,9 @@
std::unique_ptr<PresenceSensor> presence;
std::shared_ptr<sdbusplus::asio::dbus_interface> itemIface;
std::shared_ptr<sdbusplus::asio::dbus_interface> itemAssoc;
+ boost::asio::streambuf readBuf;
boost::asio::posix::stream_descriptor inputDev;
boost::asio::deadline_timer waitTimer;
- boost::asio::streambuf readBuf;
std::string path;
std::optional<std::string> led;
bool ledState = false;