mirror of
https://git.kernel.org/pub/scm/network/wireless/iwd.git
synced 2024-11-25 17:59:25 +01:00
auto-t: hostapd.py: remove ungraceful_restart
This is no longer needed and greatly simplifies the class
This commit is contained in:
parent
5776ce87d7
commit
70b6451dc2
@ -43,10 +43,10 @@ class HostapdCLI(object):
|
|||||||
|
|
||||||
return cls._instances[config]
|
return cls._instances[config]
|
||||||
|
|
||||||
def _init_hostapd(self, config, reinit=False):
|
def __init__(self, config=None, *args, **kwargs):
|
||||||
global ctrl_count
|
global ctrl_count
|
||||||
|
|
||||||
if self._initialized and not reinit:
|
if self._initialized:
|
||||||
return
|
return
|
||||||
|
|
||||||
self._initialized = True
|
self._initialized = True
|
||||||
@ -83,9 +83,6 @@ class HostapdCLI(object):
|
|||||||
|
|
||||||
ctrl_count = ctrl_count + 1
|
ctrl_count = ctrl_count + 1
|
||||||
|
|
||||||
def __init__(self, config=None, *args, **kwargs):
|
|
||||||
self._init_hostapd(config)
|
|
||||||
|
|
||||||
def _poll_event(self, event):
|
def _poll_event(self, event):
|
||||||
if not self._data_available(0.25):
|
if not self._data_available(0.25):
|
||||||
return False
|
return False
|
||||||
@ -117,20 +114,15 @@ class HostapdCLI(object):
|
|||||||
|
|
||||||
return self.ctrl_sock.recv(4096).decode('utf-8')
|
return self.ctrl_sock.recv(4096).decode('utf-8')
|
||||||
|
|
||||||
def _del_hostapd(self, force=False):
|
def __del__(self):
|
||||||
if not self.ctrl_sock:
|
if self.ctrl_sock:
|
||||||
return
|
self.ctrl_sock.close()
|
||||||
|
|
||||||
self.ctrl_sock.close()
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.remove(self.local_ctrl)
|
os.remove(self.local_ctrl)
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def __del__(self):
|
|
||||||
self._del_hostapd()
|
|
||||||
|
|
||||||
HostapdCLI._instances[self.config] = None
|
HostapdCLI._instances[self.config] = None
|
||||||
|
|
||||||
# Check if this is the final instance
|
# Check if this is the final instance
|
||||||
@ -202,25 +194,6 @@ class HostapdCLI(object):
|
|||||||
if 'OK' not in proc.out:
|
if 'OK' not in proc.out:
|
||||||
raise Exception('BSS_TM_REQ failed, is hostapd built with CONFIG_WNM_AP=y?')
|
raise Exception('BSS_TM_REQ failed, is hostapd built with CONFIG_WNM_AP=y?')
|
||||||
|
|
||||||
def ungraceful_restart(self):
|
|
||||||
'''
|
|
||||||
Ungracefully kill and restart hostapd
|
|
||||||
'''
|
|
||||||
ctx.stop_process(ctx.hostapd.process, True)
|
|
||||||
|
|
||||||
self.interface.set_interface_state('down')
|
|
||||||
self.interface.set_interface_state('up')
|
|
||||||
|
|
||||||
self._del_hostapd(force=True)
|
|
||||||
|
|
||||||
ctx.start_hostapd()
|
|
||||||
|
|
||||||
# Give hostapd a second to start and initialize the control interface
|
|
||||||
time.sleep(1)
|
|
||||||
|
|
||||||
# New hostapd process, so re-init
|
|
||||||
self._init_hostapd(config=self.config, reinit=True)
|
|
||||||
|
|
||||||
def req_beacon(self, addr, request):
|
def req_beacon(self, addr, request):
|
||||||
'''
|
'''
|
||||||
Send a RRM Beacon request
|
Send a RRM Beacon request
|
||||||
|
Loading…
Reference in New Issue
Block a user