From 9742b534af03c12cf1b2cb71bfdfef590af9849a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=93mar=20H=C3=B6gni=20Gu=C3=B0marsson?= Date: Tue, 27 Feb 2024 15:22:56 +0000 Subject: [PATCH] Allow access to connection in object server MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Allow connection object to be accessed out of the dbus_interface. See https://github.com/openbmc/sdbusplus/issues/83 for reference. Similar pattern to asio's get_executor() method exposed on sockets. Can reduce parameter count when working in code where the dbus_interface is passed around. When components register their own interface onto a preexisting dbus_interface but require access to the connection or the connections underlying execution context. Change-Id: Ie9df1f2762f639de60b492255d6f9d85920b0fd6 Signed-off-by: Ómar Högni Guðmarsson --- include/sdbusplus/asio/object_server.hpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/include/sdbusplus/asio/object_server.hpp b/include/sdbusplus/asio/object_server.hpp index 57dcc956..e2d2f127 100644 --- a/include/sdbusplus/asio/object_server.hpp +++ b/include/sdbusplus/asio/object_server.hpp @@ -398,6 +398,12 @@ class dbus_interface std::vector{name_}); } + auto connection() const noexcept + -> std::shared_ptr + { + return conn_; + } + template bool register_property_r(const std::string& name, const PropertyType& property,