diff options
| author | Andrew Geissler <andrewg@us.ibm.com> | 2017-06-13 16:15:30 -0500 |
|---|---|---|
| committer | Patrick Williams <patrick@stwcx.xyz> | 2017-06-16 05:48:10 +0000 |
| commit | ac8b7c6b71f089a9054e34d555c14ad14dd501b4 (patch) | |
| tree | 9b9d8e733ae55b57c328a1583e41feeb09f05033 /sysfs.cpp | |
| parent | 1f8a9586266d90f8d88b5c1af51833b067d9c0b8 (diff) | |
| download | phosphor-hwmon-ac8b7c6b71f089a9054e34d555c14ad14dd501b4.tar.gz phosphor-hwmon-ac8b7c6b71f089a9054e34d555c14ad14dd501b4.zip | |
Don't exit with error when hwmon dir is removed
There is a race condition between when an hwmon
directory is removed and systemd halting the
phosphor-hwmon application monitoring it. This
code change ensures the application does not return
an error in these cases.
Resolves openbmc/openbmc#1789
Change-Id: If4f032759c522aa811d4092e7a7d8ea275480e4a
Signed-off-by: Andrew Geissler <andrewg@us.ibm.com>
Diffstat (limited to 'sysfs.cpp')
| -rw-r--r-- | sysfs.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -180,6 +180,18 @@ int readSysfsWithCallout(const std::string& root, // errno should still reflect the error from the failing open // or read system calls that got us here. auto rc = errno; + + // If the directory disappeared then this application should gracefully + // exit. There are race conditions between the unloading of a hwmon + // driver and the stopping of this service by systemd. To prevent + // this application from falsely failing in these scenarios, it will + // simply exit if the directory or file can not be found. It is up + // to the user(s) of this provided hwmon object to log the appropriate + // errors if the object disappears when it should not. + if (rc == ENOENT) + { + exit(0); + } instancePath /= "device"; using namespace sdbusplus::xyz::openbmc_project::Sensor::Device::Error; report<ReadFailure>( |

