3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-21 22:09:23 +01:00

wfd-source: Fix some races on iwd name owner change

Subscribe to InterfacesAdded/Removed/PropertiesChanged signals before
using GetManagedObjects.  For some reason when iwd starts after the
client, we consistently get the managed objects list from before Adapter
interfaces are added but we miss the subsequent InterfacesAdded
signals, probably has to do with the GetManagedObjects and the AddMatch
calls all being synchronous.

Secondly call self.populate_devices() on init as it won't be called if
IWD is not on the bus.
This commit is contained in:
Andrew Zaborowski 2020-08-04 16:52:58 +02:00 committed by Denis Kenzior
parent b12a9f599d
commit fb4b7e7a0b

View File

@ -826,6 +826,7 @@ class WFDSource(Gtk.Window):
self.rtsp_port = 7236
self.devices = None
self.objects = {}
self.populate_devices()
self.dbus = dbus.SystemBus()
self.dbus.watch_name_owner('net.connman.iwd', self.on_name_owner_change)
self.on_name_owner_change('dummy' if self.dbus.name_has_owner('net.connman.iwd') else '')
@ -857,17 +858,6 @@ class WFDSource(Gtk.Window):
return True
manager = dbus.Interface(self.dbus.get_object('net.connman.iwd', '/'), 'org.freedesktop.DBus.ObjectManager')
self.devices = {}
self.objects = manager.GetManagedObjects()
for path in self.objects:
if DEVICE_IF in self.objects[path]:
self.add_dev(path)
for path in self.objects:
if PEER_IF in self.objects[path]:
self.add_peer(path)
self.populate_devices()
self.dbus.add_signal_receiver(self.on_properties_changed,
bus_name="net.connman.iwd",
@ -883,6 +873,18 @@ class WFDSource(Gtk.Window):
dbus_interface="org.freedesktop.DBus.ObjectManager",
signal_name="InterfacesRemoved")
self.objects = manager.GetManagedObjects()
self.devices = {}
for path in self.objects:
if DEVICE_IF in self.objects[path]:
self.add_dev(path)
for path in self.objects:
if PEER_IF in self.objects[path]:
self.add_peer(path)
self.populate_devices()
svc_mgr = dbus.Interface(self.dbus.get_object('net.connman.iwd', '/net/connman/iwd'), SVC_MGR_IF)
svc_mgr.RegisterDisplayService({
'Source': True,