diff options
author | Ed Tanous <edtanous@google.com> | 2022-09-09 01:10:39 +0300 |
---|---|---|
committer | Ed Tanous <edtanous@google.com> | 2022-09-09 03:33:34 +0300 |
commit | 6936afe4e687c8e94b7b1281fa9796101202871a (patch) | |
tree | 36745da1b0068e950f39dea623a3a36b8e59bad2 | |
parent | 38c8a6f28b69ed4a08b8d20056db37dac071c05c (diff) | |
download | bmcweb-6936afe4e687c8e94b7b1281fa9796101202871a.tar.xz |
Fix thrown exception
The newest version of clang detects this as an exception thrown in a
destructor. To solve this, this commit moves the returned data to a
struct, and loads it backs into io::service::post().
Tested:
Not sure I know how to test this, and this code was checked in prior to
tested statements being required.
Change-Id: Ieef32e43d89043fe99fbbf46cceb794b08db8b13
Signed-off-by: Ed Tanous <edtanous@google.com>
-rw-r--r-- | redfish-core/lib/managers.hpp | 41 |
1 files changed, 30 insertions, 11 deletions
diff --git a/redfish-core/lib/managers.hpp b/redfish-core/lib/managers.hpp index f934fd6f98..a52b7b5281 100644 --- a/redfish-core/lib/managers.hpp +++ b/redfish-core/lib/managers.hpp @@ -1173,6 +1173,12 @@ inline CreatePIDRet createPidInterface( } struct GetPIDValues : std::enable_shared_from_this<GetPIDValues> { + struct CompletionValues + { + std::vector<std::string> supportedProfiles; + std::string currentProfile; + dbus::utility::MapperGetSubTreeResponse subtree; + }; explicit GetPIDValues( const std::shared_ptr<bmcweb::AsyncResp>& asyncRespIn) : @@ -1195,7 +1201,7 @@ struct GetPIDValues : std::enable_shared_from_this<GetPIDValues> messages::internalError(self->asyncResp->res); return; } - self->subtree = subtreeLocal; + self->complete.subtree = subtreeLocal; }, "xyz.openbmc_project.ObjectMapper", "/xyz/openbmc_project/object_mapper", @@ -1257,8 +1263,8 @@ struct GetPIDValues : std::enable_shared_from_this<GetPIDValues> messages::internalError(self->asyncResp->res); return; } - self->currentProfile = *current; - self->supportedProfiles = *supported; + self->complete.currentProfile = *current; + self->complete.supportedProfiles = *supported; }); }, "xyz.openbmc_project.ObjectMapper", @@ -1267,16 +1273,23 @@ struct GetPIDValues : std::enable_shared_from_this<GetPIDValues> std::array<const char*, 1>{thermalModeIface}); } - ~GetPIDValues() + static void + processingComplete(const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, + const CompletionValues& completion) { if (asyncResp->res.result() != boost::beast::http::status::ok) { return; } // create map of <connection, path to objMgr>> - boost::container::flat_map<std::string, std::string> objectMgrPaths; - boost::container::flat_set<std::string> calledConnections; - for (const auto& pathGroup : subtree) + boost::container::flat_map< + std::string, std::string, std::less<>, + std::vector<std::pair<std::string, std::string>>> + objectMgrPaths; + boost::container::flat_set<std::string, std::less<>, + std::vector<std::string>> + calledConnections; + for (const auto& pathGroup : completion.subtree) { for (const auto& connectionGroup : pathGroup.second) { @@ -1310,7 +1323,8 @@ struct GetPIDValues : std::enable_shared_from_this<GetPIDValues> calledConnections.insert(connectionGroup.first); asyncPopulatePid(findObjMgr->first, findObjMgr->second, - currentProfile, supportedProfiles, + completion.currentProfile, + completion.supportedProfiles, asyncResp); break; } @@ -1319,15 +1333,20 @@ struct GetPIDValues : std::enable_shared_from_this<GetPIDValues> } } + ~GetPIDValues() + { + boost::asio::post(crow::connections::systemBus->get_io_context(), + std::bind_front(&processingComplete, asyncResp, + std::move(complete))); + } + GetPIDValues(const GetPIDValues&) = delete; GetPIDValues(GetPIDValues&&) = delete; GetPIDValues& operator=(const GetPIDValues&) = delete; GetPIDValues& operator=(GetPIDValues&&) = delete; - std::vector<std::string> supportedProfiles; - std::string currentProfile; - dbus::utility::MapperGetSubTreeResponse subtree; std::shared_ptr<bmcweb::AsyncResp> asyncResp; + CompletionValues complete; }; struct SetPIDValues : std::enable_shared_from_this<SetPIDValues> |