Handle losing association endpoints

If the endpoint path of an association (not the path that has the
org.openbmc.Associations interface) goes off of D-Bus, then remove the 2
association objects and move this association to the list of pending
ones.  That way if it ever comes back, the association objects will be
re-added.

This commit adds a moveAssociationToPending function in the code paths
where the mapper sees D-Bus paths going away.  That function will find
all associations that involve that path, and then remove the actual
association paths and add them to the list of pending ones.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I14d5ddf8f65be866c2cedd5f467d65adf8e3af95
diff --git a/src/main.cpp b/src/main.cpp
index 84d5b67..1ae2c6c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -558,11 +558,27 @@
                 }
 
                 interface_set->second.erase(interface);
-                // If this was the last interface on this connection,
-                // erase the connection
+
                 if (interface_set->second.empty())
                 {
+                    // If this was the last interface on this connection,
+                    // erase the connection
                     connection_map->second.erase(interface_set);
+
+                    // Instead of checking if every single path is the endpoint
+                    // of an association that needs to be moved to pending,
+                    // only check when the only remaining owner of this path is
+                    // ourself, which would be because we still own the
+                    // association path.
+                    if ((connection_map->second.size() == 1) &&
+                        (connection_map->second.begin()->first ==
+                         "xyz.openbmc_project.ObjectMapper"))
+                    {
+                        // Remove the 2 association D-Bus paths and move the
+                        // association to pending.
+                        moveAssociationToPending(obj_path.str, associationMaps,
+                                                 server);
+                    }
                 }
             }
             // If this was the last connection on this object path,