mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-25 17:59:25 +01:00
auto-t: iwd.py: fix re-scanning bug on get_ordered_networks
Certain scenarios coupled with lost beacons could result in OrderedNetwork being initialized many times until the dbus library reached its maximum signal registrations. This could happen where there are two networks, IWD finds one in a scan but continues to scan for the other and the beacons are lost. The way get_ordered_networks was written it returns early if any networks are found. Since get_ordered_network (not plural) uses get_ordered_networks() in a loop this caused OrderedNetwork's to be created rapidly until python raises an exception. To fix this, pass an optional list of networks being looked for to get_ordered_networks. Only if all the networks in the list are found will it return early, otherwise it will continue to scan.
This commit is contained in:
parent
4e61d04e0d
commit
392eebc0a9
@ -437,7 +437,7 @@ class Device(IWDDBusAbstract):
|
||||
|
||||
self._wait_for_async_op()
|
||||
|
||||
def get_ordered_networks(self, scan_if_needed = True, full_scan = False):
|
||||
def get_ordered_networks(self, scan_if_needed = True, full_scan = False, list = []):
|
||||
'''Return the list of networks found in the most recent
|
||||
scan, sorted by their user interface importance
|
||||
score as calculated by iwd. If the device is
|
||||
@ -454,7 +454,10 @@ class Device(IWDDBusAbstract):
|
||||
ordered_network = OrderedNetwork(bus_obj, self._bus, self._namespace)
|
||||
ordered_networks.append(ordered_network)
|
||||
|
||||
if len(ordered_networks) > 0:
|
||||
names = [x.name for x in ordered_networks]
|
||||
|
||||
# all() will always return true if 'list' is empty
|
||||
if all(x in names for x in list) and len(names) > 0:
|
||||
return ordered_networks
|
||||
elif not scan_if_needed:
|
||||
return None
|
||||
@ -489,8 +492,8 @@ class Device(IWDDBusAbstract):
|
||||
network wasn't found. If the network is not found an exception is
|
||||
raised, this removes the need to extra asserts in autotests.
|
||||
'''
|
||||
def wait_for_network(self, network, scan_if_needed):
|
||||
networks = self.get_ordered_networks(scan_if_needed)
|
||||
def wait_for_network(self, network, scan_if_needed, full_scan):
|
||||
networks = self.get_ordered_networks(scan_if_needed, full_scan, list=[network])
|
||||
|
||||
if not networks:
|
||||
# No point in continuing if we aren't going to re-scan
|
||||
@ -505,7 +508,7 @@ class Device(IWDDBusAbstract):
|
||||
|
||||
return False
|
||||
|
||||
return ctx.non_block_wait(wait_for_network, 30, self, network, scan_if_needed,
|
||||
return ctx.non_block_wait(wait_for_network, 30, self, network, scan_if_needed, full_scan,
|
||||
exception=Exception("Network %s not found" % network))
|
||||
|
||||
def wps_push_button(self):
|
||||
|
Loading…
Reference in New Issue
Block a user