entity-manager: remove global io_context
Remove the global var
```
boost::asio::io_context io
```
and move it to be a local var in the main function.
Since boost::asio::io_context io is declared first, it in scope for the
entire program duration and should not cause any issues from that
perspective.
The io_context is passed through where needed. In case there is a class
already defined, the class now has a reference to the io_context to
avoid passing it through everywhere.
Tested: Capturing or passing a reference which is always valid should
not introduce any issues.
Tested on Tyan S8030:
```
Jul 01 09:59:26 s8030-bmc-30303035c0c1 entity-manager[4204]: Inventory Added: Supermicro PWS 920P SQ 0
Jul 01 09:59:26 s8030-bmc-30303035c0c1 entity-manager[4204]: Inventory Added: Supermicro PWS 920P SQ 1
Jul 01 09:59:26 s8030-bmc-30303035c0c1 entity-manager[4204]: Inventory Added: chassis
Jul 01 09:59:26 s8030-bmc-30303035c0c1 entity-manager[4204]: Inventory Added: MBX 1.57 Chassis
```
busctl tree output as before
Change-Id: Ie8f7d18c38d166c57a9cb645ab45c9103bbdff6e
Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com>
diff --git a/src/entity_manager/dbus_interface.hpp b/src/entity_manager/dbus_interface.hpp
index 60527e3..84cfbba 100644
--- a/src/entity_manager/dbus_interface.hpp
+++ b/src/entity_manager/dbus_interface.hpp
@@ -123,18 +123,19 @@
const std::string& jsonPointerPath,
const std::shared_ptr<sdbusplus::asio::dbus_interface>& iface,
sdbusplus::asio::object_server& objServer,
- nlohmann::json& systemConfiguration);
+ nlohmann::json& systemConfiguration, boost::asio::io_context& io);
void populateInterfaceFromJson(
- nlohmann::json& systemConfiguration, const std::string& jsonPointerPath,
+ boost::asio::io_context& io, nlohmann::json& systemConfiguration,
+ const std::string& jsonPointerPath,
std::shared_ptr<sdbusplus::asio::dbus_interface>& iface,
nlohmann::json& dict, sdbusplus::asio::object_server& objServer,
sdbusplus::asio::PropertyPermission permission =
sdbusplus::asio::PropertyPermission::readOnly);
void createAddObjectMethod(
- const std::string& jsonPointerPath, const std::string& path,
- nlohmann::json& systemConfiguration,
+ boost::asio::io_context& io, const std::string& jsonPointerPath,
+ const std::string& path, nlohmann::json& systemConfiguration,
sdbusplus::asio::object_server& objServer, const std::string& board);
std::vector<std::weak_ptr<sdbusplus::asio::dbus_interface>>&