Add sdbusplus::asio::connection pointer to ipmi::Context
This adds a std::shared_ptr<sdbusplus::asio::connection> to every
ipmi::Context in order to facilitate easy transition to
yield_method_call over other D-Bus interfaces. This means that a
getDbusObjects call could just pass in the ipmi::Context and it will get
a yielding call. ipmi::Context is a natural fit because one is created
for each of the boost::asio::coroutine contexts. And because a yielding
call needs both an async D-Bus connection and a yield_context, this
means that we now have one object to rule them all.
Tested: Created a handler that uses the new shared_ptr in the context
to see the API in action.
Change-Id: I429a324180a38bf17845f7fd0544df2226d0300a
Signed-off-by: Vernon Mauery <vernon.mauery@linux.intel.com>
diff --git a/ipmid-new.cpp b/ipmid-new.cpp
index 7e77b12..c32ba3f 100644
--- a/ipmid-new.cpp
+++ b/ipmid-new.cpp
@@ -536,8 +536,8 @@
entry("PRIVILEGE=%u", static_cast<uint8_t>(privilege)),
entry("RQSA=%x", rqSA));
- auto ctx = std::make_shared<ipmi::Context>(netFn, cmd, channel, userId,
- privilege, rqSA, &yield);
+ auto ctx = std::make_shared<ipmi::Context>(getSdBus(), netFn, cmd, channel,
+ userId, privilege, rqSA, &yield);
auto request = std::make_shared<ipmi::message::Request>(
ctx, std::forward<std::vector<uint8_t>>(data));
message::Response::ptr response = executeIpmiCommand(request);
@@ -748,8 +748,9 @@
std::vector<uint8_t> data;
m.read(seq, netFn, lun, cmd, data);
+ std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
auto ctx = std::make_shared<ipmi::Context>(
- netFn, cmd, 0, 0, ipmi::Privilege::Admin, 0, &yield);
+ bus, netFn, cmd, 0, 0, ipmi::Privilege::Admin, 0, &yield);
auto request = std::make_shared<ipmi::message::Request>(
ctx, std::forward<std::vector<uint8_t>>(data));
ipmi::message::Response::ptr response =
@@ -764,9 +765,9 @@
dest = m.get_sender();
path = m.get_path();
boost::system::error_code ec;
- getSdBus()->yield_method_call(yield, ec, dest, path, DBUS_INTF,
- "sendMessage", seq, netFn, lun, cmd,
- response->cc, response->payload.raw);
+ bus->yield_method_call(yield, ec, dest, path, DBUS_INTF, "sendMessage",
+ seq, netFn, lun, cmd, response->cc,
+ response->payload.raw);
if (ec)
{
log<level::ERR>("Failed to send response to requestor",