Check for pending associations
When the mapper is adding a new D-Bus path to its path map,
either via an introspect or in the interfacesAdded handler,
check if that new path has an outstanding pending association.
If it does, then create the 2 real association paths and
remove that entry from the pending associations maps.
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I2da8109b5cba8596eb0c14a6af0d377472ca4145
diff --git a/src/main.cpp b/src/main.cpp
index 49b1344..84d5b67 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -81,7 +81,7 @@
{
InProgressIntrospect(
sdbusplus::asio::connection* system_bus, boost::asio::io_service& io,
- const std::string& process_name
+ const std::string& process_name, AssociationMaps& am
#ifdef DEBUG
,
std::shared_ptr<std::chrono::time_point<std::chrono::steady_clock>>
@@ -89,7 +89,7 @@
#endif
) :
system_bus(system_bus),
- io(io), process_name(process_name)
+ io(io), process_name(process_name), assocMaps(am)
#ifdef DEBUG
,
global_start_time(global_start_time),
@@ -120,6 +120,7 @@
sdbusplus::asio::connection* system_bus;
boost::asio::io_service& io;
std::string process_name;
+ AssociationMaps& assocMaps;
#ifdef DEBUG
std::shared_ptr<std::chrono::time_point<std::chrono::steady_clock>>
global_start_time;
@@ -209,6 +210,11 @@
pElement = pElement->NextSiblingElement("interface");
}
+ // Check if this new path has a pending association that can
+ // now be completed.
+ checkIfPendingAssociation(path, interface_map,
+ transaction->assocMaps, objectServer);
+
pElement = pRoot->FirstChildElement("node");
while (pElement != nullptr)
{
@@ -234,6 +240,7 @@
void start_new_introspect(
sdbusplus::asio::connection* system_bus, boost::asio::io_service& io,
interface_map_type& interface_map, const std::string& process_name,
+ AssociationMaps& assocMaps,
#ifdef DEBUG
std::shared_ptr<std::chrono::time_point<std::chrono::steady_clock>>
global_start_time,
@@ -243,7 +250,8 @@
if (needToIntrospect(process_name, service_whitelist, service_blacklist))
{
std::shared_ptr<InProgressIntrospect> transaction =
- std::make_shared<InProgressIntrospect>(system_bus, io, process_name
+ std::make_shared<InProgressIntrospect>(system_bus, io, process_name,
+ assocMaps
#ifdef DEBUG
,
global_start_time
@@ -280,11 +288,11 @@
boost::asio::io_service& io, interface_map_type& interface_map,
sdbusplus::asio::connection* system_bus,
boost::container::flat_map<std::string, std::string>& name_owners,
- sdbusplus::asio::object_server& objectServer)
+ AssociationMaps& assocMaps, sdbusplus::asio::object_server& objectServer)
{
system_bus->async_method_call(
- [&io, &interface_map, &name_owners, &objectServer,
- system_bus](const boost::system::error_code ec,
+ [&io, &interface_map, &name_owners, &objectServer, system_bus,
+ &assocMaps](const boost::system::error_code ec,
std::vector<std::string> process_names) {
if (ec)
{
@@ -306,7 +314,7 @@
service_blacklist))
{
start_new_introspect(system_bus, io, interface_map,
- process_name,
+ process_name, assocMaps,
#ifdef DEBUG
global_start_time,
#endif
@@ -481,7 +489,7 @@
{
name_owners[new_owner] = name;
start_new_introspect(system_bus.get(), io, interface_map,
- name,
+ name, associationMaps,
#ifdef DEBUG
transaction,
#endif
@@ -828,7 +836,8 @@
iface->initialize();
io.post([&]() {
- doListNames(io, interface_map, system_bus.get(), name_owners, server);
+ doListNames(io, interface_map, system_bus.get(), name_owners,
+ associationMaps, server);
});
io.run();