[PATCH phosphor-objmgr 1/2] Discard existing interfaces

OpenBMC Patches openbmc-patches at stwcx.xyz
Fri Feb 5 07:50:31 AEDT 2016


From: Brad Bishop <bradleyb at us.ibm.com>

Avoid the need for syncronization between the mapper and services
emitting interfaces added signals by discarding interfaces that have
already been discovered.  This can happen when ia service emits the
interfaces added signal in quick sucession to the name owner changed
signal, and the mapper discovers the new interface while handling
the name owner changed signal.
---
 phosphor-mapper | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/phosphor-mapper b/phosphor-mapper
index f5b1def..da4ae63 100644
--- a/phosphor-mapper
+++ b/phosphor-mapper
@@ -70,9 +70,7 @@ class ObjectMapper(dbus.service.Object):
 			return
 
 		matches = [ x for x in iprops.iterkeys() if self.intf_match(x) ]
-		d = self.cache.setdefault(path, {})
-		d.setdefault(kw['sender'], []).extend(matches)
-		self.cache[path] = d
+		self.add_interfaces(path, kw['sender'], matches)
 
 	def interfaces_removed_handler(self, path, interfaces, **kw):
 		name = self.bus.get_owned_name(self.bus_match, kw['sender'])
@@ -130,9 +128,9 @@ class ObjectMapper(dbus.service.Object):
 			self.process_old_owner(old)
 
 	def add_interfaces(self, path, owner, interfaces):
-		d = self.cache.setdefault(path, { })
-		d.setdefault(owner, []).extend(interfaces)
-		self.cache[path] = d
+		d = self.cache.setdefault(path, {})
+		d = d.setdefault(owner, [])
+		self.cache[path][owner] = list(set(d + interfaces))
 
 	def add_items(self, owner, bus_items):
 		for x,y in bus_items.iteritems():
-- 
2.6.4




More information about the openbmc mailing list