Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce getter for asio::connection in asio::dbus_interface #83

Open
jbbjarnason opened this issue Oct 9, 2023 · 4 comments
Open

Comments

@jbbjarnason
Copy link

Before I go through the process of making a PR on gerrit.

Do you have something against populating a getter for the shared_ptr of asio::connection within asio::dbus_interface?

@mine260309
Copy link
Contributor

By the getter, do you mean something like https://gerrit.openbmc.org/c/openbmc/sdbusplus/+/64536?

@jbbjarnason
Copy link
Author

@mine260309 Nope, even more simple, here is what I mean:

diff --git a/include/sdbusplus/asio/object_server.hpp b/include/sdbusplus/asio/object_server.hpp
index 57dcc95..a4d8ff7 100644
--- a/include/sdbusplus/asio/object_server.hpp
+++ b/include/sdbusplus/asio/object_server.hpp
@@ -398,6 +398,8 @@ class dbus_interface
                                        std::vector<std::string>{name_});
     }
 
+    auto connection() const noexcept -> std::shared_ptr<sdbusplus::asio::connection> { return conn_; }
+
     template <typename PropertyType, typename CallbackTypeGet>
     bool register_property_r(const std::string& name,
                              const PropertyType& property,

@omarhogni
Copy link

@williamspatrick is this something you would consider merging? can be very handy if you are writing a component to minimize the parameter count. Also sort of follows asio convention of getting a io_context. See this for reference https://live.boost.org/doc/libs/1_84_0/doc/html/boost_asio/reference/basic_stream_socket/get_executor.html

If so I can create a patch, get a CLA signed and submit to gerrit.

@williamspatrick
Copy link
Member

@omarhogni - Sure.

geissonator pushed a commit that referenced this issue Feb 28, 2024
Allow connection object to be accessed out of the dbus_interface. See
#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 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants