mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-29 05:39:24 +01:00
auto-t: hostapd.py: remove _hostapd_restarted concept
The destructor was trying to do more than the scope of a destructor by trying to handle this single case of hostapd being restarted. Instead we can simply pass a keyword argument 'reinit' to the constructor to tell it to reinitialize everything. And as for killing hostapd this can be done in ungraceful_restart itself rather than trying to handle it in the destructor.
This commit is contained in:
parent
7b98a6ed9c
commit
42fe6c5a15
@ -43,10 +43,10 @@ class HostapdCLI(object):
|
||||
|
||||
return cls._instances[config]
|
||||
|
||||
def _init_hostapd(self, config):
|
||||
def _init_hostapd(self, config, reinit=False):
|
||||
global ctrl_count
|
||||
|
||||
if self._initialized:
|
||||
if self._initialized and not reinit:
|
||||
return
|
||||
|
||||
self._initialized = True
|
||||
@ -60,9 +60,6 @@ class HostapdCLI(object):
|
||||
|
||||
hapd = ctx.hostapd[config]
|
||||
|
||||
if not hasattr(self, '_hostapd_restarted'):
|
||||
self._hostapd_restarted = False
|
||||
|
||||
self.interface = hapd.intf
|
||||
self.config = hapd.config
|
||||
|
||||
@ -131,12 +128,6 @@ class HostapdCLI(object):
|
||||
except:
|
||||
pass
|
||||
|
||||
if self._hostapd_restarted:
|
||||
ctx.stop_process(ctx.hostapd.process, force)
|
||||
|
||||
self.interface.set_interface_state('down')
|
||||
self.interface.set_interface_state('up')
|
||||
|
||||
def __del__(self):
|
||||
self._del_hostapd()
|
||||
|
||||
@ -215,8 +206,10 @@ class HostapdCLI(object):
|
||||
'''
|
||||
Ungracefully kill and restart hostapd
|
||||
'''
|
||||
# set flag so hostapd can be killed after the test
|
||||
self._hostapd_restarted = True
|
||||
ctx.stop_process(ctx.hostapd.process, True)
|
||||
|
||||
self.interface.set_interface_state('down')
|
||||
self.interface.set_interface_state('up')
|
||||
|
||||
self._del_hostapd(force=True)
|
||||
|
||||
@ -226,7 +219,7 @@ class HostapdCLI(object):
|
||||
time.sleep(1)
|
||||
|
||||
# New hostapd process, so re-init
|
||||
self._init_hostapd(config=self.config)
|
||||
self._init_hostapd(config=self.config, reinit=True)
|
||||
|
||||
def req_beacon(self, addr, request):
|
||||
'''
|
||||
|
Loading…
Reference in New Issue
Block a user