Add Timer check avoid multiple clicks
There are too many calls if power status changed quickly.
Add timer check to avoid multiple calls.
Tested: Power status change quickly, only one call to
rescanBusses.
Change-Id: Ib982f2dea205399a30eb3d68855b24456130b392
Signed-off-by: Jian Zhang <zhangjian.3032@bytedance.com>
diff --git a/src/fru_device.cpp b/src/fru_device.cpp
index df97b1b..af1155e 100644
--- a/src/fru_device.cpp
+++ b/src/fru_device.cpp
@@ -943,7 +943,18 @@
timer.expires_from_now(boost::posix_time::seconds(1));
// setup an async wait in case we get flooded with requests
- timer.async_wait([&](const boost::system::error_code&) {
+ timer.async_wait([&](const boost::system::error_code& ec) {
+ if (ec == boost::asio::error::operation_aborted)
+ {
+ return;
+ }
+
+ if (ec)
+ {
+ std::cerr << "Error in timer: " << ec.message() << "\n";
+ return;
+ }
+
auto devDir = fs::path("/dev/");
std::vector<fs::path> i2cBuses;