3
0
mirror of https://git.kernel.org/pub/scm/network/wireless/iwd.git synced 2024-11-25 17:59:25 +01:00

auto-t: AdHoc - address race condition

The AdHoc methods used to miss the change in properties
on AdHoc interface. To address the race condition, we
subscribe 'PropertiesChanged' signal first and then do
GetAll properties call. This way we are not missing
'PropertiesChanged' signal in between these calls.
This commit is contained in:
Tim Kourt 2019-03-22 10:30:30 -07:00 committed by Denis Kenzior
parent 588848651a
commit 20ac57783b

View File

@ -468,11 +468,6 @@ class Device(IWDDBusAbstract):
self._prop_proxy.Set(IWD_DEVICE_INTERFACE, 'Mode', 'station')
def adhoc_wait_for_disconnected(self, addr):
props = self._prop_proxy.GetAll(IWD_ADHOC_INTERFACE)
if props.get('ConnectedPeers', None):
if addr not in props['ConnectedPeers']:
return
self._adhoc_prop_found = False
self._adhoc_timed_out = False
@ -487,6 +482,10 @@ class Device(IWDDBusAbstract):
self._prop_proxy.connect_to_signal('PropertiesChanged',
adhoc_props_changed)
props = self._prop_proxy.GetAll(IWD_ADHOC_INTERFACE)
if props.get('ConnectedPeers', None):
if addr not in props['ConnectedPeers']:
return
GLib.timeout_add(int(30 * 1000), wait_timeout_cb)
context = mainloop.get_context()
@ -496,11 +495,6 @@ class Device(IWDDBusAbstract):
raise TimeoutError("Timed out waiting for peer %s" % addr)
def adhoc_wait_for_connected(self, addr):
props = self._prop_proxy.GetAll(IWD_ADHOC_INTERFACE)
if props.get('ConnectedPeers', None):
if addr in props['ConnectedPeers']:
return
self._adhoc_prop_found = False
self._adhoc_timed_out = False
@ -516,6 +510,11 @@ class Device(IWDDBusAbstract):
self._prop_proxy.connect_to_signal('PropertiesChanged',
adhoc_props_changed)
props = self._prop_proxy.GetAll(IWD_ADHOC_INTERFACE)
if props.get('ConnectedPeers', None):
if addr in props['ConnectedPeers']:
return
GLib.timeout_add(int(15 * 1000), wait_timeout_cb)
context = mainloop.get_context()
while not self._adhoc_prop_found: