Skip to contentSkip to conversation

test-runner: fix Radio/Interface circular reference

PATCH Applied James Prestwood 2 participants 2 messages Nov 3, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test-runner: fix Radio/Interface circular reference

Code was added with commit 04487f575b6 which passes a radio object to the Interface class constructor and stores it in the Interface object. The radio class also stores each Interface object which creates a circular reference and causes the Radio to stick around long after the tests finishes.

I cannot see why the Interface needs to keep track of the Radio object. None of the wpa_supplicant utilities use this so it has been removed.

---
 tools/test-runner | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
tools/test-runner +2 -3
index 3ae4558c..b4840fa4 100755
@@ -246,11 +246,10 @@ class Process:
 				raise Exception("Timed out waiting for socket")
 
 class Interface:
-	def __init__(self, name, config, radio):
+	def __init__(self, name, config):
 		self.name = name
 		self.ctrl_interface = '/var/run/hostapd/' + name
 		self.config = config
-		self.radio = radio
 
 	def __del__(self):
 		Process(['iw', 'dev', self.name, 'del'], True)
@@ -276,7 +275,7 @@ class Radio:
 
 		intf_id += 1
 
-		self.interface = Interface(ifname, config, self)
+		self.interface = Interface(ifname, config)
 		self.use = use
 
 		Process(['iw', 'phy', self.name, 'interface', 'add', ifname,
Signature · 1 line
2.26.2
#1 lore raw

Hi James,

Quoted 6 lines · James Prestwood

Code was added with commit 04487f575b6 which passes a radio object to the Interface class constructor and stores it in the Interface object. The radio class also stores each Interface object which creates a circular reference and causes the Radio to stick around long after the tests finishes.

Quoted 7 lines

I cannot see why the Interface needs to keep track of the Radio object. None of the wpa_supplicant utilities use this so it has been removed.

---
  tools/test-runner | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)

Applied, thanks.

Regards,
-Denis