diff options
author | Vernon Mauery <vernon.mauery@linux.intel.com> | 2019-05-13 15:32:37 -0700 |
---|---|---|
committer | Vernon Mauery <vernon.mauery@linux.intel.com> | 2019-05-30 15:24:18 +0000 |
commit | 33298af179718bf6da82634101578eff39b4a9ae (patch) | |
tree | 200782358e909b6f8b4c2f487ca54bed58b3af15 /include/ipmid | |
parent | db2e8c45727ba98e26778b8c754b92e093e6921c (diff) | |
download | phosphor-host-ipmid-33298af179718bf6da82634101578eff39b4a9ae.tar.gz phosphor-host-ipmid-33298af179718bf6da82634101578eff39b4a9ae.zip |
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>
Diffstat (limited to 'include/ipmid')
-rw-r--r-- | include/ipmid/message.hpp | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/include/ipmid/message.hpp b/include/ipmid/message.hpp index 7841e9e..4864f4e 100644 --- a/include/ipmid/message.hpp +++ b/include/ipmid/message.hpp @@ -23,6 +23,7 @@ #include <ipmid/message/types.hpp> #include <memory> #include <phosphor-logging/log.hpp> +#include <sdbusplus/asio/connection.hpp> #include <tuple> #include <utility> #include <vector> @@ -34,27 +35,32 @@ struct Context { using ptr = std::shared_ptr<Context>; - Context() = default; - - Context(NetFn netFn, Cmd cmd, int channel, int userId, Privilege priv, - int rqSA = 0, boost::asio::yield_context* yield = nullptr) : - netFn(netFn), - cmd(cmd), channel(channel), userId(userId), priv(priv), rqSA(rqSA), - yield(yield) + Context() = delete; + Context(const Context&) = default; + Context& operator=(const Context&) = default; + Context(Context&&) = delete; + Context& operator=(Context&&) = delete; + + Context(std::shared_ptr<sdbusplus::asio::connection> bus, NetFn netFn, + Cmd cmd, int channel, int userId, Privilege priv, int rqSA, + boost::asio::yield_context* yield) : + bus(bus), + netFn(netFn), cmd(cmd), channel(channel), userId(userId), priv(priv), + rqSA(rqSA), yield(yield) { } + std::shared_ptr<sdbusplus::asio::connection> bus; // normal IPMI context (what call is this, from whence it came...) - NetFn netFn = 0; - Cmd cmd = 0; - int channel = 0; - int userId = 0; - Privilege priv = Privilege::None; + NetFn netFn; + Cmd cmd; + int channel; + int userId; + Privilege priv; // srcAddr is only set on IPMB requests because // Platform Event Message needs it to determine the incoming format - int rqSA = 0; - // if non-null, use this to do blocking asynchronous asio calls - boost::asio::yield_context* yield = nullptr; + int rqSA; + boost::asio::yield_context* yield; }; namespace message |