All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/4] auto-t: iwd.py: fix re-scanning bug on get_ordered_networks
@ 2021-11-02 19:57 James Prestwood
  0 siblings, 0 replies; only message in thread
From: James Prestwood @ 2021-11-02 19:57 UTC (permalink / raw)
  To: iwd

[-- Attachment #1: Type: text/plain, Size: 3013 bytes --]

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.
---
 autotests/util/iwd.py | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/autotests/util/iwd.py b/autotests/util/iwd.py
index d6a7fe06..5e1e2721 100755
--- a/autotests/util/iwd.py
+++ b/autotests/util/iwd.py
@@ -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):
-- 
2.31.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-11-02 19:57 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-02 19:57 [PATCH 2/4] auto-t: iwd.py: fix re-scanning bug on get_ordered_networks James Prestwood

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.