mainloop: Cache devpath at startup
Currently the devpath is determined after a bus error to make
a callout. Finding the path at startup is less prone to race
conditions around ENOENT on driver unload in the event of a
callout.
Change-Id: I8ce8d9f630c8b7ecc398082002aa113ab352d3cb
Signed-off-by: Brad Bishop <bradleyb@fuzziesquirrel.com>
diff --git a/readd.cpp b/readd.cpp
index 95c6887..c7d0466 100644
--- a/readd.cpp
+++ b/readd.cpp
@@ -53,9 +53,17 @@
// Finished getting options out, so cleanup the parser.
options.reset();
+ // Determine the physical device sysfs path.
+ auto calloutPath = sysfs::findCalloutPath(path);
+ if (calloutPath.empty())
+ {
+ exit_with_error("Unable to determine callout path.", argv);
+ }
+
MainLoop loop(
sdbusplus::bus::new_default(),
path,
+ calloutPath,
BUSNAME_PREFIX,
SENSOR_ROOT);
loop.run();