From e8b340bd94021cb8c9eb0725168bfd9fa9e1a670 Mon Sep 17 00:00:00 2001 From: Matthew Barth Date: Fri, 9 Nov 2018 10:05:34 -0600 Subject: control: Add interface when not in service cache When a service is cached, each interface it hosts is added to a list. In the case where an object path given to fan control is never found, a service lookup is performed on this path causing its given interface to be added. This fixes that interface from continuously being added in the case that the object path is attempted to be accessed continuously from dbus. Resolves openbmc/phosphor-fan-presence#12 Tested: Added & removed events containing object paths that dont exist, interface list remains the same size. Change-Id: Id034e7829566979c196cb9901cbea287ddab78d4 Signed-off-by: Matthew Barth --- control/zone.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/control/zone.cpp b/control/zone.cpp index 4e8a749..4531151 100644 --- a/control/zone.cpp +++ b/control/zone.cpp @@ -555,8 +555,13 @@ const std::string& Zone::addServices(const std::string& path, // Service found in cache for (auto& iIter : sIter.second) { - // Add interface to cache - servIter->second.emplace_back(iIter); + if (std::find(servIter->second.begin(), + servIter->second.end(), + iIter) == servIter->second.end()) + { + // Add interface to cache + servIter->second.emplace_back(iIter); + } } } else -- cgit v1.2.1