Skip to content

Commit

Permalink
boost version 1.86 support
Browse files Browse the repository at this point in the history
Added fix for boost::asio::spawn overload issue reported similar
to chriskohlhoff/asio#1524, during boost 1.86 migration build.

Proposed fix is to use default completion token.

Tested: verified build

Change-Id: Ie3ebcf963f998fd6064e8efab49d1fe584d4b587
Signed-off-by: Jayanth Othayoth <[email protected]>
  • Loading branch information
ojayanth committed Nov 18, 2024
1 parent 8bd9a9b commit 531223f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 38 deletions.
8 changes: 5 additions & 3 deletions dbus-sdr/storagecommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,11 @@ void startMatch(void)
});

// call once to populate
boost::asio::spawn(*getIoContext(), [](boost::asio::yield_context yield) {
replaceCacheFru(getSdBus(), yield);
});
boost::asio::spawn(*getIoContext(),
[](boost::asio::yield_context yield) {
replaceCacheFru(getSdBus(), yield);
},
{});
}

/** @brief implements the read FRU data command
Expand Down
73 changes: 38 additions & 35 deletions ipmid-new.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -764,41 +764,44 @@ void handleLegacyIpmiCommand(sdbusplus::message_t& m)
{
// make a copy so the next two moves don't wreak havoc on the stack
sdbusplus::message_t b{m};
boost::asio::spawn(*getIoContext(), [b = std::move(b)](
boost::asio::yield_context yield) {
sdbusplus::message_t m{std::move(b)};
unsigned char seq = 0, netFn = 0, lun = 0, cmd = 0;
ipmi::SecureBuffer data;

m.read(seq, netFn, lun, cmd, data);
std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
auto ctx = std::make_shared<ipmi::Context>(
bus, netFn, lun, cmd, 0, 0, 0, ipmi::Privilege::Admin, 0, 0, yield);
auto request = std::make_shared<ipmi::message::Request>(
ctx, std::forward<ipmi::SecureBuffer>(data));
ipmi::message::Response::ptr response =
ipmi::executeIpmiCommand(request);

// Responses in IPMI require a bit set. So there ya go...
netFn |= 0x01;

const char *dest, *path;
constexpr const char* DBUS_INTF = "org.openbmc.HostIpmi";

dest = m.get_sender();
path = m.get_path();
boost::system::error_code ec;
bus->yield_method_call(yield, ec, dest, path, DBUS_INTF, "sendMessage",
seq, netFn, lun, cmd, response->cc,
response->payload.raw);
if (ec)
{
lg2::error(
"Failed to send response to requestor ({NETFN}/{CMD}): {ERROR}",
"ERROR", ec.message(), "SENDER", dest, "NETFN", lg2::hex, netFn,
"CMD", lg2::hex, cmd);
}
});
boost::asio::spawn(
*getIoContext(),
[b = std::move(b)](boost::asio::yield_context yield) {
sdbusplus::message_t m{std::move(b)};
unsigned char seq = 0, netFn = 0, lun = 0, cmd = 0;
ipmi::SecureBuffer data;

m.read(seq, netFn, lun, cmd, data);
std::shared_ptr<sdbusplus::asio::connection> bus = getSdBus();
auto ctx = std::make_shared<ipmi::Context>(
bus, netFn, lun, cmd, 0, 0, 0, ipmi::Privilege::Admin, 0, 0,
yield);
auto request = std::make_shared<ipmi::message::Request>(
ctx, std::forward<ipmi::SecureBuffer>(data));
ipmi::message::Response::ptr response =
ipmi::executeIpmiCommand(request);

// Responses in IPMI require a bit set. So there ya go...
netFn |= 0x01;

const char *dest, *path;
constexpr const char* DBUS_INTF = "org.openbmc.HostIpmi";

dest = m.get_sender();
path = m.get_path();
boost::system::error_code ec;
bus->yield_method_call(yield, ec, dest, path, DBUS_INTF,
"sendMessage", seq, netFn, lun, cmd,
response->cc, response->payload.raw);
if (ec)
{
lg2::error(
"Failed to send response to requestor ({NETFN}/{CMD}): {ERROR}",
"ERROR", ec.message(), "SENDER", dest, "NETFN", lg2::hex,
netFn, "CMD", lg2::hex, cmd);
}
},
{});
}

#endif /* ALLOW_DEPRECATED_API */
Expand Down

0 comments on commit 531223f

Please sign in to comment.