sensor: remove exception in error path

Any ASIO property callback handler should *not* throw an exception.
This will crash the application because there is nothing in the
ASIO stack that catches the exception and turns it into an
sd_bus_error.

It is also invalid to construct an SdBusError because it is an
internal class type of sdbusplus.

Instead of throwing the bad exception and crashing the sensor
application, print an error message and return the intended
-ERRNO (EACCES), so that sd_bus will pass it back along to the
dbus client as an sd_bus_error response.

The behavior of the underlying sd_bus library can be observed at:
    https://github.com/systemd/systemd/blob/a4121e965f43bc323ec3c0ac212cee9d339f7be0/src/libsystemd/sd-bus/bus-objects.c#L520
    https://github.com/systemd/systemd/blob/a4121e965f43bc323ec3c0ac212cee9d339f7be0/src/libsystemd/sd-bus/bus-objects.c#L683

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: Icd6dfc30eb6aa4d17c846b28c69ca4a5aa253d61
1 file changed
tree: bc88c168344d5f148da0120c060d7515a946e74b
  1. include/
  2. service_files/
  3. src/
  4. subprojects/
  5. tests/
  6. .clang-format
  7. .clang-ignore
  8. .clang-tidy
  9. .gitignore
  10. Jenkinsfile
  11. LICENSE
  12. MAINTAINERS
  13. meson.build
  14. meson_options.txt
  15. OWNERS
  16. README.md
README.md

dbus-sensors

dbus-sensors is a collection of sensor applications that provide the xyz.openbmc_project.Sensor collection of interfaces. They read sensor values from hwmon, d-bus, or direct driver access to provide readings. Some advance non-sensor features such as fan presence, pwm control, and automatic cpu detection (x86) are also supported.

key features

  • runtime re-configurable from d-bus (entity-manager or the like)

  • isolated: each sensor type is isolated into its own daemon, so a bug in one sensor is unlikely to affect another, and single sensor modifications are possible

  • async single-threaded: uses sdbusplus/asio bindings

  • multiple data inputs: hwmon, d-bus, direct driver access

sensor documentation