Commit aff69950 authored by Léo-Paul Géneau's avatar Léo-Paul Géneau 👾

multicast: Fix 100% cpu load from select use

Implement select in multicast.py to fix immediate return causing 100% cpu load
See merge request !39
parent f4506017
......@@ -366,12 +366,6 @@ def main():
R[r] = partial(tunnel_manager.handleServerEvent, r)
x.close()
if config.multicast:
from re6st.multicast import PimDm
pimdm = PimDm()
cleanup.append(pimdm.run(config.iface_list, config.run).stop)
R[pimdm.s_netlink] = pimdm.addInterfaceWhenReady
ip('addr', my_ip + '/%s' % len(subnet),
'dev', config.main_interface)
if_rt = ['ip', '-6', 'route', 'del',
......@@ -458,6 +452,11 @@ def main():
select_list = [forwarder.select] if forwarder else []
if config.console:
select_list.append(console.select)
if config.multicast:
from re6st.multicast import PimDm
pimdm = PimDm()
cleanup.append(pimdm.run(config.iface_list, config.run).stop)
select_list.append(pimdm.select)
select_list += tunnel_manager.select, utils.select
while True:
args = R.copy(), {}, []
......
......@@ -72,9 +72,6 @@ class PimDm(object):
subprocess.call(['pim-dm', '-aimld', ifname])
def addInterfaceWhenReady(self):
if not self.not_ready_iface_set:
return
data = self.s_netlink.recv(65535)
unpack = unpacker(data)
msg_len, msg_type, flags, seq, pid = unpack("=LHHLL")
......@@ -101,7 +98,7 @@ class PimDm(object):
def isStarted(self):
if not self.started:
self.started = os.path.exists('/run/pim-dm/0')
return self.started
return self.started
def run(self, iface_list, run_path):
# pim-dm requires interface to be up at startup,
......@@ -127,6 +124,10 @@ class PimDm(object):
return utils.Popen(['pim-dm', '-config', conf_file_path])
def select(self, r, w, t):
if self.not_ready_iface_set:
r[self.s_netlink] = self.addInterfaceWhenReady
def ifap_iter(ifa):
'''Iterate over linked list of ifaddrs'''
while ifa:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment